vrpn  07.33
Virtual Reality Peripheral Network
vrpn_Poser_Analog.h
Go to the documentation of this file.
1 #ifndef vrpn_POSER_ANALOG_H
2 #define vrpn_POSER_ANALOG_H
3 #include <stdio.h> // for NULL
4 
5 #include "vrpn_Configure.h" // for VRPN_API, VRPN_CALLBACK
6 #include "vrpn_Poser.h" // for vrpn_Poser
7 #include "vrpn_Tracker.h" // for vrpn_Tracker
8 #include "vrpn_Types.h" // for vrpn_float64
9 
12 struct vrpn_HANDLERPARAM;
13 
14 // This code is for a Poser server that uses a vrpn_Analog_Output to drive a
15 // device.
16 // It is basically the inverse of a vrpn_Tracker_AnalogFly.
17 // We are assuming that one Analog device will be used to drive all axes. This
18 // could be
19 // Changed by storing an Analog device per axis.
20 //
21 // This class can also act as a vrpn_Tracker so that it can report back the new
22 // positions
23 // and velocities to the client when the requests are within the bounds. This
24 // is not
25 // what you want it to do if you've got an independent tracker watching your
26 // output,
27 // and in any case is open-loop, so use with caution.
28 
29 // Class for holding data used in transforming pose data to analog values for
30 // each axis
32 public:
33  vrpn_PA_axis(char *name = NULL, int c = -1, double offset = 0.0,
34  double s = 1.0)
35  : ana_name(name)
36  , channel(c)
37  , offset(offset)
38  , scale(s)
39  {
40  }
41 
42  char *ana_name; // Name of the Analog Output device to drive with this axis
43  int channel; // Which channel to use from the Analog device. Default value
44  // of -1 means
45  // no motion for this axis
46  double offset; // Offset to apply to pose values for this channel to reach 0
47  double
48  scale; // Scale applied to pose values to get the correct analog value
49 };
50 
51 // Class for passing in config data. Usually read from the vrpn.cfg file in the
52 // server code.
54 public:
56 
57  // Translation for the three axes
58  vrpn_PA_axis x, y, z;
59 
60  // Rotation for the three axes
61  vrpn_PA_axis rx, ry, rz;
62 
63  // Workspace max and min info
64  vrpn_float64 pos_min[3], pos_max[3], pos_rot_min[3], pos_rot_max[3],
65  vel_min[3], vel_max[3], vel_rot_min[3], vel_rot_max[3];
66 };
67 
68 class VRPN_API vrpn_Poser_Analog; // Forward reference
69 
71 public:
73  {
74  ana = NULL;
75  value = 0.0;
76  pa = NULL;
77  };
78 
82  double value;
83 };
84 
86 public:
87  vrpn_Poser_Analog(const char *name, vrpn_Connection *c,
88  vrpn_Poser_AnalogParam *p, bool act_as_tracker = false);
89 
90  virtual ~vrpn_Poser_Analog();
91 
92  virtual void mainloop();
93 
94 protected:
95  // Axes for translation and rotation
96  vrpn_PA_fullaxis x, y, z, rx, ry, rz;
97 
98  // Should we act like a tracker, and report back values?
100 
101  static int VRPN_CALLBACK
102  handle_change_message(void *userdata, vrpn_HANDLERPARAM p);
103  static int VRPN_CALLBACK
104  handle_vel_change_message(void *userdata, vrpn_HANDLERPARAM p);
105 
106  // Routine to update the analog values from the current pose
107  bool update_Analog_values();
108  bool setup_channel(vrpn_PA_fullaxis *full);
109 };
110 
111 #endif
vrpn_Tracker.h
vrpn_PA_axis::vrpn_PA_axis
vrpn_PA_axis(char *name=NULL, int c=-1, double offset=0.0, double s=1.0)
Definition: vrpn_Poser_Analog.h:33
vrpn_Tracker
Definition: vrpn_Tracker.h:49
vrpn_PA_axis
Definition: vrpn_Poser_Analog.h:31
vrpn_PA_axis::scale
double scale
Definition: vrpn_Poser_Analog.h:48
vrpn_Types.h
vrpn_PA_axis::offset
double offset
Definition: vrpn_Poser_Analog.h:46
vrpn_Poser_Analog
class VRPN_API vrpn_Poser_Analog
Definition: vrpn_Poser_Analog.h:68
vrpn_PA_fullaxis
Definition: vrpn_Poser_Analog.h:70
vrpn_PA_fullaxis::ana
vrpn_Analog_Output_Remote * ana
Definition: vrpn_Poser_Analog.h:80
vrpn_PA_fullaxis::vrpn_PA_fullaxis
vrpn_PA_fullaxis(void)
Definition: vrpn_Poser_Analog.h:72
vrpn_Poser_AnalogParam
Definition: vrpn_Poser_Analog.h:53
vrpn_HANDLERPARAM
This structure is what is passed to a vrpn_Connection message callback.
Definition: vrpn_Connection.h:44
vrpn_Poser
Definition: vrpn_Poser.h:18
vrpn_PA_fullaxis::value
double value
Definition: vrpn_Poser_Analog.h:82
vrpn_Poser_Analog::z
vrpn_PA_fullaxis z
Definition: vrpn_Poser_Analog.h:96
vrpn_BaseClass::mainloop
virtual void mainloop()=0
Called once through each main loop iteration to handle updates. Remote object mainloop() should call ...
vrpn_Connection
Generic connection class not specific to the transport mechanism.
Definition: vrpn_Connection.h:510
vrpn_Poser_AnalogParam::rz
vrpn_PA_axis rz
Definition: vrpn_Poser_Analog.h:61
VRPN_CALLBACK
#define VRPN_CALLBACK
Definition: vrpn_Configure.h:647
vrpn_PA_axis::ana_name
char * ana_name
Definition: vrpn_Poser_Analog.h:42
vrpn_PA_fullaxis::pa
vrpn_Poser_Analog * pa
Definition: vrpn_Poser_Analog.h:81
vrpn_Poser.h
vrpn_PA_fullaxis::axis
vrpn_PA_axis axis
Definition: vrpn_Poser_Analog.h:77
vrpn_Analog_Output_Remote
Definition: vrpn_Analog_Output.h:154
vrpn_Poser_AnalogParam::z
vrpn_PA_axis z
Definition: vrpn_Poser_Analog.h:58
vrpn_PA_axis::channel
int channel
Definition: vrpn_Poser_Analog.h:43
vrpn_Configure.h
vrpn_Poser_Analog::d_act_as_tracker
bool d_act_as_tracker
Definition: vrpn_Poser_Analog.h:99
VRPN_API
#define VRPN_API
Definition: vrpn_Configure.h:646
vrpn_Poser_Analog
Definition: vrpn_Poser_Analog.h:85