31 memset(
d_quat, 0, 4 *
sizeof(
float));
32 memset(
pos, 0, 3 *
sizeof(
float));
37 const vrpn_uint8 sensor0 = s0;
38 const vrpn_uint8 sensor1 = s1;
39 const vrpn_uint8 sensor2 = s2;
40 const vrpn_uint8 set_sensors_cmd[] = {0x0,
'S',
'A',sensor0,sensor1,sensor2,
'\n'};
42 send_data(
sizeof(set_sensors_cmd),set_sensors_cmd);
44 cout <<
"WintrackerIII Vrpn Server up and running..." << endl;
45 cout <<
"Sensors activation state : " << endl;
46 cout <<
"Sensor 0: " << sensor0 <<
" - " <<
"Sensor 1: " << sensor1 <<
" - " <<
"Sensor 2: " << sensor2 <<endl;
51 cout <<
"Hemisphere of operation : Upper(Z<0)" << endl;
52 const vrpn_uint8 set_hemi[] = {0x0,
'S',
'H',
'U',
'\n'};
56 cout <<
"Hemisphere of operation : Front(X>0)" << endl;
61 cout <<
"Range Extender : Activated" << endl;
62 const vrpn_uint8 set_extender_cmd[] = {0x0,
'S',
'L',
'\n'};
63 send_data(
sizeof(set_extender_cmd),set_extender_cmd);
66 cout <<
"Range Extender : Not Activated" << endl;
78 vrpn_uint8 recordType = vrpn_unbuffer_from_little_endian<vrpn_int8>(buff);
80 vrpn_uint8 recordNumber = vrpn_unbuffer_from_little_endian<vrpn_int8>(buff);
86 if(((
int)recordNumber)==48){
88 }
else if(((
int)recordNumber)==49){
90 }
else if(((
int)recordNumber)==50){
95 pos[0]=vrpn_unbuffer_from_little_endian<vrpn_int16>(buff)/10000.00;
96 pos[1]=vrpn_unbuffer_from_little_endian<vrpn_int16>(buff)/10000.00;
97 pos[2]=vrpn_unbuffer_from_little_endian<vrpn_int16>(buff)/10000.00;
100 vrpn_uint16 azimuth = vrpn_unbuffer_from_little_endian<vrpn_int16>(buff);
101 vrpn_uint16 elevation = vrpn_unbuffer_from_little_endian<vrpn_int16>(buff);
102 vrpn_uint16 roll = vrpn_unbuffer_from_little_endian<vrpn_int16>(buff);
105 d_quat[3]=vrpn_unbuffer_from_little_endian<vrpn_int16>(buff)/10000.00;
106 d_quat[0]=vrpn_unbuffer_from_little_endian<vrpn_int16>(buff)/10000.00;
107 d_quat[1]=vrpn_unbuffer_from_little_endian<vrpn_int16>(buff)/10000.00;
108 d_quat[2]=vrpn_unbuffer_from_little_endian<vrpn_int16>(buff)/10000.00;
118 fprintf(stderr,
"FAIL \n");
122 recordType = recordType + 1;
123 azimuth = azimuth + 1;
124 elevation = elevation + 1;
127 fprintf(stderr,
"FAIL : Cannot read input from Wintracker \n");
vrpn_Connection * d_connection
Connection that this object talks to.
vrpn_int32 d_sender_id
Sender ID registered with the connection.
void server_mainloop(void)
Handles functions that all servers should provide in their mainloop() (ping/pong, for example) Should...
Generic connection class not specific to the transport mechanism.
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...
virtual void update()
Polls the device buffers and causes on_data_received callbacks if appropriate You NEED to call this f...
virtual bool connected() const
Returns true iff the last device I/O succeeded.
void send_data(size_t bytes, const vrpn_uint8 *buffer)
Call this to send data to the device.
Accepts any device with the given vendor and product IDs.
virtual void on_data_received(size_t bytes, vrpn_uint8 *buffer)
Derived class reimplements this callback.
struct timeval _timestamp
virtual void mainloop()
Called once through each main loop iteration to handle updates. Remote object mainloop() should call ...
vrpn_Tracker_Wintracker(const char *name, vrpn_Connection *trackercon, const char s0, const char s1, const char s2, const char ext, const char hemisphere)
virtual int encode_to(char *buf)
const vrpn_uint32 vrpn_CONNECTION_LOW_LATENCY
#define vrpn_gettimeofday
const unsigned PRODUCT_ID