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