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