3 #include <SimoxUtility/math/pose.h>
4 #include <SimoxUtility/math/rescale.h>
20 defs->optional(
enabled, prefix +
"enabled",
"Enable or disable visualization of objects.");
21 defs->optional(
frequencyHz, prefix +
"frequenzyHz",
"Frequency of visualization.");
23 prefix +
"inGlobalFrame",
24 "If true, show global poses. If false, show poses in robot frame.");
25 defs->optional(
alpha, prefix +
"alpha",
"Alpha of objects (1 = solid, 0 = transparent).");
27 prefix +
"alphaByConfidence",
28 "If true, use the pose confidence as alpha (if < 1.0).");
29 defs->optional(
oobbs, prefix +
"oobbs",
"Enable showing oriented bounding boxes.");
31 defs->optional(
objectFrames, prefix +
"objectFrames",
"Enable showing object frames.");
38 prefix +
"useArticulatedModels",
39 "Prefer articulated object models if available.");
48 position, prefix +
"position",
"Enable showing pose gaussians (position part).");
50 positionScale, prefix +
"positionScale",
"Scaling of pose gaussians (position part).");
53 orientation, prefix +
"position",
"Enable showing pose gaussians (orientation part).");
55 prefix +
"positionScale",
56 "Scaling of pose gaussians (orientation part).");
59 prefix +
"positionDisplaced",
60 "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())
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);
114 std::vector<viz::Layer>
117 const std::map<
ObjectID, std::map<DateTime, objpose::ObjectPose>>& poseHistories,
120 std::map<std::string, viz::Layer> stage;
121 for (
const auto& [
id, pose] : objectPoses)
124 auto poseHistoryMap = poseHistories.find(
id);
125 if (poseHistoryMap != poseHistories.end())
128 getLayer(pose.providerName, stage), pose, poseHistoryMap->second, objectFinder);
135 return simox::alg::get_values(stage);
139 Visu::getLayer(
const std::string& providerName, std::map<std::string, viz::Layer>& stage)
const
141 auto it = stage.find(providerName);
142 if (it == stage.end())
144 it = stage.emplace(providerName,
arviz.
layer(providerName)).first;
151 const std::string& providerName,
153 const std::vector<std::map<DateTime, objpose::ObjectPose>>& poseHistories,
157 for (
size_t i = 0; i < poseHistories.size(); ++i)
167 const std::map<DateTime, objpose::ObjectPose>& poseHistory,
176 const std::string key =
id.
str();
180 std::optional<ObjectInfo> objectInfo = objectFinder.
findObject(
id);
182 auto makeObject = [&objectInfo, &id](
const std::string& key)
187 object.file(objectInfo->package(), objectInfo->simoxXML().relativePath);
191 object.fileByObjectFinder(
id);
196 bool hasObject =
false;
201 if (std::optional<PackageFileLocation> model = objectInfo->getArticulatedModel())
205 robot.
file(model->package, model->package +
"/" + model->relativePath);
230 const simox::OrientedBoxf oobb =
232 layer.
add(
viz::Box(key +
" OOBB").
set(oobb).color(simox::Color::lime(255, 64)));
253 return position or orientation;
271 .position(ellipsoid.
center)
278 for (
int i = 0; i < 3; ++i)
280 Eigen::Vector3i color = Eigen::Vector3i::Zero();
285 ellipsoid.
center + positionScale * ellipsoid.
size(i) *
294 const float pi =
static_cast<float>(
M_PI);
295 for (
int i = 0; i < 3; ++i)
297 const bool global =
true;
300 Eigen::Vector4i color = Eigen::Vector4i::Zero();
305 .position(orientationDisplaced
306 ? ellipsoid.
center + orientationScale * rot.axis()
310 .
completion(simox::math::rescale(rot.angle(), 0.f,
pi * 2, 0.f, 1.f))
311 .
width(simox::math::rescale(rot.angle(), 0.f,
pi * 2, 2.f, 7.f))
324 alpha.setRange(0, 1.0);
356 grid.
add(
Label(
"Alpha"), {row, 0}).add(
alpha, {row, 1}, {1, 3});
379 group.setLabel(
"Visualization");
380 group.addChild(grid);
391 grid.
add(
Label(
"Position"), {row, 0}).add(position, {row, 1});
392 grid.
add(
Label(
"Scale:"), {row, 2}).add(positionScale, {row, 3});
395 grid.
add(
Label(
"Orientation"), {row, 0}).add(orientation, {row, 1});
396 grid.
add(
Label(
"Scale:"), {row, 2}).add(orientationScale, {row, 3});
397 grid.
add(
Label(
"Displaced"), {row, 4}).add(orientationDisplaced, {row, 5});
401 group.setLabel(
"Pose Gaussians");
402 group.addChild(grid);
408 data.position = position.getValue();
409 data.positionScale = positionScale.getValue();
411 data.orientation = orientation.getValue();
412 data.orientationScale = orientationScale.getValue();
413 data.orientationDisplaced = orientationDisplaced.getValue();