vrpn
07.35
Virtual Reality Peripheral Network
Loading...
Searching...
No Matches
vrpn_Tracker_AnalogFly.h
Go to the documentation of this file.
1
#ifndef INCLUDED_ANALOGFLY
2
#define INCLUDED_ANALOGFLY
3
4
#include <quat.h>
// for q_matrix_type
5
#include <stdio.h>
// for NULL
6
7
#include "
vrpn_Analog.h
"
// for vrpn_ANALOGCB, etc
8
#include "
vrpn_Button.h
"
// for vrpn_BUTTONCB, etc
9
#include "
vrpn_Configure.h
"
// for VRPN_API, VRPN_CALLBACK
10
#include "
vrpn_Shared.h
"
// for timeval
11
#include "
vrpn_Tracker.h
"
// for vrpn_Tracker
12
#include "
vrpn_Types.h
"
// for VRPN_FALSE, vrpn_FALSE
13
14
class
VRPN_API
vrpn_Connection
;
15
struct
vrpn_HANDLERPARAM
;
16
17
// This parameter is passed to the constructor for the AnalogFly; it describes
18
// the channel mapping and parameters of that mapping, as well as the button
19
// that will be used to reset the tracker when it is pushed. Any entry which
20
// has a NULL pointer for the name is disabled.
21
22
class
VRPN_API
vrpn_TAF_axis
{
23
24
public
:
25
26
vrpn_TAF_axis
(
void
)
27
{ name = NULL; channel = 0; offset = 0.0f; thresh = 0.0f;
28
scale = 1.0f; power = 1.0f; };
29
30
char
*
name
;
//< Name of the Analog device driving this axis
31
int
channel
;
//< Which channel to use from the Analog device
32
float
offset
;
//< Offset to apply to values from this channel to reach 0
33
float
thresh
;
//< Threshold to apply after offset within which values count as zero
34
float
scale
;
//< Scale applied to values after offset and threshold
35
float
power
;
//< Power to which values are taken after scaling
36
};
37
38
class
VRPN_API
vrpn_Tracker_AnalogFlyParam
{
39
40
public
:
41
42
vrpn_Tracker_AnalogFlyParam
(
void
) {
43
x.name = y.name = z.name =
44
sx.name = sy.name = sz.name = reset_name = clutch_name = NULL;
45
}
46
48
vrpn_TAF_axis
x
, y, z;
49
51
vrpn_TAF_axis
sx
, sy, sz;
52
54
55
char
*
reset_name
;
56
int
reset_which
;
57
59
// large distances
60
61
char
*
clutch_name
;
62
int
clutch_which
;
63
};
64
65
class
VRPN_API
vrpn_Tracker_AnalogFly
;
// Forward reference
66
67
class
VRPN_API
vrpn_TAF_fullaxis
{
68
public
:
69
vrpn_TAF_fullaxis
(
void
) { ana = NULL; value = 0.0; af = NULL; };
70
71
vrpn_TAF_axis
axis
;
72
vrpn_Analog_Remote
*
ana
;
73
vrpn_Tracker_AnalogFly
*
af
;
74
double
value
;
75
};
76
78
// tracker into a tracker by interpreting the joystick
79
// positions as either position or velocity inputs and "flying" the user
80
// around based on analog values.
81
// The "absolute" parameter tells whether the tracker integrates differential
82
// changes (the default, with FALSE) or takes the analog values as absolute
83
// positions or orientations.
84
// The mapping from analog channels to directions (or orientation changes) is
85
// described in the vrpn_Tracker_AnalogFlyParam parameter. For translations,
86
// values above threshold are multiplied by the scale and then taken to the
87
// power; the result is the number of meters (or meters per second) to move
88
// in that direction. For rotations, the result is taken as the number of
89
// revolutions (or revolutions per second) around the given axis.
90
// Note that the reset button has no effect on an absolute tracker.
91
// The time reported by absolute trackers is as of the last report they have
92
// had from their analog devices. The time reported by differential trackers
93
// is the local time that the report was generated. This is to allow a
94
// gen-locked camera tracker to have its time values passed forward through
95
// the AnalogFly class.
96
97
// If reportChanges is TRUE, updates are ONLY sent if there has been a
98
// change since the last update, in which case they are generated no faster
99
// than update_rate.
100
101
// If worldFrame is TRUE, then translations and rotations take place in the
102
// world frame, rather than the local frame. Useful for a simulated wand
103
// when doing desktop testing of immersive apps - easier to keep under control.
104
105
class
VRPN_API
vrpn_Tracker_AnalogFly
:
public
vrpn_Tracker
{
106
public
:
107
vrpn_Tracker_AnalogFly
(
const
char
* name,
vrpn_Connection
* trackercon,
108
vrpn_Tracker_AnalogFlyParam
* params,
109
float
update_rate,
bool
absolute = vrpn_FALSE,
110
bool
reportChanges = VRPN_FALSE,
bool
worldFrame = VRPN_FALSE);
111
112
virtual
~vrpn_Tracker_AnalogFly
(
void
);
113
114
virtual
void
mainloop ();
115
116
protected
:
117
double
d_update_interval
;
//< How long to wait between sends
118
struct
timeval d_prevtime;
//< Time of the previous report
119
bool
d_absolute
;
//< Report absolute (vs. differential)?
120
bool
d_reportChanges
;
121
bool
d_worldFrame
;
122
123
vrpn_TAF_fullaxis
d_x, d_y, d_z,
d_sx
, d_sy, d_sz;
124
vrpn_Button_Remote
*
d_reset_button
;
125
int
d_which_button
;
126
127
vrpn_Button_Remote
*
d_clutch_button
;
128
int
d_clutch_which
;
129
bool
d_clutch_engaged
;
130
bool
d_clutch_was_off
;
131
132
q_matrix_type d_initMatrix, d_currentMatrix,
d_clutchMatrix
;
133
134
void
update_matrix_based_on_values (
double
time_interval);
135
void
convert_matrix_to_tracker (
void
);
136
137
bool
shouldReport (
double
elapsedInterval)
const
;
138
139
int
setup_channel (
vrpn_TAF_fullaxis
* full);
140
int
teardown_channel (
vrpn_TAF_fullaxis
* full);
141
virtual
void
reset(
void
);
142
143
static
void
VRPN_CALLBACK
handle_analog_update (
void
* userdata,
144
const
vrpn_ANALOGCB
info);
145
static
void
VRPN_CALLBACK
handle_reset_press (
void
* userdata,
const
vrpn_BUTTONCB
info);
146
static
void
VRPN_CALLBACK
handle_clutch_press (
void
* userdata,
const
vrpn_BUTTONCB
info);
147
static
int
VRPN_CALLBACK
handle_newConnection(
void
*,
vrpn_HANDLERPARAM
);
148
};
149
150
#endif
vrpn_Analog_Remote
Definition
vrpn_Analog.h:181
vrpn_Button_Remote
Definition
vrpn_Button.h:251
vrpn_Connection
Generic connection class not specific to the transport mechanism.
Definition
vrpn_Connection.h:561
vrpn_TAF_axis
Definition
vrpn_Tracker_AnalogFly.h:22
vrpn_TAF_axis::scale
float scale
Definition
vrpn_Tracker_AnalogFly.h:34
vrpn_TAF_axis::thresh
float thresh
Definition
vrpn_Tracker_AnalogFly.h:33
vrpn_TAF_axis::name
char * name
Definition
vrpn_Tracker_AnalogFly.h:30
vrpn_TAF_axis::power
float power
Definition
vrpn_Tracker_AnalogFly.h:35
vrpn_TAF_axis::channel
int channel
Definition
vrpn_Tracker_AnalogFly.h:31
vrpn_TAF_axis::offset
float offset
Definition
vrpn_Tracker_AnalogFly.h:32
vrpn_TAF_axis::vrpn_TAF_axis
vrpn_TAF_axis(void)
Definition
vrpn_Tracker_AnalogFly.h:26
vrpn_TAF_fullaxis
Definition
vrpn_Tracker_AnalogFly.h:67
vrpn_TAF_fullaxis::value
double value
Definition
vrpn_Tracker_AnalogFly.h:74
vrpn_TAF_fullaxis::ana
vrpn_Analog_Remote * ana
Definition
vrpn_Tracker_AnalogFly.h:72
vrpn_TAF_fullaxis::axis
vrpn_TAF_axis axis
Definition
vrpn_Tracker_AnalogFly.h:71
vrpn_TAF_fullaxis::af
vrpn_Tracker_AnalogFly * af
Definition
vrpn_Tracker_AnalogFly.h:73
vrpn_TAF_fullaxis::vrpn_TAF_fullaxis
vrpn_TAF_fullaxis(void)
Definition
vrpn_Tracker_AnalogFly.h:69
vrpn_Tracker_AnalogFlyParam
Definition
vrpn_Tracker_AnalogFly.h:38
vrpn_Tracker_AnalogFlyParam::sx
vrpn_TAF_axis sx
Rotation in the positive direction about the three axes.
Definition
vrpn_Tracker_AnalogFly.h:51
vrpn_Tracker_AnalogFlyParam::reset_name
char * reset_name
Button device that is used to reset the matrix to the origin.
Definition
vrpn_Tracker_AnalogFly.h:55
vrpn_Tracker_AnalogFlyParam::reset_which
int reset_which
Definition
vrpn_Tracker_AnalogFly.h:56
vrpn_Tracker_AnalogFlyParam::x
vrpn_TAF_axis x
Translation along each of these three axes.
Definition
vrpn_Tracker_AnalogFly.h:48
vrpn_Tracker_AnalogFlyParam::clutch_which
int clutch_which
Definition
vrpn_Tracker_AnalogFly.h:62
vrpn_Tracker_AnalogFlyParam::vrpn_Tracker_AnalogFlyParam
vrpn_Tracker_AnalogFlyParam(void)
Definition
vrpn_Tracker_AnalogFly.h:42
vrpn_Tracker_AnalogFlyParam::clutch_name
char * clutch_name
Clutch device that is used to enable relative motion over.
Definition
vrpn_Tracker_AnalogFly.h:61
vrpn_Tracker_AnalogFly
This class will turn an analog device such as a joystick or a camera.
Definition
vrpn_Tracker_AnalogFly.h:105
vrpn_Tracker_AnalogFly::d_reset_button
vrpn_Button_Remote * d_reset_button
Definition
vrpn_Tracker_AnalogFly.h:124
vrpn_Tracker_AnalogFly::d_worldFrame
bool d_worldFrame
Definition
vrpn_Tracker_AnalogFly.h:121
vrpn_Tracker_AnalogFly::d_clutchMatrix
q_matrix_type d_clutchMatrix
Definition
vrpn_Tracker_AnalogFly.h:132
vrpn_Tracker_AnalogFly::d_absolute
bool d_absolute
Definition
vrpn_Tracker_AnalogFly.h:119
vrpn_Tracker_AnalogFly::d_sx
vrpn_TAF_fullaxis d_sx
Definition
vrpn_Tracker_AnalogFly.h:123
vrpn_Tracker_AnalogFly::d_clutch_button
vrpn_Button_Remote * d_clutch_button
Definition
vrpn_Tracker_AnalogFly.h:127
vrpn_Tracker_AnalogFly::d_reportChanges
bool d_reportChanges
Definition
vrpn_Tracker_AnalogFly.h:120
vrpn_Tracker_AnalogFly::d_which_button
int d_which_button
Definition
vrpn_Tracker_AnalogFly.h:125
vrpn_Tracker_AnalogFly::d_clutch_engaged
bool d_clutch_engaged
Definition
vrpn_Tracker_AnalogFly.h:129
vrpn_Tracker_AnalogFly::d_clutch_which
int d_clutch_which
Definition
vrpn_Tracker_AnalogFly.h:128
vrpn_Tracker_AnalogFly::d_clutch_was_off
bool d_clutch_was_off
Definition
vrpn_Tracker_AnalogFly.h:130
vrpn_Tracker_AnalogFly::d_update_interval
double d_update_interval
Definition
vrpn_Tracker_AnalogFly.h:117
vrpn_Tracker
Definition
vrpn_Tracker.h:49
vrpn_ANALOGCB
Definition
vrpn_Analog.h:168
vrpn_BUTTONCB
Definition
vrpn_Button.h:226
vrpn_HANDLERPARAM
This structure is what is passed to a vrpn_Connection message callback.
Definition
vrpn_Connection.h:41
vrpn_Analog.h
vrpn_Button.h
vrpn_Configure.h
VRPN_API
#define VRPN_API
Definition
vrpn_Configure.h:648
VRPN_CALLBACK
#define VRPN_CALLBACK
Definition
vrpn_Configure.h:649
vrpn_Shared.h
vrpn_Tracker.h
vrpn_Types.h
vrpn_Tracker_AnalogFly.h
Generated by
1.9.8