vrpn
07.33
Virtual Reality Peripheral Network
|
Go to the documentation of this file.
20 static const double TIMEOUT_INTERVAL = 10e+6;
22 static const double REV_PER_TICK_WHEEL = 1.0/15;
23 static const double REV_PER_TICK_BALL = 1.0/164;
25 static const unsigned char reset_char = 0x81;
28 #define STATUS_RESETTING (-1) // Resetting the box
29 #define STATUS_SYNCING (0) // Looking for the first character of report
30 #define STATUS_READING (1) // Looking for the rest of the report
48 const char * port,
int baud) :
93 struct timeval timeout;
94 unsigned char inbuf[1];
111 perror(
"vrpn_GlobalHapticsOrb::reset(): Error reading from Orb\n");
118 if (inbuf[0] != 0xfc) {
120 sprintf(message,
"vrpn_GlobalHapticsOrb::reset(): Bad response from Orb (%02X)", inbuf[0]);
172 case 0x89:
buttons[0] = 1;
break;
case 0xb9:
buttons[0] = 0;
break;
173 case 0x88:
buttons[1] = 1;
break;
case 0xb8:
buttons[1] = 0;
break;
174 case 0x90:
buttons[2] = 1;
break;
case 0xc0:
buttons[2] = 0;
break;
175 case 0x8e:
buttons[3] = 1;
break;
case 0xbe:
buttons[3] = 0;
break;
176 case 0x8d:
buttons[4] = 1;
break;
case 0xbd:
buttons[4] = 0;
break;
177 case 0x8c:
buttons[5] = 1;
break;
case 0xbc:
buttons[5] = 0;
break;
178 case 0x8b:
buttons[6] = 1;
break;
case 0xbb:
buttons[6] = 0;
break;
179 case 0x8a:
buttons[7] = 1;
break;
case 0xba:
buttons[7] = 0;
break;
180 case 0x9b:
buttons[8] = 1;
break;
case 0xcb:
buttons[8] = 0;
break;
181 case 0x9a:
buttons[9] = 1;
break;
case 0xca:
buttons[9] = 0;
break;
182 case 0x99:
buttons[10] = 1;
break;
case 0xc9:
buttons[10] = 0;
break;
183 case 0x98:
buttons[11] = 1;
break;
case 0xc8:
buttons[11] = 0;
break;
184 case 0x9f:
buttons[12] = 1;
break;
case 0xcf:
buttons[12] = 0;
break;
185 case 0x9e:
buttons[13] = 1;
break;
case 0xce:
buttons[13] = 0;
break;
186 case 0x9d:
buttons[14] = 1;
break;
case 0xcd:
buttons[14] = 0;
break;
187 case 0x9c:
buttons[15] = 1;
break;
case 0xcc:
buttons[15] = 0;
break;
188 case 0x81:
buttons[16] = 1;
break;
case 0xb1:
buttons[16] = 0;
break;
189 case 0x80:
buttons[17] = 1;
break;
case 0xb0:
buttons[17] = 0;
break;
190 case 0x8f:
buttons[18] = 1;
break;
case 0xbf:
buttons[18] = 0;
break;
191 case 0x86:
buttons[19] = 1;
break;
case 0xb6:
buttons[19] = 0;
break;
192 case 0x85:
buttons[20] = 1;
break;
case 0xb5:
buttons[20] = 0;
break;
193 case 0x84:
buttons[21] = 1;
break;
case 0xb4:
buttons[21] = 0;
break;
194 case 0x83:
buttons[22] = 1;
break;
case 0xb3:
buttons[22] = 0;
break;
195 case 0x82:
buttons[23] = 1;
break;
case 0xb2:
buttons[23] = 0;
break;
196 case 0xa0:
buttons[24] = 1;
break;
case 0xd0:
buttons[24] = 0;
break;
197 case 0x87:
buttons[25] = 1;
break;
case 0xb7:
buttons[25] = 0;
break;
200 case 0xa1:
buttons[26] = 1;
break;
case 0xd1:
buttons[26] = 0;
break;
201 case 0xa2:
buttons[27] = 1;
break;
case 0xd2:
buttons[27] = 0;
break;
204 case 0x92:
buttons[28] = 1;
break;
case 0xc2:
buttons[28] = 0;
break;
205 case 0x91:
buttons[29] = 1;
break;
case 0xc1:
buttons[29] = 0;
break;
211 dials[0] -= REV_PER_TICK_WHEEL;
212 channel[0] -= REV_PER_TICK_WHEEL;
216 dials[0] += REV_PER_TICK_WHEEL;
217 channel[0] += REV_PER_TICK_WHEEL;
227 dials[1] += REV_PER_TICK_BALL;
228 channel[1] += REV_PER_TICK_BALL;
232 dials[1] -= REV_PER_TICK_BALL;
233 channel[1] -= REV_PER_TICK_BALL;
237 dials[2] += REV_PER_TICK_BALL;
238 channel[2] += REV_PER_TICK_BALL;
242 dials[2] -= REV_PER_TICK_BALL;
243 channel[2] -= REV_PER_TICK_BALL;
304 struct timeval last_poll_sent = {0,0};
326 struct timeval current_time;
334 last_poll_sent = current_time;
int register_autodeleted_handler(vrpn_int32 type, vrpn_MESSAGEHANDLER handler, void *userdata, vrpn_int32 sender=vrpn_ANY_SENDER)
Registers a handler with the connection, and remembers to delete at destruction.
virtual void report(void)
unsigned long vrpn_TimevalDuration(struct timeval endT, struct timeval startT)
Return number of microseconds between startT and endT.
vrpn_float64 channel[vrpn_CHANNEL_MAX]
vrpn_GlobalHapticsOrb(const char *name, vrpn_Connection *c, const char *port, int baud)
virtual void report(vrpn_uint32 class_of_service=vrpn_CONNECTION_LOW_LATENCY, const struct timeval time=vrpn_ANALOG_NOW)
Send a report whether something has changed or not (for servers) Optionally, tell what time to stamp ...
static int VRPN_CALLBACK handle_firstConnection(void *userdata, vrpn_HANDLERPARAM)
Clear all of the values when we get our first client connection request.
const char * vrpn_got_first_connection
These are the strings that define the system-generated message types that tell when connections are r...
virtual void clear_values(void)
vrpn_Serial: Pulls all the serial port routines into one file to make porting to new operating system...
unsigned char d_buffer[512]
vrpn_Connection * d_connection
Connection that this object talks to.
virtual vrpn_int32 register_message_type(const char *name)
int vrpn_flush_input_buffer(int comm)
Throw out any characters within the input buffer.
struct timeval d_timestamp
This structure is what is passed to a vrpn_Connection message callback.
virtual int get_report(void)
unsigned d_expected_chars
vrpn_float64 dials[vrpn_DIAL_MAX]
virtual void report_changes(void)
Generic connection class not specific to the transport mechanism.
#define vrpn_gettimeofday
int vrpn_read_available_characters(int comm, unsigned char *buffer, size_t bytes)
vrpn_float64 last[vrpn_CHANNEL_MAX]
int vrpn_write_characters(int comm, const unsigned char *buffer, size_t bytes)
Write the buffer to the serial port.
int send_text_message(const char *msg, struct timeval timestamp, vrpn_TEXT_SEVERITY type=vrpn_TEXT_NORMAL, vrpn_uint32 level=0)
Sends a NULL-terminated text message from the device d_sender_id.
virtual void report_changes(vrpn_uint32 class_of_service=vrpn_CONNECTION_LOW_LATENCY, const struct timeval time=vrpn_ANALOG_NOW)
Send a report only if something has changed (for servers) Optionally, tell what time to stamp the val...
virtual void mainloop()
Called once through each main loop iteration to handle updates. Remote object mainloop() should call ...
void server_mainloop(void)
Handles functions that all servers should provide in their mainloop() (ping/pong, for example) Should...