3 #include <SimoxUtility/math/pose.h>
4 #include <SimoxUtility/math/rescale.h>
20 defs->optional(
enabled, prefix +
"enabled",
21 "Enable or disable visualization of objects.");
23 "Frequency of visualization.");
25 "If true, show global poses. If false, show poses in robot frame.");
26 defs->optional(
alpha, prefix +
"alpha",
27 "Alpha of objects (1 = solid, 0 = transparent).");
29 "If true, use the pose confidence as alpha (if < 1.0).");
30 defs->optional(
oobbs, prefix +
"oobbs",
31 "Enable showing oriented bounding boxes.");
34 "Enable showing object frames.");
36 "Scaling of object frames.");
41 "Prefer articulated object models if available.");
49 defs->optional(
position, prefix +
"position",
50 "Enable showing pose gaussians (position part).");
52 "Scaling of pose gaussians (position part).");
55 "Enable showing pose gaussians (orientation part).");
57 "Scaling of pose gaussians (orientation part).");
59 "Displace center orientation (co)variance circle arrows along their rotation axis.");
63 std::vector<viz::Layer>
65 const std::map<std::string, objpose::ObjectPoseSeq>& objectPoses,
66 const std::map<std::string, std::vector<std::map<DateTime, objpose::ObjectPose>>>&
70 std::vector<viz::Layer> layers;
71 for (
const auto& [name, poses] : objectPoses)
78 auto poseHistoryMap = poseHistories.find(name);
79 if (poseHistoryMap != poseHistories.end())
81 layers.push_back(
visualizeProvider(name, poses, poseHistoryMap->second, objectFinder));
92 std::vector<viz::Layer>
94 const std::vector<std::map<DateTime, objpose::ObjectPose>>& poseHistories,
97 std::map<std::string, viz::Layer> stage;
98 for (
size_t i = 0; i < objectPoses.size(); ++i)
100 if(objectPoses.at(i).providerName.empty())
111 return simox::alg::get_values(stage);
115 std::vector<viz::Layer>
118 const std::map<
ObjectID, std::map<DateTime, objpose::ObjectPose>>& poseHistories,
121 std::map<std::string, viz::Layer> stage;
122 for (
const auto& [
id, pose] : objectPoses)
125 auto poseHistoryMap = poseHistories.find(
id);
126 if (poseHistoryMap != poseHistories.end())
129 getLayer(pose.providerName, stage), pose, poseHistoryMap->second, objectFinder);
136 return simox::alg::get_values(stage);
141 const std::string& providerName,
142 std::map<std::string, viz::Layer>& stage)
const
144 auto it = stage.find(providerName);
145 if (it == stage.end())
147 it = stage.emplace(providerName,
arviz.
layer(providerName)).first;
155 const std::string& providerName,
157 const std::vector<std::map<DateTime, objpose::ObjectPose>>& poseHistories,
161 for (
size_t i = 0; i < poseHistories.size(); ++i)
171 const std::map<DateTime, objpose::ObjectPose>& poseHistory,
180 const std::string key =
id.
str();
183 std::optional<ObjectInfo> objectInfo = objectFinder.
findObject(
id);
185 auto makeObject = [&objectInfo, &id](
const std::string& key)
190 object.file(objectInfo->package(), objectInfo->simoxXML().relativePath);
194 object.fileByObjectFinder(
id);
199 bool hasObject =
false;
204 if (std::optional<PackageFileLocation> model = objectInfo->getArticulatedModel())
208 robot.
file(model->package, model->package +
"/" + model->relativePath);
236 layer.
add(
viz::Box(key +
" OOBB").
set(oobb).color(simox::Color::lime(255, 64)));
255 return position or orientation;
275 .position(ellipsoid.
center)
283 for (
int i = 0; i < 3; ++i)
285 Eigen::Vector3i color = Eigen::Vector3i::Zero();
290 ellipsoid.
center + positionScale * ellipsoid.
size(i)
301 const float pi =
static_cast<float>(
M_PI);
302 for (
int i = 0; i < 3; ++i)
304 const bool global =
true;
307 Eigen::Vector4i color = Eigen::Vector4i::Zero();
312 .position(orientationDisplaced
313 ? ellipsoid.
center + orientationScale * rot.axis()
317 .
completion(simox::math::rescale(rot.angle(), 0.f,
pi * 2, 0.f, 1.f))
318 .
width(simox::math::rescale(rot.angle(), 0.f,
pi * 2, 2.f, 7.f))
332 alpha.setRange(0, 1.0);
364 grid.
add(
Label(
"Alpha"), {row, 0}).add(
alpha, {row, 1}, {1, 3});
387 group.setLabel(
"Visualization");
388 group.addChild(grid);
399 grid.
add(
Label(
"Position"), {row, 0}).add(position, {row, 1});
400 grid.
add(
Label(
"Scale:"), {row, 2}).add(positionScale, {row, 3});
403 grid.
add(
Label(
"Orientation"), {row, 0}).add(orientation, {row, 1});
404 grid.
add(
Label(
"Scale:"), {row, 2}).add(orientationScale, {row, 3});
405 grid.
add(
Label(
"Displaced"), {row, 4}).add(orientationDisplaced, {row, 5});
409 group.setLabel(
"Pose Gaussians");
410 group.addChild(grid);
416 data.position = position.getValue();
417 data.positionScale = positionScale.getValue();
419 data.orientation = orientation.getValue();
420 data.orientationScale = orientationScale.getValue();
421 data.orientationDisplaced = orientationDisplaced.getValue();