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
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
23
24 public:
25
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
39
40 public:
41
43 x.name = y.name = z.name =
44 sx.name = sy.name = sz.name = reset_name = clutch_name = NULL;
45 }
46
49
52
54
55 char * reset_name;
57
59 // large distances
60
63};
64
65class VRPN_API vrpn_Tracker_AnalogFly; // Forward reference
66
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
106 public:
107 vrpn_Tracker_AnalogFly (const char * name, vrpn_Connection * trackercon,
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)?
122
126
131
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);
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);
148};
149
150#endif
Generic connection class not specific to the transport mechanism.
vrpn_Analog_Remote * ana
vrpn_Tracker_AnalogFly * af
vrpn_TAF_axis sx
Rotation in the positive direction about the three axes.
char * reset_name
Button device that is used to reset the matrix to the origin.
vrpn_TAF_axis x
Translation along each of these three axes.
char * clutch_name
Clutch device that is used to enable relative motion over.
This class will turn an analog device such as a joystick or a camera.
vrpn_Button_Remote * d_reset_button
static int VRPN_CALLBACK handle_newConnection(void *, vrpn_HANDLERPARAM)
void update_matrix_based_on_values(double time_interval)
int setup_channel(vrpn_TAF_fullaxis *full)
vrpn_Button_Remote * d_clutch_button
static void VRPN_CALLBACK handle_analog_update(void *userdata, const vrpn_ANALOGCB info)
int teardown_channel(vrpn_TAF_fullaxis *full)
bool shouldReport(double elapsedInterval) const
vrpn_Tracker_AnalogFly(const char *name, vrpn_Connection *trackercon, vrpn_Tracker_AnalogFlyParam *params, float update_rate, bool absolute=vrpn_FALSE, bool reportChanges=VRPN_FALSE, bool worldFrame=VRPN_FALSE)
static void VRPN_CALLBACK handle_reset_press(void *userdata, const vrpn_BUTTONCB info)
static void VRPN_CALLBACK handle_clutch_press(void *userdata, const vrpn_BUTTONCB info)
virtual void mainloop()
Called once through each main loop iteration to handle updates. Remote object mainloop() should call ...
virtual void reset(void)
Reset the current matrix to zero and store it into the tracker position/quaternion location.
vrpn_Tracker(const char *name, vrpn_Connection *c=NULL, const char *tracker_cfg_file_name=NULL)
This structure is what is passed to a vrpn_Connection message callback.
#define VRPN_API
#define VRPN_CALLBACK
class VRPN_API vrpn_Tracker_AnalogFly
class VRPN_API vrpn_Connection