HumanPoseMMMBody68.cpp
Go to the documentation of this file.
2
3#include <string>
4
6
9
13
14namespace armarx::viz
15{
16
17 using namespace armarx::human::pose::model::mmm_body_68;
18
19 void
21 HumanPoseLayers& layers,
22 const std::string& prefix,
23 const DrawingStyle& drawingStyle)
24 {
26
27 // Segments.
28 for (const auto& [index1, index2] : Segments)
29 {
30 const std::string& name1 = JointNames.map().left.at(index1);
31 const std::string& name2 = JointNames.map().left.at(index2);
32
33 // Only draw segment if start end end are in keypoint map.
34 if (pose.keypoints.find(name1) == pose.keypoints.end() or
35 pose.keypoints.find(name2) == pose.keypoints.end())
36 {
37 continue;
38 }
39
40 const armarx::armem::human::PoseKeypoint p1 = pose.keypoints.at(name1);
41 const armarx::armem::human::PoseKeypoint p2 = pose.keypoints.at(name2);
42
43 const Eigen::Vector3f pos1 = p1.positionGlobal->toEigen();
44 const Eigen::Vector3f pos2 = p2.positionGlobal->toEigen();
45
46 if (pos1.allFinite() and pos2.allFinite())
47 {
48 if (pos1 == Eigen::Vector3f(0, 0, 0) or pos2 == Eigen::Vector3f(0, 0, 0))
49 {
50 continue;
51 }
52
53 const armarx::viz::Color color =
54 drawingStyle.segmentColor.value_or(Colors.at(index2));
55
56 const float scale = (index2 > Joints::WristRight && index2 <= Joints::HandTCPRight)
57 ? drawingStyle.thinFactor
58 : 1.;
60 armarx::viz::Cylinder(prefix + "::" + p1.label + "_" + p2.label)
61 .fromTo(pos1, pos2)
62 .radius(scale * drawingStyle.segmentThickness)
63 .color(color);
64 layers.skeleton.add(line);
65 }
66 }
67
68 // Keypoints.
69 for (auto const& [id, name] : JointNames.map())
70 {
71 if (pose.keypoints.find(name) != pose.keypoints.end())
72 {
73 armarx::armem::human::PoseKeypoint kp = pose.keypoints.at(name);
74
75 const armarx::viz::Color color = drawingStyle.jointColor.value_or(Colors.at(id));
76 const float scale = (id > Joints::WristRight && id <= Joints::HandTCPRight)
77 ? drawingStyle.thinFactor
78 : 1.;
79 armarx::viz::Sphere sphere = armarx::viz::Sphere(prefix + "::" + name)
80 .position(kp.positionGlobal->toEigen())
81 .radius(scale * drawingStyle.jointThickness)
82 .color(color);
83 layers.skeleton.add(sphere);
84 }
85 }
86 }
87
88} // namespace armarx::viz
DerivedT & color(Color color)
Definition ElementOps.h:218
DerivedT & position(float x, float y, float z)
Definition ElementOps.h:136
const std::map< Joints, simox::Color > Colors
const simox::meta::EnumNames< Joints > JointNames
Names of the joints as defined in the body model.
const std::vector< std::pair< Joints, Joints > > Segments
Segments (defined by pairs of joints) as defined in the body model.
void addPoseToLayer(const armarx::armem::human::HumanPose &pose, HumanPoseLayers &layers, const std::string &prefix, const DrawingStyle &drawingStyle=DrawingStyle())
This file is part of ArmarX.
std::optional< armarx::FramedPosition > positionGlobal
Definition types.h:37
Cylinder & radius(float r)
Definition Elements.h:76
Cylinder & fromTo(Eigen::Vector3f from, Eigen::Vector3f to)
Definition Elements.cpp:93
std::optional<::simox::Color > jointColor
Definition HumanPose.h:30
std::optional<::simox::Color > segmentColor
Definition HumanPose.h:29
void add(ElementT const &element)
Definition Layer.h:31
Sphere & radius(float r)
Definition Elements.h:138
#define ARMARX_TRACE
Definition trace.h:77