RflySimSDK v3.05
RflySimSDK说明文档
载入中...
搜索中...
未找到
vrpn_YEI_3Space.h
1#ifndef VRPN_YEI_3SPACE_H
2#define VRPN_YEI_3SPACE_H
3
4#include "quat.h"
5#include "vrpn_Tracker.h"
6#include "vrpn_Analog.h"
7#include "vrpn_Button.h"
8
11class VRPN_API vrpn_YEI_3Space
12 : public vrpn_Tracker_Server
13 , public vrpn_Analog
14 , public vrpn_Button_Filter
15{
16public:
25 vrpn_YEI_3Space (const char * name,
27 double frames_per_second = 50,
28 const char *reset_commands[] = NULL);
29
32
34 virtual void mainloop ();
35
36protected:
41 void init(bool calibrate_gyros_on_setup
42 , bool tare_on_setup
43 , double red_LED_color
44 , double green_LED_color
45 , double blue_LED_color
46 , int LED_mode);
47
49 virtual void flush_input(void) = 0;
50
51 // A list of ASCII commands that are sent to the device after
52 // the other reset commands have been sent, each time the device
53 // is reset. This enables arbitrary configuration.
54 char **d_reset_commands; //< Commands to send on reset
55 int d_reset_command_count; //< How many reset commands
56
57 // Status and handlers for different states
58 int d_status; //< What are we currently up to?
59 virtual int reset(void); //< Set device back to starting config
60 virtual bool get_report(void) = 0; //< Try to read and handle a report from the device
61 virtual void handle_report(unsigned char *report); //< Parse and handle a complete streaming report
62
63 double d_frames_per_second; //< How many frames/second do we want?
64 int d_LED_mode; //< LED mode we read from the device.
65 vrpn_float32 d_LED_color[3]; //< LED color we read from the device.
66
69 virtual bool send_binary_command(const unsigned char *cmd, int len) = 0;
70
74 virtual bool send_ascii_command(const char *cmd) = 0;
75
79 virtual bool receive_LED_mode_response(struct timeval *timeout = NULL) = 0;
80
84 virtual bool receive_LED_values_response(struct timeval *timeout = NULL) = 0;
85
86 unsigned char d_buffer[128]; //< Buffer to read reports into.
87 unsigned d_expected_characters; //< How many characters we are expecting
88 unsigned d_characters_read; //< How many characters we've read so far
89
90 struct timeval timestamp; //< Time of the last report from the device
91
93 virtual void report_changes
94 (vrpn_uint32 class_of_service = vrpn_CONNECTION_LOW_LATENCY);
96 virtual void report
97 (vrpn_uint32 class_of_service = vrpn_CONNECTION_LOW_LATENCY);
98};
99
103 : public vrpn_YEI_3Space
104{
105public:
123 vrpn_YEI_3Space_Sensor (const char * name,
124 vrpn_Connection * c,
125 const char * port,
126 int baud = 115200,
127 bool calibrate_gyros_on_setup = false,
128 bool tare_on_setup = false,
129 double frames_per_second = 50,
130 double red_LED_color = 0,
131 double green_LED_color = 0,
132 double blue_LED_color = 0,
133 int LED_mode = 1,
134 const char *reset_commands[] = NULL);
135
138
139protected:
140 int d_serial_fd; //< Serial port to read from.
141
143 virtual void flush_input(void);
144
145 virtual bool get_report(void); //< Try to read and handle a report from the device
146
149 bool send_binary_command(const unsigned char *cmd, int len);
150
154 bool send_ascii_command(const char *cmd);
155
159 bool receive_LED_mode_response(struct timeval *timeout = NULL);
160
164 bool receive_LED_values_response(struct timeval *timeout = NULL);
165};
166
170 : public vrpn_YEI_3Space
171{
172public:
196 vrpn_Connection * c,
197 int logical_id,
198 const char * port,
199 int baud = 115200,
200 bool calibrate_gyros_on_setup = false,
201 bool tare_on_setup = false,
202 double frames_per_second = 50,
203 double red_LED_color = 0,
204 double green_LED_color = 0,
205 double blue_LED_color = 0,
206 int LED_mode = 1,
207 const char *reset_commands[] = NULL);
208
229 vrpn_Connection * c,
230 int logical_id,
231 int serial_file_descriptor,
232 bool calibrate_gyros_on_setup = false,
233 bool tare_on_setup = false,
234 double frames_per_second = 50,
235 double red_LED_color = 0,
236 double green_LED_color = 0,
237 double blue_LED_color = 0,
238 int LED_mode = 1,
239 const char *reset_commands[] = NULL);
240
243
246 int get_serial_file_descriptor(void) const { return d_serial_fd; }
247
248protected:
249 bool d_i_am_first; //< Records whether I'm the first sensor (so close the port)
250 int d_serial_fd; //< Serial port to read from.
251 vrpn_uint8 d_logical_id; //< Which logical ID are we assigned to on the dongle?
252
254 virtual bool configure_dongle(void);
255
257 virtual bool set_logical_id(vrpn_uint8 logical_id, vrpn_int32 serial_number);
258
260 virtual void flush_input(void);
261
264 virtual bool get_report(void);
265
269 bool send_binary_command_to_dongle(const unsigned char *cmd, int len);
270
273 bool send_binary_command(const unsigned char *cmd, int len);
274
278 bool send_ascii_command(const char *cmd);
279
283 bool receive_LED_mode_response(struct timeval *timeout = NULL);
284
288 bool receive_LED_values_response(struct timeval *timeout = NULL);
289};
290
291#endif
定义 vrpn_Analog.h:28
定义 vrpn_Button.h:66
Generic connection class not specific to the transport mechanism.
定义 vrpn_Connection.h:562
定义 vrpn_Tracker.h:273
Class to support reading data from a wireless YEI 3Space unit.
定义 vrpn_YEI_3Space.h:171
virtual bool set_logical_id(vrpn_uint8 logical_id, vrpn_int32 serial_number)
Insert our serial number into the specified slot.
int get_serial_file_descriptor(void) const
定义 vrpn_YEI_3Space.h:246
virtual void flush_input(void)
Flush any incoming characters in the communications channel.
virtual ~vrpn_YEI_3Space_Sensor_Wireless()
Destructor.
virtual bool get_report(void)
vrpn_YEI_3Space_Sensor_Wireless(const char *name, vrpn_Connection *c, int logical_id, const char *port, int baud=115200, bool calibrate_gyros_on_setup=false, bool tare_on_setup=false, double frames_per_second=50, double red_LED_color=0, double green_LED_color=0, double blue_LED_color=0, int LED_mode=1, const char *reset_commands[]=NULL)
Constructor for the first device, which will open the serial port and configure the dongle....
bool send_ascii_command(const char *cmd)
vrpn_YEI_3Space_Sensor_Wireless(const char *name, vrpn_Connection *c, int logical_id, int serial_file_descriptor, bool calibrate_gyros_on_setup=false, bool tare_on_setup=false, double frames_per_second=50, double red_LED_color=0, double green_LED_color=0, double blue_LED_color=0, int LED_mode=1, const char *reset_commands[]=NULL)
Constructor for a follow-on device, once a wireless unit has already been opened on a given dongle....
bool send_binary_command(const unsigned char *cmd, int len)
bool send_binary_command_to_dongle(const unsigned char *cmd, int len)
bool receive_LED_values_response(struct timeval *timeout=NULL)
bool receive_LED_mode_response(struct timeval *timeout=NULL)
virtual bool configure_dongle(void)
Configure the dongle (called if we are the first one)
Class to support reading data from a wired YEI 3Space unit.
定义 vrpn_YEI_3Space.h:104
virtual void flush_input(void)
Flush any incoming characters in the communications channel.
bool send_ascii_command(const char *cmd)
bool send_binary_command(const unsigned char *cmd, int len)
bool receive_LED_values_response(struct timeval *timeout=NULL)
virtual ~vrpn_YEI_3Space_Sensor()
Destructor.
bool receive_LED_mode_response(struct timeval *timeout=NULL)
vrpn_YEI_3Space_Sensor(const char *name, vrpn_Connection *c, const char *port, int baud=115200, bool calibrate_gyros_on_setup=false, bool tare_on_setup=false, double frames_per_second=50, double red_LED_color=0, double green_LED_color=0, double blue_LED_color=0, int LED_mode=1, const char *reset_commands[]=NULL)
Constructor.
Base class with routines for YEI 3Space units.
定义 vrpn_YEI_3Space.h:15
virtual bool receive_LED_mode_response(struct timeval *timeout=NULL)=0
virtual bool send_binary_command(const unsigned char *cmd, int len)=0
virtual bool receive_LED_values_response(struct timeval *timeout=NULL)=0
virtual ~vrpn_YEI_3Space()
Destructor.
virtual void mainloop()
Called once through each main loop iteration to handle updates.
virtual bool send_ascii_command(const char *cmd)=0
vrpn_YEI_3Space(const char *name, vrpn_Connection *c, double frames_per_second=50, const char *reset_commands[]=NULL)
Constructor.
virtual void flush_input(void)=0
Flush any incoming characters in the communications channel.
void init(bool calibrate_gyros_on_setup, bool tare_on_setup, double red_LED_color, double green_LED_color, double blue_LED_color, int LED_mode)
virtual void report(vrpn_uint32 class_of_service=vrpn_CONNECTION_LOW_LATENCY)
send report whether or not changed
virtual void report_changes(vrpn_uint32 class_of_service=vrpn_CONNECTION_LOW_LATENCY)
send report iff changed