DTrackSDK  v2.9.0
DTrackParser.hpp
1 /* DTrackSDK in C++: DTrackParser.hpp
2  *
3  * Functions to process DTrack UDP packets (ASCII protocol).
4  *
5  * Copyright (c) 2013-2023 Advanced Realtime Tracking GmbH & Co. KG
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions are met:
9  *
10  * 1. Redistributions of source code must retain the above copyright
11  * notice, this list of conditions and the following disclaimer.
12  * 2. Redistributions in binary form must reproduce the above copyright
13  * notice, this list of conditions and the following disclaimer in the
14  * documentation and/or other materials provided with the distribution.
15  * 3. Neither the name of copyright holder nor the names of its contributors
16  * may be used to endorse or promote products derived from this software
17  * without specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29  *
30  * Purpose:
31  * - DTrack network protocol according to:
32  * 'DTrack2 User Manual, Technical Appendix' or 'DTRACK3 Programmer's Guide'
33  */
34 
35 #ifndef _ART_DTRACKSDK_PARSER_HPP_
36 #define _ART_DTRACKSDK_PARSER_HPP_
37 
38 #include "DTrackDataTypes.hpp"
39 
40 #include <vector>
41 
42 using namespace DTrackSDK_Datatypes;
43 
48 {
49 protected:
50 
54  DTrackParser();
55 
59  virtual ~DTrackParser();
60 
64  void startFrame();
65 
69  void endFrame();
70 
79  bool parseLine( char **line );
80 
81 public:
82 
90  unsigned int getFrameCounter() const;
91 
99  double getTimeStamp() const;
100 
108  unsigned int getTimeStampSec() const;
109 
117  unsigned int getTimeStampUsec() const;
118 
126  unsigned int getLatencyUsec() const;
127 
135  int getNumBody() const;
136 
145  const DTrackBody* getBody( int id ) const;
146 
154  int getNumFlyStick() const;
155 
164  const DTrackFlyStick* getFlyStick( int id ) const;
165 
173  int getNumMeaTool() const;
174 
183  const DTrackMeaTool* getMeaTool( int id ) const;
184 
192  int getNumMeaRef() const;
193 
202  const DTrackMeaRef* getMeaRef( int id ) const;
203 
211  int getNumHand() const;
212 
221  const DTrackHand* getHand( int id ) const;
222 
230  int getNumHuman() const;
231 
240  const DTrackHuman* getHuman( int id ) const;
241 
249  int getNumInertial() const;
250 
259  const DTrackInertial* getInertial( int id ) const;
260 
268  int getNumMarker() const;
269 
278  const DTrackMarker* getMarker( int index ) const;
279 
287  bool isStatusAvailable() const;
288 
296  const DTrackStatus* getStatus() const;
297 
298 
299 private:
300 
309  bool parseLine_fr( char **line );
310 
319  bool parseLine_ts( char **line );
320 
329  bool parseLine_ts2( char **line );
330 
339  bool parseLine_6dcal( char **line );
340 
349  bool parseLine_6d( char **line );
350 
359  bool parseLine_6dcov( char **line );
360 
369  bool parseLine_6df( char **line );
370 
379  bool parseLine_6df2( char **line );
380 
389  bool parseLine_6dmt( char **line );
390 
399  bool parseLine_6dmt2( char **line );
400 
409  bool parseLine_6dmtr( char **line );
410 
419  bool parseLine_glcal( char **line );
420 
429  bool parseLine_gl( char **line );
430 
439  bool parseLine_6dj( char **line );
440 
449  bool parseLine_6di( char **line );
450 
459  bool parseLine_3d( char **line );
460 
469  bool parseLine_st( char** line );
470 
471 private:
472 
473  unsigned int act_framecounter;
474  double act_timestamp;
475  unsigned int act_timestamp_sec;
476  unsigned int act_timestamp_usec;
477  unsigned int act_latency_usec;
478 
479  int act_num_body;
480  std::vector< DTrackBody > act_body;
481  int act_num_flystick;
482  std::vector< DTrackFlyStick > act_flystick;
483  int act_num_meatool;
484  std::vector< DTrackMeaTool > act_meatool;
485  int act_num_mearef;
486  std::vector< DTrackMeaRef > act_mearef;
487  int act_num_hand;
488  std::vector< DTrackHand > act_hand;
489  int act_num_human;
490  std::vector< DTrackHuman > act_human;
491  int act_num_inertial;
492  std::vector< DTrackInertial > act_inertial;
493  int act_num_marker;
494  std::vector< DTrackMarker > act_marker;
495  bool act_is_status_available;
496  DTrackStatus act_status;
497 
498  int loc_num_bodycal;
499  int loc_num_handcal;
500  int loc_num_flystick1;
501  int loc_num_meatool1;
502 };
503 
504 
505 #endif // _ART_DTRACKSDK_PARSER_HPP_
506 
DTrack Parser class.
Single marker data (3DOF).
A.R.T. Flystick data (6DOF + buttons).
Hybrid (optical-inertial) body data (6DOF).
Measurement Tool data (6DOF + buttons).
A.R.T. FINGERTRACKING hand data (6DOF + fingers).
Measurement Tool reference data (6DOF).
Standard body data (6DOF).
ART-Human model (joints (6DOF) including optional Fingertracking).