MRPT  1.9.9
CSkeletonTracker.cpp
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | https://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2020, Individual contributors, see AUTHORS file |
6  | See: https://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See: https://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 
10 #include "hwdrivers-precomp.h" // Precompiled headers
11 
13 
14 // opengl includes
15 #include <mrpt/opengl/CBox.h>
16 #include <mrpt/opengl/CCylinder.h>
20 #include <mrpt/opengl/CSphere.h>
21 #include <mrpt/opengl/CText.h>
24 #include <mrpt/poses/CPoint3D.h>
25 
27 
28 using namespace mrpt::hwdrivers;
29 using namespace mrpt::poses;
30 using namespace mrpt::obs;
31 using namespace mrpt::img;
32 using namespace std;
33 
34 #define skl_states (static_cast<nite::SkeletonState*>(m_skeletons_ptr))
35 #define user_tracker (static_cast<nite::UserTracker*>(m_userTracker_ptr))
36 #define MAX_USERS 10
37 #define FILL_JOINT_DATA(_J1, _J2) \
38  obs->_J1.x = user.getSkeleton().getJoint(_J2).getPosition().x; \
39  obs->_J1.y = user.getSkeleton().getJoint(_J2).getPosition().y; \
40  obs->_J1.z = user.getSkeleton().getJoint(_J2).getPosition().z; \
41  obs->_J1.conf = user.getSkeleton().getJoint(_J2).getPositionConfidence();
42 
43 #if MRPT_HAS_NITE2
44 #include "NiTE.h"
45 #pragma comment(lib, "NiTE2.lib")
46 #endif
47 
48 string jointNames[] = {
49  "head", "neck", "torso", "left_shoulder", "left_elbow",
50  "left_hand", "left_hip", "left_knee", "left_foot", "right_shoulder",
51  "right_elbow", "right_hand", "right_hip", "right_knee", "right_foot"};
52 
53 /*-------------------------------------------------------------
54  CSkeletonTracker
55 -------------------------------------------------------------*/
56 CSkeletonTracker::CSkeletonTracker() : m_timeStartTT(), m_sensorPose()
57 
58 {
59  m_sensorLabel = "skeletonTracker";
60 
61 #if MRPT_HAS_OPENNI2 && MRPT_HAS_NITE2
62  m_skeletons_ptr = new nite::SkeletonState[MAX_USERS];
63  m_userTracker_ptr = new nite::UserTracker;
64  for (int i = 0; i < MAX_USERS; ++i) skl_states[i] = nite::SKELETON_NONE;
65 
66  m_linesToPlot.resize(NUM_LINES);
67  m_joint_theta.resize(NUM_JOINTS);
68  for (int i = 1; i < NUM_JOINTS; ++i)
69  m_joint_theta[i] = (i - 1) * (M_2PI / (NUM_JOINTS - 1));
70 #else
72  "MRPT has been compiled with 'BUILD_OPENNI2'=OFF or 'BUILD_NITE2'=OFF, "
73  "so this class cannot be used.");
74 #endif
75 }
76 
77 /*-------------------------------------------------------------
78  ~CSkeletonTracker
79 -------------------------------------------------------------*/
81 {
82 #if MRPT_HAS_OPENNI2 && MRPT_HAS_NITE2
83  nite::NiTE::shutdown(); // close tracker
84  delete[] skl_states;
85  m_skeletons_ptr = nullptr;
86  delete user_tracker;
87  m_userTracker_ptr = nullptr;
88 #endif
89  if (m_win) m_win.reset();
90 }
91 
92 /*-------------------------------------------------------------
93  processPreviewNone
94 -------------------------------------------------------------*/
96 {
97  using namespace mrpt::opengl;
98 
99  // show skeleton data
100  if (m_showPreview)
101  {
102  if (!m_win)
103  {
104  string caption = string("Preview of ") + m_sensorLabel;
105  m_win = mrpt::gui::CDisplayWindow3D::Create(caption, 800, 600);
106 
107  COpenGLScene::Ptr& scene = m_win->get3DSceneAndLock();
108  scene->insert(std::make_shared<CGridPlaneXZ>(-3, 3, 0, 5, -1.5));
109 
110  // set camera parameters
111  m_win->setCameraElevationDeg(-90);
112  m_win->setCameraAzimuthDeg(90);
113  m_win->setCameraZoom(4);
114  m_win->setCameraPointingToPoint(0, 0, 0);
115 
116  // insert initial body
117  CSetOfObjects::Ptr body = std::make_shared<CSetOfObjects>();
118  body->setName("body");
119  for (const auto& jointName : jointNames)
120  {
121  CSphere::Ptr sph = std::make_shared<CSphere>(0.03f);
122  sph->setColor(0, 1, 0);
123  sph->setName(jointName);
124  body->insert(sph);
125  }
126 
127  // insert initial lines
128  CSetOfLines::Ptr lines = std::make_shared<CSetOfLines>();
129  lines->setName("lines");
130  lines->setColor(0, 0, 1);
131  body->insert(lines);
132 
133  scene->insert(body);
134  m_win->unlockAccess3DScene();
135  }
136 
137  if (m_win && m_win->isOpen())
138  {
139  COpenGLScene::Ptr& scene = m_win->get3DSceneAndLock();
140  {
141  m_win->addTextMessage(0.35, 0.9, "Please, adopt this position");
142 
143  // insert translucid dummy and help text (it will go away when
144  // measurements are taken)
145  if (!scene->getByName("dummy"))
146  {
147  const double SCALE = 0.8;
148  const double BODY_RADIUS = 0.22 * SCALE;
149  const double BODY_LENGTH = 0.8 * SCALE;
150  const double ARM_RADIUS = 0.05 * SCALE;
151  const double ARM_LENGTH = 0.4 * SCALE;
152  const double LEG_RADIUS = 0.1 * SCALE;
153  const double LEG_LENGTH = 0.8 * SCALE;
154  const double HEAD_RADIUS = 0.15 * SCALE;
155  const double ALPHA_CH = 0.8;
156 
157  CSetOfObjects::Ptr dummy =
158  std::make_shared<CSetOfObjects>();
159  dummy->setName("dummy");
160  dummy->setPose(math::TPose3D(0, 0, 0, 0, 0, -90.0_deg));
161  {
162  // head
163  CSphere::Ptr part =
164  std::make_shared<CSphere>(HEAD_RADIUS);
165  part->setColor(1, 1, 1, ALPHA_CH);
166  part->setPose(math::TPose3D(
167  0, 0, 0.5 * BODY_LENGTH + HEAD_RADIUS, 0, 0, 0));
168  dummy->insert(part);
169  }
170  {
171  // body
172  CCylinder::Ptr part = std::make_shared<CCylinder>(
173  BODY_RADIUS, BODY_RADIUS, BODY_LENGTH);
174  part->setColor(1, 1, 1, ALPHA_CH);
175  part->setPose(
176  math::TPose3D(0, 0, -BODY_LENGTH / 2, 0, 0, 0));
177  dummy->insert(part);
178  }
179  {
180  // left arm 0
181  CCylinder::Ptr part = std::make_shared<CCylinder>(
182  ARM_RADIUS, ARM_RADIUS, ARM_LENGTH);
183  part->setColor(1, 1, 1, ALPHA_CH);
184  part->setPose(math::TPose3D(
185  -BODY_RADIUS, 0, 0.5 * BODY_LENGTH - ARM_RADIUS, 0,
186  -90.0_deg, 0));
187  dummy->insert(part);
188  }
189  {
190  // left arm 1
191  CCylinder::Ptr part = std::make_shared<CCylinder>(
192  ARM_RADIUS, ARM_RADIUS, ARM_LENGTH);
193  part->setColor(1, 1, 1, ALPHA_CH);
194  part->setPose(math::TPose3D(
195  -BODY_RADIUS - ARM_LENGTH + ARM_RADIUS, 0,
196  0.5 * BODY_LENGTH - ARM_RADIUS, 0, 0, 0));
197  dummy->insert(part);
198  }
199  {
200  // right arm 0
201  CCylinder::Ptr part = std::make_shared<CCylinder>(
202  ARM_RADIUS, ARM_RADIUS, ARM_LENGTH);
203  part->setColor(1, 1, 1, ALPHA_CH);
204  part->setPose(math::TPose3D(
205  BODY_RADIUS, 0, 0.5 * BODY_LENGTH - ARM_RADIUS, 0,
206  90.0_deg, 0));
207  dummy->insert(part);
208  }
209  {
210  // right arm 1
211  CCylinder::Ptr part = std::make_shared<CCylinder>(
212  ARM_RADIUS, ARM_RADIUS, ARM_LENGTH);
213  part->setColor(1, 1, 1, ALPHA_CH);
214  part->setPose(math::TPose3D(
215  BODY_RADIUS + ARM_LENGTH - ARM_RADIUS, 0,
216  0.5 * BODY_LENGTH - ARM_RADIUS, 0, 0, 0));
217  dummy->insert(part);
218  }
219  {
220  // left leg
221  CCylinder::Ptr part = std::make_shared<CCylinder>(
222  LEG_RADIUS, LEG_RADIUS, LEG_LENGTH);
223  part->setColor(1, 1, 1, ALPHA_CH);
224  part->setPose(math::TPose3D(
225  -BODY_RADIUS + LEG_RADIUS, 0,
226  -(0.5 * BODY_LENGTH + LEG_LENGTH), 0, 0, 0));
227  dummy->insert(part);
228  }
229  {
230  // right leg
231  CCylinder::Ptr part = std::make_shared<CCylinder>(
232  LEG_RADIUS, LEG_RADIUS, LEG_LENGTH);
233  part->setColor(1, 1, 1, ALPHA_CH);
234  part->setPose(math::TPose3D(
235  BODY_RADIUS - LEG_RADIUS, 0,
236  -(0.5 * BODY_LENGTH + LEG_LENGTH), 0, 0, 0));
237  dummy->insert(part);
238  }
239  scene->insert(dummy);
240  } // end-if
241  else
242  {
243  CSetOfObjects::Ptr dummy =
244  std::dynamic_pointer_cast<CSetOfObjects>(
245  scene->getByName("dummy"));
246  dummy->setVisibility(true);
247  }
248 
249  // update joints positions
250  CSetOfObjects::Ptr body =
251  std::dynamic_pointer_cast<CSetOfObjects>(
252  scene->getByName("body"));
253  ASSERT_(body);
254 
255  for (int i = 0; i < NUM_JOINTS; ++i)
256  {
257  CSphere::Ptr s = std::dynamic_pointer_cast<CSphere>(
258  body->getByName(jointNames[i]));
259  CPoint3D sphPos;
260  if (i == 0)
261  sphPos = CPoint3D(0, 0, 0);
262  else
263  {
264  m_joint_theta[i] += M_2PI / (10 * (NUM_JOINTS - 1));
265  sphPos.x(0.5 * cos(m_joint_theta[i]));
266  sphPos.y(0.5 * sin(m_joint_theta[i]));
267  sphPos.z(0.0);
268  }
269  s->setPose(sphPos);
270  s->setColor(1, 0, 0);
271  s->setRadius(i == 0 ? 0.07 : 0.03);
272  } // end-for
273  } // end-get3DSceneAndLock
274  m_win->unlockAccess3DScene();
275  m_win->forceRepaint();
276  } // end if
277  } // end if
278 } // end-processPreviewNone
279 
280 /*-------------------------------------------------------------
281  processPreview
282 -------------------------------------------------------------*/
285 {
286  using namespace mrpt::opengl;
287 
288  // show skeleton data
289  if (m_showPreview)
290  {
291  if (!m_win)
292  {
293  string caption = string("Preview of ") + m_sensorLabel;
294  m_win = mrpt::gui::CDisplayWindow3D::Create(caption, 800, 600);
295 
296  COpenGLScene::Ptr& scene = m_win->get3DSceneAndLock();
297  scene->insert(std::make_shared<CGridPlaneXZ>(-3, 3, 0, 5, -1.5));
298 
299  // set camera parameters
300  m_win->setCameraElevationDeg(-90);
301  m_win->setCameraAzimuthDeg(90);
302  m_win->setCameraZoom(4);
303  m_win->setCameraPointingToPoint(0, 0, 0);
304 
305  // insert initial body
306  CSetOfObjects::Ptr body = std::make_shared<CSetOfObjects>();
307  body->setName("body");
308  for (const auto& jointName : jointNames)
309  {
310  CSphere::Ptr sph = std::make_shared<CSphere>(0.03f);
311  sph->setColor(0, 1, 0);
312  sph->setName(jointName);
313  body->insert(sph);
314  }
315 
316  // insert initial lines
317  CSetOfLines::Ptr lines = std::make_shared<CSetOfLines>();
318  lines->setName("lines");
319  lines->setColor(0, 0, 1);
320  body->insert(lines);
321 
322  scene->insert(body);
323  m_win->unlockAccess3DScene();
324  }
325 
326  if (m_win && m_win->isOpen())
327  {
328  COpenGLScene::Ptr& scene = m_win->get3DSceneAndLock();
329 
330  // remove help text and dummy
331  m_win->clearTextMessages();
332  CSetOfObjects::Ptr dummy = std::dynamic_pointer_cast<CSetOfObjects>(
333  scene->getByName("dummy"));
334  if (dummy) dummy->setVisibility(false);
335 
336  {
337  // update joints positions
338  CSetOfObjects::Ptr body =
339  std::dynamic_pointer_cast<CSetOfObjects>(
340  scene->getByName("body"));
341  ASSERT_(body);
342 
343  for (int i = 0; i < NUM_JOINTS; ++i)
344  {
346 
347  switch (i)
348  {
349  case 0:
350  j = obs->head;
351  break;
352  case 1:
353  j = obs->neck;
354  break;
355  case 2:
356  j = obs->torso;
357  break;
358 
359  case 3:
360  j = obs->left_shoulder;
361  break;
362  case 4:
363  j = obs->left_elbow;
364  break;
365  case 5:
366  j = obs->left_hand;
367  break;
368  case 6:
369  j = obs->left_hip;
370  break;
371  case 7:
372  j = obs->left_knee;
373  break;
374  case 8:
375  j = obs->left_foot;
376  break;
377 
378  case 9:
379  j = obs->right_shoulder;
380  break;
381  case 10:
382  j = obs->right_elbow;
383  break;
384  case 11:
385  j = obs->right_hand;
386  break;
387  case 12:
388  j = obs->right_hip;
389  break;
390  case 13:
391  j = obs->right_knee;
392  break;
393  case 14:
394  j = obs->right_foot;
395  break;
396  } // end-switch
397 
398  CSphere::Ptr s = std::dynamic_pointer_cast<CSphere>(
399  body->getByName(jointNames[i]));
400  s->setPose(mrpt::math::TPose3D(
401  j.x * 1e-3, j.y * 1e-3, j.z * 1e-3, 0, 0, 0));
402  s->setColor(
403  std::min(1.0, 2 * (1 - j.conf)),
404  std::min(1.0, 2 * j.conf), 0);
405  s->setRadius(i == 0 ? 0.07 : 0.03);
406  } // end-for
407 
408  // update lines joining joints
409  CSetOfLines::Ptr lines = std::dynamic_pointer_cast<CSetOfLines>(
410  body->getByName("lines"));
411  ASSERT_(lines);
412 
413  lines->clear();
414  for (int i = 0; i < NUM_LINES; ++i)
415  {
416  pair<JOINT, JOINT> pair = m_linesToPlot[i];
417  CSphere::Ptr s0 = dynamic_pointer_cast<CSphere>(
418  body->getByName(jointNames[pair.first]));
419  CSphere::Ptr s1 = dynamic_pointer_cast<CSphere>(
420  body->getByName(jointNames[pair.second]));
421  ASSERT_(s0 && s1);
422 
423  lines->appendLine(
424  s0->getPoseX(), s0->getPoseY(), s0->getPoseZ(),
425  s1->getPoseX(), s1->getPoseY(), s1->getPoseZ());
426  }
427  } // end-get3DSceneAndLock
428  m_win->unlockAccess3DScene();
429  m_win->forceRepaint();
430  } // end if
431  } // end if
432 }
433 
434 /*-------------------------------------------------------------
435  doProcess
436 -------------------------------------------------------------*/
438 {
439 #if MRPT_HAS_OPENNI2 && MRPT_HAS_NITE2
440  if (m_state == ssError)
441  {
442  std::this_thread::sleep_for(200ms);
443  initialize();
444  }
445 
446  if (m_state == ssError) return;
447 
448  nite::UserTrackerFrameRef userTrackerFrame;
449  nite::Status niteRc = user_tracker->readFrame(&userTrackerFrame);
450 
451  if (niteRc != nite::STATUS_OK)
452  {
453  printf(" [Skeleton tracker] Get next frame failed\n");
454  return;
455  }
456 
457  int n_data_ok = 0;
458  const nite::Array<nite::UserData>& users = userTrackerFrame.getUsers();
459  m_nUsers = users.getSize();
460  for (int i = 0; i < m_nUsers; ++i)
461  {
462  const nite::UserData& user = users[i];
463 
464  // update user state
465  skl_states[user.getId()] = user.getSkeleton().getState();
466 
467  if (user.isNew())
468  {
469  user_tracker->startSkeletonTracking(user.getId());
470  cout << " [Skeleton tracker] New user found" << endl;
471  }
472  else if (user.getSkeleton().getState() == nite::SKELETON_TRACKED)
473  {
474  cout << " [Skeleton tracker] User " << user.getId() << " tracked"
475  << endl;
477  std::make_shared<CObservationSkeleton>();
478 
479  // timestamp
480  const uint64_t nowUI = userTrackerFrame.getTimestamp();
481 
482  uint64_t AtUI = 0;
483  if (m_timeStartUI == 0)
484  {
485  m_timeStartUI = nowUI;
487  }
488  else
489  AtUI = nowUI - m_timeStartUI;
490 
491  /* Board time is usec */
492  const auto AtDO = std::chrono::microseconds(AtUI);
494  obs->timestamp = ts;
495 
496  // fill joint data
497  FILL_JOINT_DATA(head, nite::JOINT_HEAD)
498  FILL_JOINT_DATA(neck, nite::JOINT_NECK)
499  FILL_JOINT_DATA(torso, nite::JOINT_TORSO)
500 
501  FILL_JOINT_DATA(left_shoulder, nite::JOINT_LEFT_SHOULDER)
502  FILL_JOINT_DATA(left_elbow, nite::JOINT_LEFT_ELBOW)
503  FILL_JOINT_DATA(left_hand, nite::JOINT_LEFT_HAND)
504  FILL_JOINT_DATA(left_hip, nite::JOINT_LEFT_HIP)
505  FILL_JOINT_DATA(left_knee, nite::JOINT_LEFT_KNEE)
506  FILL_JOINT_DATA(left_foot, nite::JOINT_LEFT_FOOT)
507 
508  FILL_JOINT_DATA(right_shoulder, nite::JOINT_RIGHT_SHOULDER)
509  FILL_JOINT_DATA(right_elbow, nite::JOINT_RIGHT_ELBOW)
510  FILL_JOINT_DATA(right_hand, nite::JOINT_RIGHT_HAND)
511  FILL_JOINT_DATA(right_hip, nite::JOINT_RIGHT_HIP)
512  FILL_JOINT_DATA(right_knee, nite::JOINT_RIGHT_KNEE)
513  FILL_JOINT_DATA(right_foot, nite::JOINT_RIGHT_FOOT)
514 
515  // sensor label:
516  obs->sensorLabel =
517  m_sensorLabel + "_" + std::to_string(user.getId());
518 
519  appendObservation(obs);
520  processPreview(obs);
521 
522  m_toutCounter = 0;
523  n_data_ok++;
524  } // end-else-if
525  } // end-for
526 
527  if (n_data_ok == 0) // none of the sensors yielded data
528  m_toutCounter++;
529 
530  if (m_toutCounter > 0)
531  {
533  if ((m_toutCounter % 50) == 0)
534  cout << " [Skeleton tracker] Looking for user..." << endl;
535  }
536 
537  if (m_toutCounter > 2000)
538  {
539  m_toutCounter = 0;
540  m_state = ssError;
541 
542  cout << " [Skeleton tracker] No user found after 2000 attempts ..."
543  << endl;
544  nite::NiTE::shutdown(); // close tracker
545  }
546 #else
548  "MRPT has been compiled with 'BUILD_OPENNI2'=OFF or "
549  "'MRPT_HAS_NITE2'=OFF, so this class cannot be used.");
550 #endif
551 }
552 
553 /*-------------------------------------------------------------
554  initialize
555 -------------------------------------------------------------*/
557 {
558 #if MRPT_HAS_OPENNI2 && MRPT_HAS_NITE2
559 
560  // initialize tracker
562  nite::Status niteRc = user_tracker->create();
563 
564  if (niteRc != nite::STATUS_OK)
565  {
566  printf("Couldn't create user tracker\n");
567  m_state = ssError;
568  }
569  else
570  {
571  printf("Sucessfully created user tracker \n");
572  printf(
573  "Start moving around to get detected...\n(PSI pose may be required "
574  "for skeleton calibration, depending on the configuration)\n");
576  }
577  // initialize preview joints and lines
578  if (m_showPreview)
579  {
580  m_linesToPlot[0] = make_pair(NECK, HEAD);
581  m_linesToPlot[1] = make_pair(NECK, TORSO);
582  m_linesToPlot[2] = make_pair(NECK, LEFT_SHOULDER);
583  m_linesToPlot[3] = make_pair(NECK, RIGHT_SHOULDER);
584  m_linesToPlot[4] = make_pair(LEFT_SHOULDER, LEFT_ELBOW);
585  m_linesToPlot[5] = make_pair(LEFT_ELBOW, LEFT_HAND);
586  m_linesToPlot[6] = make_pair(RIGHT_SHOULDER, RIGHT_ELBOW);
587  m_linesToPlot[7] = make_pair(RIGHT_ELBOW, RIGHT_HAND);
588  m_linesToPlot[8] = make_pair(TORSO, LEFT_HIP);
589  m_linesToPlot[9] = make_pair(TORSO, RIGHT_HIP);
590  m_linesToPlot[10] = make_pair(LEFT_HIP, LEFT_KNEE);
591  m_linesToPlot[11] = make_pair(LEFT_KNEE, LEFT_FOOT);
592  m_linesToPlot[12] = make_pair(RIGHT_HIP, RIGHT_KNEE);
593  m_linesToPlot[13] = make_pair(RIGHT_KNEE, RIGHT_FOOT);
594  }
595 #else
597  "MRPT has been compiled with 'BUILD_OPENNI2'=OFF OR "
598  "'MRPT_HAS_NITE2'=OFF, so this class cannot be used.");
599 #endif
600 }
601 
602 /*-------------------------------------------------------------
603  loadConfig_sensorSpecific
604 -------------------------------------------------------------*/
606  const mrpt::config::CConfigFileBase& configSource,
607  const std::string& iniSection)
608 {
610  configSource.read_float(iniSection, "pose_x", 0, false),
611  configSource.read_float(iniSection, "pose_y", 0, false),
612  configSource.read_float(iniSection, "pose_z", 0, false),
613  DEG2RAD(configSource.read_float(iniSection, "pose_yaw", 0, false)),
614  DEG2RAD(configSource.read_float(iniSection, "pose_pitch", 0, false)),
615  DEG2RAD(configSource.read_float(iniSection, "pose_roll", 0, false)));
616 
617  m_showPreview =
618  configSource.read_bool(iniSection, "showPreview", m_showPreview, false);
619 
620  // dump parameters to console
621  cout << "---------------------------" << endl;
622  cout << "Skeleton Tracker parameters: " << endl;
623  cout << "---------------------------" << endl;
624  cout << m_sensorPose << endl;
625  cout << m_showPreview << endl;
626  cout << "---------------------------" << endl << endl;
627 }
std::string to_string(T v)
Just like std::to_string(), but with an overloaded version for std::string arguments.
Definition: format.h:36
void appendObservation(const mrpt::serialization::CSerializable::Ptr &obj)
Like appendObservations() but for just one observation.
void initialize() override
Connects to the PrimeSense camera and prepares it to get skeleton data.
app initialize(argc, argv)
void * m_skeletons_ptr
Opaque pointers to specific NITE data.
#define M_2PI
Definition: common.h:58
A set of object, which are referenced to the coordinates framework established in this object...
Definition: CSetOfObjects.h:26
#define NUM_JOINTS
#define THROW_EXCEPTION(msg)
Definition: exceptions.h:67
mrpt::system::TTimeStamp m_timeStartTT
string jointNames[]
std::string m_sensorLabel
See CGenericSensor.
unsigned int m_toutCounter
Timeout counter (for internal use only)
mrpt::system::TTimeStamp now()
A shortcut for system::getCurrentTime.
Definition: datetime.h:86
Contains classes for various device interfaces.
float read_float(const std::string &section, const std::string &name, float defaultValue, bool failIfNotFound=false) const
STL namespace.
static CDisplayWindow3D::Ptr Create(const std::string &windowCaption, unsigned int initialWindowWidth=400, unsigned int initialWindowHeight=300)
Class factory returning a smart pointer.
int m_nUsers
Number of detected users.
#define skl_states
mrpt::poses::CPose3D m_sensorPose
Sensor pose.
void processPreview(const mrpt::obs::CObservationSkeleton::Ptr &obs)
Displays real-time info for the captured skeleton.
#define ASSERT_(f)
Defines an assertion mechanism.
Definition: exceptions.h:120
mrpt::Clock::time_point TTimeStamp
A system independent time type, it holds the the number of 100-nanosecond intervals since January 1...
Definition: datetime.h:40
~CSkeletonTracker() override
Destructor.
This class allows loading and storing values and vectors of different types from a configuration text...
A class for grabbing mrpt::obs::CObservationSkeleton from a PrimeSense camera.
constexpr double DEG2RAD(const double x)
Degrees to radians.
void loadConfig_sensorSpecific(const mrpt::config::CConfigFileBase &configSource, const std::string &iniSection) override
See the class documentation at the top for expected parameters.
This namespace contains representation of robot actions and observations.
std::vector< std::pair< JOINT, JOINT > > m_linesToPlot
Lines between joints.
#define NUM_LINES
A class used to store a 3D point.
Definition: CPoint3D.h:31
#define IMPLEMENTS_GENERIC_SENSOR(class_name, NameSpace)
This must be inserted in all CGenericSensor classes implementation files:
#define MAX_USERS
Classes for 2D/3D geometry representation, both of single values and probability density distribution...
bool m_showPreview
Preview window management.
bool read_bool(const std::string &section, const std::string &name, bool defaultValue, bool failIfNotFound=false) const
A solid or wire-frame sphere.
Definition: CSphere.h:28
void setFromValues(const double x0, const double y0, const double z0, const double yaw=0, const double pitch=0, const double roll=0)
Set the pose from a 3D position (meters) and yaw/pitch/roll angles (radians) - This method recomputes...
Definition: CPose3D.cpp:265
Lightweight 3D pose (three spatial coordinates, plus three angular coordinates).
Definition: TPose3D.h:24
The namespace for 3D scene representation and rendering.
Definition: CGlCanvasBase.h:13
#define user_tracker
A generic joint for the skeleton observation.
A set of independent lines (or segments), one line with its own start and end positions (X...
Definition: CSetOfLines.h:32
uint32_t m_timeStartUI
Timestamp management.
mrpt::gui::CDisplayWindow3D::Ptr m_win
void doProcess() override
This method will be invoked at a minimum rate of "process_rate" (Hz)
#define FILL_JOINT_DATA(_J1, _J2)
std::vector< double > m_joint_theta
Joint angles when no skeleton has been detected.



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: c7a3bec24 Sun Mar 29 18:33:13 2020 +0200 at dom mar 29 18:50:38 CEST 2020