MRPT  2.0.1
CSkeletonTracker.h
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 #pragma once
11 
12 #include <mrpt/comms/CSerialPort.h>
16 #include <mrpt/poses/CPose3D.h>
17 
18 namespace mrpt::hwdrivers
19 {
20 // clang-format off
21 /** A class for grabbing mrpt::obs::CObservationSkeleton from a PrimeSense
22  *camera.
23  * It connects to a PrimeSense camera and tries to detect users while
24  *recording the positions of their skeletons' joints along time.
25  *
26  * See also the application "rawlog-grabber" for a ready-to-use application to
27  *gather data from this sensor.
28  *
29  * \code
30  * PARAMETERS IN THE ".INI"-LIKE CONFIGURATION STRINGS:
31  * -------------------------------------------------------
32  * [supplied_section_name]
33  * driver = CSkeletonTracker
34  * sensorLabel = <label> ; Label of the sensor
35  * grab_decimation = 1 ; [int] Grab skeletons in 1 out of 'grab_decimation' frames.
36  * show_preview = 1 ; [bool] {0,1} Opens a display window to show the recorded skeleton.
37  * pose_x = 0 ; [double] Sensor 3D position relative to the robot (meters)
38  * pose_y = 0
39  * pose_z = 0
40  * pose_yaw = 0 ; [double] Angles in degrees
41  * pose_pitch = 0
42  * pose_roll = 0
43  *
44  * \endcode
45  * \ingroup mrpt_hwdrivers_grp
46  */ // clang-format on
48 {
49  enum JOINT
50  {
51  HEAD = 0,
67  };
68 
69 #define NUM_JOINTS 15 // number of joints
70 #define NUM_LINES 14 // number of lines joining joints
71 
73  protected:
74  /** Opaque pointers to specific NITE data */
75  void* /* nite::SkeletonState* */ m_skeletons_ptr{nullptr};
76  void* /* nite::userTracker* */ m_userTracker_ptr{nullptr};
77 
78  /** Timestamp management */
79  uint32_t m_timeStartUI{};
81 
82  /** Sensor pose */
84  /** Number of detected users */
85  int m_nUsers{0};
86 
87  /** Preview window management */
88  bool m_showPreview{false};
90  /** Lines between joints */
91  std::vector<std::pair<JOINT, JOINT>> m_linesToPlot;
92  /** Joint angles when no skeleton has been detected */
93  std::vector<double> m_joint_theta;
94 
95  /** Timeout counter (for internal use only) */
96  unsigned int m_toutCounter{0};
97 
98  /** See the class documentation at the top for expected parameters */
100  const mrpt::config::CConfigFileBase& configSource,
101  const std::string& iniSection) override;
102 
103  /** Displays real-time info for the captured skeleton */
105  void processPreviewNone();
106 
107  public:
108  /** Constructor
109  */
111 
112  /** Destructor
113  */
114  ~CSkeletonTracker() override;
115 
116  /** This method will be invoked at a minimum rate of "process_rate" (Hz)
117  * \exception This method must throw an exception with a descriptive
118  * message if some critical error is found.
119  */
120  void doProcess() override;
121 
122  /** Connects to the PrimeSense camera and prepares it to get skeleton data
123  */
124  void initialize() override;
125 
126  /** Set/unset preview */
127  inline void setPreview(const bool setPreview = true)
128  {
130  }
131 }; // end of class
132 
133 } // namespace mrpt::hwdrivers
A generic interface for a wide-variety of sensors designed to be used in the application RawLogGrabbe...
void initialize() override
Connects to the PrimeSense camera and prepares it to get skeleton data.
void * m_skeletons_ptr
Opaque pointers to specific NITE data.
mrpt::system::TTimeStamp m_timeStartTT
unsigned int m_toutCounter
Timeout counter (for internal use only)
Contains classes for various device interfaces.
int m_nUsers
Number of detected users.
mrpt::poses::CPose3D m_sensorPose
Sensor pose.
void processPreview(const mrpt::obs::CObservationSkeleton::Ptr &obs)
Displays real-time info for the captured skeleton.
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.
void loadConfig_sensorSpecific(const mrpt::config::CConfigFileBase &configSource, const std::string &iniSection) override
See the class documentation at the top for expected parameters.
std::vector< std::pair< JOINT, JOINT > > m_linesToPlot
Lines between joints.
#define DEFINE_GENERIC_SENSOR(class_name)
This declaration must be inserted in all CGenericSensor classes definition, within the class declarat...
bool m_showPreview
Preview window management.
void setPreview(const bool setPreview=true)
Set/unset preview.
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
Definition: CPose3D.h:85
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)
std::vector< double > m_joint_theta
Joint angles when no skeleton has been detected.



Page generated by Doxygen 1.8.14 for MRPT 2.0.1 Git: 0fef1a6d7 Fri Apr 3 23:00:21 2020 +0200 at vie abr 3 23:20:28 CEST 2020