RflySimSDK
v3.05
RflySimSDK说明文档
载入中...
搜索中...
未找到
simulink
vrpn
vrpn_Tracker_DTrack.h
1
// vrpn_Tracker_DTrack.h
2
//
3
// Advanced Realtime Tracking (https://www.ar-tracking.com) DTrack/DTrack2/DTRACK3 client
4
//
5
// developed by David Nahon for Virtools VR Pack (http://www.virtools.com)
6
// (07/20/2004) improved by Advanced Realtime Tracking GmbH
7
// (07/02/2007, 06/29/2009) upgraded by Advanced Realtime Tracking GmbH to support new devices
8
// (08/25/2010) a correction added by Advanced Realtime Tracking GmbH
9
// (12/01/2010) support of 3dof objects added by Advanced Realtime Tracking GmbH
10
// (2024-01-25) support of extended timestamp, multicast UDP and stateful firewall added
11
// by Advanced Realtime Tracking GmbH & Co. KG
12
13
#ifndef VRPN_TRACKER_DTRACK_H
14
#define VRPN_TRACKER_DTRACK_H
15
16
#include "vrpn_Configure.h"
// for VRPN_API
17
#include "vrpn_Shared.h"
// for timeval
18
19
class
VRPN_API
vrpn_Connection
;
20
// There is a problem with linking on SGI related to the use of standard
21
// libraries.
22
#ifndef sgi
23
24
#include <stdio.h>
// for NULL
25
26
#include "vrpn_Analog.h"
// for vrpn_Analog
27
#include "vrpn_Button.h"
// for vrpn_Button_Filter
28
#include "vrpn_Tracker.h"
// for vrpn_Tracker
29
30
31
// --------------------------------------------------------------------------
32
// Data types:
33
34
// Standard marker data (3DOF):
35
36
typedef
struct
{
37
int
id;
// id number (starting with 0)
38
float
loc[3];
// location (in mm)
39
}
vrpn_dtrack_marker_type
;
40
41
// Standard body data (6DOF):
42
// - currently not tracked bodies are getting a quality of -1
43
44
typedef
struct
{
45
int
id;
// id number (starting with 0)
46
float
quality;
// quality (0 <= qu <= 1, no tracking if -1)
47
48
float
loc[3];
// location (in mm)
49
float
rot[9];
// rotation matrix (column-wise)
50
}
vrpn_dtrack_body_type
;
51
52
// A.R.T. Flystick data (6DOF + buttons):
53
// - currently not tracked bodies are getting a quality of -1
54
// - note the maximum number of buttons and joystick values
55
56
#define vrpn_DTRACK_FLYSTICK_MAX_BUTTON 16
// maximum number of buttons
57
#define vrpn_DTRACK_FLYSTICK_MAX_JOYSTICK 8
// maximum number of joystick values
58
59
typedef
struct
{
60
int
id;
// id number (starting with 0)
61
float
quality;
// quality (0 <= qu <= 1, no tracking if -1)
62
63
int
num_button;
// number of buttons
64
int
button[vrpn_DTRACK_FLYSTICK_MAX_BUTTON];
// button state (1 pressed, 0 not pressed)
65
// (0 front, 1..n-1 right to left)
66
int
num_joystick;
// number of joystick values
67
float
joystick[vrpn_DTRACK_FLYSTICK_MAX_JOYSTICK];
// joystick value (-1 <= joystick <= 1)
68
// (0 horizontal, 1 vertical)
69
70
float
loc[3];
// location (in mm)
71
float
rot[9];
// rotation matrix (column-wise)
72
}
vrpn_dtrack_flystick_type
;
73
74
75
// --------------------------------------------------------------------------
76
// VRPN class:
77
78
class
VRPN_API
vrpn_Tracker_DTrack
:
public
vrpn_Tracker
,
public
vrpn_Button_Filter
,
public
vrpn_Analog
79
{
80
81
public
:
82
83
// Constructor:
84
// name (i): device name
85
// c (i): vrpn_Connection
86
// dtrackHost (i): (optional) DTRACK hostname/IP address or multicast IP address or NULL (if not given)
87
// dtrackPort (i): DTRACK UDP port
88
// doFirewall (i): enable UDP traffic through stateful firewall
89
// timeToReachJoy (i): time needed to reach the maximum value of the joystick
90
// fixNbody, fixNflystick (i): fixed numbers of DTrack bodies and Flysticks (-1 if not wanted)
91
// fixId (i): renumbering of targets; must have exact (fixNbody + fixNflystick) elements (NULL if not wanted)
92
// act3DOFout (i): activate 3dof marker output if present
93
// actTracing (i): activate trace output
94
95
vrpn_Tracker_DTrack
(
const
char
*name,
vrpn_Connection
*c,
96
const
char
* dtrackHost,
int
dtrackPort,
bool
doFirewall,
97
float
timeToReachJoy = 0.f,
98
int
fixNbody = -1,
int
fixNflystick = -1,
int
* fixId = NULL,
99
bool
act3DOFout =
false
,
bool
actTracing =
false
);
100
101
~vrpn_Tracker_DTrack
();
102
106
107
virtual
void
mainloop
();
108
109
110
private
:
111
112
// general:
113
114
struct
timeval tim_first;
// timestamp of first frame
115
struct
timeval tim_last;
// timestamp of current frame
116
117
bool
tracing;
// activate debug output
118
unsigned
int
tracing_frames;
// frame counter for debug output
119
120
// DTrack data:
121
122
bool
use_fix_numbering;
// use fixed numbers of standard bodies and Flysticks
123
124
int
fix_nbody;
// fixed number of standard bodies
125
int
fix_nflystick;
// fixed number of Flysticks
126
127
vrpn_vector<int>
fix_idbody;
// fixed vrpn standard body IDs
128
vrpn_vector<int>
fix_idflystick;
// fixed vrpn Flystick IDs
129
130
bool
warning_nbodycal;
// already warned cause of missing '6dcal' data
131
132
// preparing data for VRPN:
133
// these functions convert DTrack data to vrpn data
134
135
vrpn_vector<bool>
joy_simulate;
// simulate time varying floating values
136
vrpn_vector<float>
joy_last;
// current value of 'joystick' channel (hor, ver)
137
float
joy_incPerSec;
// increase of 'joystick' channel (in 1/sec)
138
139
int
dtrack2vrpn_marker(
int
id
,
const
char
* str_dtrack,
int
id_dtrack,
140
const
float
* loc,
struct
timeval timestamp);
141
int
dtrack2vrpn_body(
int
id
,
const
char
* str_dtrack,
int
id_dtrack,
142
const
float
* loc,
const
float
* rot,
struct
timeval timestamp);
143
int
dtrack2vrpn_flystickbuttons(
int
id
,
int
id_dtrack,
144
int
num_but,
const
int
* but,
struct
timeval timestamp);
145
int
dtrack2vrpn_flystickanalogs(
int
id
,
int
id_dtrack,
146
int
num_ana,
const
float
* ana,
float
dt,
struct
timeval timestamp);
147
148
// communicating with DTrack:
149
// these functions receive and parse data packets from DTrack
150
151
vrpn_SOCKET d_udpsock;
// socket number for UDP
152
unsigned
int
d_multicastIp;
// multicast IP to listen (optional)
153
int
d_udptimeout_us;
// timeout for receiving UDP data
154
155
int
d_udpbufsize;
// size of UDP buffer
156
char
* d_udpbuf;
// UDP buffer
157
158
unsigned
int
act_framecounter;
// frame counter
159
double
act_timestamp;
// timestamp since midnight (-1, if information not available)
160
unsigned
int
act_timestamp_sec;
// timestamp since Unix epoch, seconds (0, if not available)
161
unsigned
int
act_timestamp_usec;
// timestamp since Unix epoch, microseconds
162
unsigned
int
act_latency_usec;
// latency of current frame (0, if not available)
163
164
bool
output_3dof_marker;
// 3dof marker output if available
165
int
act_num_marker;
// number of 3dof marker (due to '3d' line)
166
vrpn_vector<vrpn_dtrack_marker_type>
act_marker;
// array containing 3dof marker data
167
168
int
act_num_body;
// number of calibrated standard bodies (due to '6d' line)
169
vrpn_vector<vrpn_dtrack_body_type>
act_body;
// array containing standard body data
170
bool
act_has_bodycal_format;
// DTrack sent '6dcal' format
171
int
act_num_bodycal;
// number of calibrated standard bodies (due to '6dcal' line)
172
173
int
act_num_flystick;
// number of calibrated Flysticks
174
vrpn_vector<vrpn_dtrack_flystick_type>
act_flystick;
// array containing Flystick data
175
bool
act_has_old_flystick_format;
// DTrack uses old Flystick format
176
177
int
d_lasterror;
// last receive error
178
179
bool
dtrack_init(
unsigned
int
serverIp,
int
udpport,
bool
doFirewall );
180
bool
dtrack_exit();
181
182
bool
dtrack_receive();
183
};
184
185
#endif
186
187
#endif
188
vrpn_Analog
定义
vrpn_Analog.h:28
vrpn_Button_Filter
定义
vrpn_Button.h:66
vrpn_Connection
Generic connection class not specific to the transport mechanism.
定义
vrpn_Connection.h:562
vrpn_Tracker_DTrack
定义
vrpn_Tracker_DTrack.h:79
vrpn_Tracker_DTrack::mainloop
virtual void mainloop()
vrpn_Tracker
定义
vrpn_Tracker.h:49
vrpn_vector
定义
vrpn_Shared.h:552
vrpn_dtrack_body_type
定义
vrpn_Tracker_DTrack.h:44
vrpn_dtrack_flystick_type
定义
vrpn_Tracker_DTrack.h:59
vrpn_dtrack_marker_type
定义
vrpn_Tracker_DTrack.h:36
制作者
1.11.0