34 memset(
d_quat, 0, 4 *
sizeof(
float));
35 memset(
pos, 0, 3 *
sizeof(
float));
40 const vrpn_uint8 sensor0 = s0;
41 const vrpn_uint8 sensor1 = s1;
42 const vrpn_uint8 sensor2 = s2;
43 const vrpn_uint8 set_sensors_cmd[] = {0x0,
'S',
'A',sensor0,sensor1,sensor2,
'\n'};
45 send_data(
sizeof(set_sensors_cmd),set_sensors_cmd);
47 cout <<
"WintrackerIII Vrpn Server up and running..." << endl;
48 cout <<
"Sensors activation state : " << endl;
49 cout <<
"Sensor 0: " << sensor0 <<
" - " <<
"Sensor 1: " << sensor1 <<
" - " <<
"Sensor 2: " << sensor2 <<endl;
54 cout <<
"Hemisphere of operation : Upper(Z<0)" << endl;
55 const vrpn_uint8 set_hemi[] = {0x0,
'S',
'H',
'U',
'\n'};
59 cout <<
"Hemisphere of operation : Front(X>0)" << endl;
64 cout <<
"Range Extender : Activated" << endl;
65 const vrpn_uint8 set_extender_cmd[] = {0x0,
'S',
'L',
'\n'};
66 send_data(
sizeof(set_extender_cmd),set_extender_cmd);
69 cout <<
"Range Extender : Not Activated" << endl;
80 vrpn_uint8 recordType = vrpn_unbuffer_from_little_endian<vrpn_int8>(buff);
82 vrpn_uint8 recordNumber = vrpn_unbuffer_from_little_endian<vrpn_int8>(buff);
88 if(((
int)recordNumber)==48){
90 }
else if(((
int)recordNumber)==49){
92 }
else if(((
int)recordNumber)==50){
97 pos[0]=vrpn_unbuffer_from_little_endian<vrpn_int16>(buff)/10000.00;
98 pos[1]=vrpn_unbuffer_from_little_endian<vrpn_int16>(buff)/10000.00;
99 pos[2]=vrpn_unbuffer_from_little_endian<vrpn_int16>(buff)/10000.00;
102 vrpn_uint16 azimuth = vrpn_unbuffer_from_little_endian<vrpn_int16>(buff);
103 vrpn_uint16 elevation = vrpn_unbuffer_from_little_endian<vrpn_int16>(buff);
104 vrpn_uint16 roll = vrpn_unbuffer_from_little_endian<vrpn_int16>(buff);
107 d_quat[3]=vrpn_unbuffer_from_little_endian<vrpn_int16>(buff)/10000.00;
108 d_quat[0]=vrpn_unbuffer_from_little_endian<vrpn_int16>(buff)/10000.00;
109 d_quat[1]=vrpn_unbuffer_from_little_endian<vrpn_int16>(buff)/10000.00;
110 d_quat[2]=vrpn_unbuffer_from_little_endian<vrpn_int16>(buff)/10000.00;
120 fprintf(stderr,
"FAIL \n");
125 fprintf(stderr,
"FAIL : Cannot read input from Wintracker \n");
const vrpn_uint32 vrpn_CONNECTION_LOW_LATENCY
void server_mainloop(void)
Handles functions that all servers should provide in their mainloop() (ping/pong, for example) Should...
virtual void on_data_received(size_t bytes, vrpn_uint8 *buffer)
Derived class reimplements this callback.
Accepts any device with the given vendor and product IDs.
Generic connection class not specific to the transport mechanism.
virtual void mainloop()
Called once through each main loop iteration to handle updates. Remote object mainloop() should call ...
struct timeval _timestamp
vrpn_Connection * d_connection
Connection that this object talks to.
virtual int pack_message(vrpn_uint32 len, struct timeval time, vrpn_int32 type, vrpn_int32 sender, const char *buffer, vrpn_uint32 class_of_service)
Pack a message that will be sent the next time mainloop() is called. Turn off the RELIABLE flag if yo...
const unsigned PRODUCT_ID
virtual int encode_to(char *buf)
vrpn_Tracker_Wintracker(const char *name, vrpn_Connection *trackercon, const char s0, const char s1, const char s2, const char ext, const char hemisphere)
#define vrpn_gettimeofday
virtual void update()
Polls the device buffers and causes on_data_received callbacks if appropriate You NEED to call this f...
void send_data(size_t bytes, const vrpn_uint8 *buffer)
Call this to send data to the device.
vrpn_int32 d_sender_id
Sender ID registered with the connection.
virtual bool connected() const
Returns true iff the last device I/O succeeded.