vrpn
07.33
Virtual Reality Peripheral Network
|
Go to the documentation of this file.
26 #if defined(VRPN_USE_LIBUSB_1_0)
30 #ifndef VRPN_CLIENT_ONLY
34 static const char *default_tracker_cfg_file_name =
"vrpn_Tracker.cfg";
38 #define vrpn_ser_tkr_MAX_TIME_INTERVAL \
39 (2000000) // max time between reports (usec)
45 const char *tracker_cfg_file_name)
48 , unit2sensor_quat(NULL)
85 #ifdef DESKTOP_PHANTOM_DEFAULTS
98 #ifdef DESKTOP_PHANTOM_DEFAULTS
109 if (tracker_cfg_file_name == NULL) {
110 tracker_cfg_file_name = default_tracker_cfg_file_name;
112 if ((config_file = fopen(tracker_cfg_file_name,
"r")) == NULL) {
118 if (tracker_cfg_file_name != default_tracker_cfg_file_name) {
119 fprintf(stderr,
"vrpn_Tracker: Can't find config file %s\n",
120 tracker_cfg_file_name);
126 "vrpn_Tracker: Found config file %s, but cannot read info for %s\n",
127 tracker_cfg_file_name, name);
131 fprintf(stderr,
"vrpn_Tracker: Read room and sensor info from %s\n",
132 tracker_cfg_file_name);
152 "vrpn_Tracker Request_Tracker_To_Room");
154 "vrpn_Tracker Request_Unit_To_Sensor");
158 "vrpn_Tracker Request_Tracker_Workspace");
195 if (newlist == NULL) {
199 if (newqlist == NULL) {
211 newlist[i][0] = newlist[i][1] = newlist[i][2] = 0.0;
212 newqlist[i][0] = 0.0;
213 newqlist[i][1] = 0.0;
214 newqlist[i][2] = 0.0;
215 newqlist[i][3] = 1.0;
237 vrpn_int32 which_sensor;
242 while (fgets(line,
sizeof(line), config_file) != NULL) {
244 if (strlen(line) >=
sizeof(line) - 1) {
245 fprintf(stderr,
"Line too long in config file: %s\n", line);
249 if ((!(strncmp(line, tracker_name, strlen(tracker_name)))) &&
250 (isspace(line[strlen(tracker_name)]))) {
252 if (fgets(line,
sizeof(line), config_file) == NULL)
break;
253 if (sscanf(line,
"%f%f%f", &f[0], &f[1], &f[2]) != 3)
break;
254 if (fgets(line,
sizeof(line), config_file) == NULL)
break;
255 if (sscanf(line,
"%f%f%f%f", &f[3], &f[4], &f[5], &f[6]) != 4)
257 if (fgets(line,
sizeof(line), config_file) == NULL)
break;
258 if (sscanf(line,
"%f%f%f%f%f%f", &f[7], &f[8], &f[9], &f[10],
259 &f[11], &f[12]) != 6)
262 for (i = 0; i < 3; i++) {
267 for (i = 0; i < 4; i++)
270 if (fgets(line,
sizeof(line), config_file) == NULL)
break;
271 if (sscanf(line,
"%d", &num_sens) != 1)
break;
273 fprintf(stderr,
"Out of memory\n");
276 for (i = 0; i < num_sens; i++) {
278 if (fgets(line,
sizeof(line), config_file) == NULL)
break;
279 if (sscanf(line,
"%d", &which_sensor) != 1)
break;
281 fprintf(stderr,
"Out of memory\n");
285 if (fgets(line,
sizeof(line), config_file) == NULL)
break;
286 if (sscanf(line,
"%f%f%f", &f[0], &f[1], &f[2]) != 3)
break;
287 if (fgets(line,
sizeof(line), config_file) == NULL)
break;
288 if (sscanf(line,
"%f%f%f%f", &f[3], &f[4], &f[5], &f[6]) != 4)
290 for (j = 0; j < 3; j++) {
293 for (j = 0; j < 4; j++) {
301 fprintf(stderr,
"Error reading or %s not found in config file\n",
308 printf(
"----------------------------------------------------\n");
310 printf(
"Timestamp :%ld:%ld\n",
timestamp.tv_sec,
313 printf(
"Pos :%lf, %lf, %lf\n",
pos[0],
pos[1],
pos[2]);
323 fprintf(stderr,
"vrpn_Tracker:can't register t2r handler\n");
328 fprintf(stderr,
"vrpn_Tracker:can't register u2s handler\n");
334 fprintf(stderr,
"vrpn_Tracker: "
335 "Can't register workspace handler\n");
349 for (i = 0; i < 3; i++)
351 for (i = 0; i < 4; i++)
361 for (i = 0; i < 3; i++)
363 for (i = 0; i < 4; i++)
369 struct timeval current_time;
377 me->
timestamp.tv_sec = current_time.tv_sec;
378 me->
timestamp.tv_usec = current_time.tv_usec;
388 fprintf(stderr,
"vrpn_Tracker: cannot write t2r message\n");
396 struct timeval current_time;
405 me->
timestamp.tv_sec = current_time.tv_sec;
406 me->
timestamp.tv_usec = current_time.tv_usec;
419 fprintf(stderr,
"vrpn_Tracker: cannot write u2s message\n");
428 struct timeval current_time;
436 me->
timestamp.tv_sec = current_time.tv_sec;
437 me->
timestamp.tv_usec = current_time.tv_usec;
446 fprintf(stderr,
"vrpn_Tracker: cannot write workspace message\n");
465 for (i = 0; i < 3; i++) {
470 for (i = 0; i < 4; i++) {
475 return 1000 - buflen;
499 for (i = 0; i < 3; i++) {
504 for (i = 0; i < 4; i++) {
509 return 1000 - buflen;
525 return 1000 - buflen;
555 return 1000 - buflen;
582 return 1000 - buflen;
609 return 1000 - buflen;
613 vrpn_int32 sensors, vrpn_float64 Hz)
625 struct timeval current_time;
639 timestamp.tv_usec = current_time.tv_usec;
652 "NULL tracker: can't write message: tossing\n");
661 "NULL tracker: can't write message: tossing\n");
670 "NULL tracker: can't write message: tossing\n");
684 "NULL tracker: can't write message: tossing\n");
693 "NULL tracker: can't write message: tossing\n");
702 "NULL tracker: can't write message: tossing\n");
730 const vrpn_float64 position[3],
731 const vrpn_float64 quaternion[4],
732 const vrpn_uint32 class_of_service)
754 memcpy(
pos, position,
sizeof(
pos));
760 "vrpn_Tracker_Server: can't write message: tossing\n");
768 const int sensor,
const struct timeval t,
const vrpn_float64 position[3],
769 const vrpn_float64 quaternion[4],
const vrpn_float64 interval,
770 const vrpn_uint32 class_of_service)
792 memcpy(
vel, position,
sizeof(
pos));
799 "vrpn_Tracker_Server: can't write message: tossing\n");
808 const int sensor,
const struct timeval t,
const vrpn_float64 position[3],
809 const vrpn_float64 quaternion[4],
const vrpn_float64 interval,
810 const vrpn_uint32 class_of_service)
832 memcpy(
acc, position,
sizeof(
pos));
837 msgbuf, class_of_service)) {
839 "vrpn_Tracker_Server: can't write message: tossing\n");
847 #ifndef VRPN_CLIENT_ONLY
849 const char *port,
long baud)
856 fprintf(stderr,
"vrpn_Tracker_Serial: NULL port name\n");
868 fprintf(stderr,
"vrpn_Tracker_Serial: Cannot Open serial port\n");
894 fprintf(stderr,
"Tracker: cannot write message: tossing\n");
898 fprintf(stderr,
"Tracker: No valid connection\n");
929 struct timeval current_time;
946 sprintf(errmsg,
"Tracker failed to read... current_time=%ld:%ld, "
947 "timestamp=%ld:%ld\n",
949 static_cast<long>(current_time.tv_usec),
timestamp.tv_sec,
962 "more than 4 attempts made)",
971 "vrpn_Tracker_Serial::mainloop(): Cannot Open serial port\n");
979 #if defined(VRPN_USE_LIBUSB_1_0)
982 vrpn_uint16 vendor, vrpn_uint16 product,
988 , _device_handle(NULL)
995 fprintf(stderr,
"vrpn_Tracker_USB: can't init LibUSB\n");
1004 fprintf(stderr,
"vrpn_Tracker_USB: can't find any Polhemus High Speed "
1005 "Liberty Latus devices\n");
1007 " (Did you remember to run as root?)\n");
1014 "vrpn_Tracker_USB: can't claim interface for this device\n");
1016 " (Did you remember to run as root?)\n");
1051 fprintf(stderr,
"Tracker: cannot write message: tossing\n");
1055 fprintf(stderr,
"Tracker: No valid connection\n");
1087 struct timeval current_time;
1104 sprintf(errmsg,
"Tracker failed to read... current_time=%ld:%ld, "
1105 "timestamp=%ld:%ld\n",
1106 current_time.tv_sec,
1107 static_cast<long>(current_time.tv_usec),
timestamp.tv_sec,
1121 "more than 4 attempts made)",
1130 fprintf(stderr,
"vrpn_Tracker_USB::mainloop(): can't find any "
1131 "Polhemus High Speed Liberty Latus devices\n");
1137 fprintf(stderr,
"vrpn_Tracker_USB::mainloop(): can't claim "
1138 "interface for this device\n");
1153 #endif // VRPN_CLIENT_ONLY
1157 , sensor_callbacks(NULL)
1158 , num_sensor_callbacks(0)
1162 fprintf(stderr,
"vrpn_Tracker_Remote: No connection\n");
1170 "vrpn_Tracker_Remote: can't register position handler\n");
1178 "vrpn_Tracker_Remote: can't register velocity handler\n");
1186 "vrpn_Tracker_Remote: can't register acceleration handler\n");
1195 "vrpn_Tracker_Remote: can't register tracker2room handler\n");
1204 "vrpn_Tracker_Remote: can't register unit2sensor handler\n");
1213 "vrpn_Tracker_Remote: can't register workspace handler\n");
1250 if (newlist == NULL) {
1273 char *msgbuf = NULL;
1275 struct timeval current_time;
1279 timestamp.tv_usec = current_time.tv_usec;
1285 fprintf(stderr,
"vrpn_Tracker_Remote: cannot request t2r xform\n");
1294 char *msgbuf = NULL;
1296 struct timeval current_time;
1300 timestamp.tv_usec = current_time.tv_usec;
1306 fprintf(stderr,
"vrpn_Tracker_Remote: cannot request u2s xform\n");
1315 char *msgbuf = NULL;
1317 struct timeval current_time;
1321 timestamp.tv_usec = current_time.tv_usec;
1327 fprintf(stderr,
"vrpn_Tracker_Remote: cannot request workspace\n");
1341 len =
sizeof(vrpn_float64);
1342 msgbuf =
new char[len];
1344 fprintf(stderr,
"vrpn_Tracker_Remote::set_update_rate: "
1345 "Out of memory!\n");
1349 vrpn_int32 buflen = len;
1360 fprintf(stderr,
"vrpn_Tracker_Remote::set_update_rate: "
1361 "Cannot send message.\n");
1370 struct timeval current_time;
1373 timestamp.tv_usec = current_time.tv_usec;
1380 "vrpn_Tracker_Remote: cannot write message: tossing\n");
1400 "vrpn_Tracker_Remote::register_change_handler: bad sensor index\n");
1406 "vrpn_Tracker_Remote::register_change_handler: NULL handler\n");
1423 "vrpn_Tracker_Remote::register_change_handler: Out of memory\n");
1430 vrpn_int32 whichSensor)
1435 "vrpn_Tracker_Remote::register_change_handler: bad sensor index\n");
1441 "vrpn_Tracker_Remote::register_change_handler: NULL handler\n");
1458 "vrpn_Tracker_Remote::register_change_handler: Out of memory\n");
1465 vrpn_int32 whichSensor)
1470 "vrpn_Tracker_Remote::register_change_handler: bad sensor index\n");
1477 "vrpn_Tracker_Remote::register_change_handler: NULL handler\n");
1494 "vrpn_Tracker_Remote::register_change_handler: Out of memory\n");
1501 vrpn_int32 whichSensor)
1506 "vrpn_Tracker_Remote::register_change_handler: bad sensor index\n");
1512 fprintf(stderr,
"%s%s",
"vrpn_Tracker_Remote:",
1513 ":register_change_handler: NULL handler\n");
1530 "vrpn_Tracker_Remote::register_change_handler: Out of memory\n");
1539 fprintf(stderr,
"vrpn_Tracker_Remote::unregister_change_handler: bad "
1555 "vrpn_Tracker_Remote::unregister_change_handler: Out of memory\n");
1562 vrpn_int32 whichSensor)
1565 fprintf(stderr,
"vrpn_Tracker_Remote::unregister_change_handler: bad "
1581 "vrpn_Tracker_Remote::unregister_change_handler: Out of memory\n");
1588 vrpn_int32 whichSensor)
1591 fprintf(stderr,
"vrpn_Tracker_Remote::unregister_change_handler: bad "
1607 "vrpn_Tracker_Remote::unregister_change_handler: Out of memory\n");
1614 vrpn_int32 whichSensor)
1617 fprintf(stderr,
"vrpn_Tracker_Remote::unregister_change_handler: bad "
1633 "vrpn_Tracker_Remote::unregister_change_handler: Out of memory\n");
1642 const char *params = (p.
buffer);
1648 if (p.
payload_len != (8 *
sizeof(vrpn_float64))) {
1649 fprintf(stderr,
"vrpn_Tracker: change message payload error\n");
1650 fprintf(stderr,
" (got %d, expected %lud)\n", p.
payload_len,
1651 static_cast<unsigned long>(8 *
sizeof(vrpn_float64)));
1658 for (i = 0; i < 3; i++) {
1661 for (i = 0; i < 4; i++) {
1671 if (tp.sensor < 0) {
1672 fprintf(stderr,
"vrpn_Tracker_Rem:pos sensor index is negative!\n");
1679 fprintf(stderr,
"vrpn_Tracker_Rem:pos sensor index too large\n");
1689 const char *params = p.
buffer;
1691 vrpn_TRACKERVELCB tp;
1695 if (p.
payload_len != (9 *
sizeof(vrpn_float64))) {
1696 fprintf(stderr,
"vrpn_Tracker: vel message payload error\n");
1697 fprintf(stderr,
" (got %d, expected %lud)\n", p.
payload_len,
1698 static_cast<unsigned long>(9 *
sizeof(vrpn_float64)));
1705 for (i = 0; i < 3; i++) {
1708 for (i = 0; i < 4; i++) {
1724 fprintf(stderr,
"vrpn_Tracker_Rem:vel sensor index too large\n");
1734 const char *params = p.
buffer;
1736 vrpn_TRACKERACCCB tp;
1740 if (p.
payload_len != (9 *
sizeof(vrpn_float64))) {
1741 fprintf(stderr,
"vrpn_Tracker: acc message payload error\n");
1742 fprintf(stderr,
"(got %d, expected %lud)\n", p.
payload_len,
1743 static_cast<unsigned long>(9 *
sizeof(vrpn_float64)));
1750 for (i = 0; i < 3; i++) {
1753 for (i = 0; i < 4; i++) {
1769 fprintf(stderr,
"vrpn_Tracker_Rem:acc sensor index too large\n");
1779 const char *params = p.
buffer;
1781 vrpn_TRACKERUNIT2SENSORCB tp;
1785 if (p.
payload_len != (8 *
sizeof(vrpn_float64))) {
1786 fprintf(stderr,
"vrpn_Tracker: unit2sensor message payload");
1787 fprintf(stderr,
" error\n(got %d, expected %lud)\n", p.
payload_len,
1788 static_cast<unsigned long>(8 *
sizeof(vrpn_float64)));
1797 for (i = 0; i < 3; i++) {
1800 for (i = 0; i < 4; i++) {
1814 fprintf(stderr,
"vrpn_Tracker_Rem:u2s sensor index too large\n");
1825 const char *params = p.
buffer;
1826 vrpn_TRACKERTRACKER2ROOMCB tp;
1830 if (p.
payload_len != (7 *
sizeof(vrpn_float64))) {
1831 fprintf(stderr,
"vrpn_Tracker: tracker2room message payload");
1832 fprintf(stderr,
" error\n(got %d, expected %lud)\n", p.
payload_len,
1833 static_cast<unsigned long>(7 *
sizeof(vrpn_float64)));
1838 for (i = 0; i < 3; i++) {
1841 for (i = 0; i < 4; i++) {
1856 const char *params = p.
buffer;
1857 vrpn_TRACKERWORKSPACECB tp;
1861 if (p.
payload_len != (6 *
sizeof(vrpn_float64))) {
1862 fprintf(stderr,
"vrpn_Tracker: tracker2room message payload");
1863 fprintf(stderr,
" error\n(got %d, expected %lud)\n", p.
payload_len,
1864 static_cast<unsigned long>(6 *
sizeof(vrpn_float64)));
1869 for (i = 0; i < 3; i++) {
1872 for (i = 0; i < 3; i++) {
vrpn_float64 workspace_max[3]
char portname[VRPN_TRACKER_BUF_SIZE]
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 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...
int read_config_file(FILE *config_file, const char *tracker_name)
virtual void send_report(void)
vrpn_Callback_List< vrpn_TRACKERCB > d_change
virtual int report_pose_acceleration(const int sensor, const struct timeval t, const vrpn_float64 position[3], const vrpn_float64 quaternion[4], const vrpn_float64 interval, const vrpn_uint32 class_of_service=vrpn_CONNECTION_LOW_LATENCY)
void client_mainloop(void)
Handles functions that all clients should provide in their mainloop() (warning of no server,...
vrpn_Callback_List< vrpn_TRACKERUNIT2SENSORCB > d_unit2sensorchange
virtual int register_change_handler(void *userdata, vrpn_TRACKERCHANGEHANDLER handler, vrpn_int32 sensor=vrpn_ALL_SENSORS)
virtual ~vrpn_Tracker_USB()
unsigned long vrpn_TimevalDuration(struct timeval endT, struct timeval startT)
Return number of microseconds between startT and endT.
virtual int encode_to(char *buf)
vrpn_float64 vrpn_Tracker_Pos[3]
vrpn_Tracker_Sensor_Callbacks * sensor_callbacks
virtual int report_pose_velocity(const int sensor, const struct timeval t, const vrpn_float64 position[3], const vrpn_float64 quaternion[4], const vrpn_float64 interval, const vrpn_uint32 class_of_service=vrpn_CONNECTION_LOW_LATENCY)
bool ensure_enough_unit2sensors(unsigned num)
static int VRPN_CALLBACK handle_workspace_request(void *userdata, vrpn_HANDLERPARAM p)
vrpn_Tracker_USB(const char *name, vrpn_Connection *c, vrpn_uint16 vendor, vrpn_uint16 product, long baud=115200)
virtual int report_pose(const int sensor, const struct timeval t, const vrpn_float64 position[3], const vrpn_float64 quaternion[4], const vrpn_uint32 class_of_service=vrpn_CONNECTION_LOW_LATENCY)
These functions should be called to report changes in state, once per sensor.
unsigned num_sensor_callbacks
vrpn_Tracker_Serial(const char *name, vrpn_Connection *c, const char *port="/dev/ttyS1", long baud=38400)
virtual int encode_vel_to(char *buf)
vrpn_int32 update_rate_id
vrpn_float64 tracker2room_quat[4]
int request_t2r_xform(void)
virtual int encode_unit2sensor_to(char *buf)
Encodes the "Unit to Sensor" transformation into the buffer specified.
int request_u2s_xform(void)
void(VRPN_CALLBACK * vrpn_TRACKERCHANGEHANDLER)(void *userdata, const vrpn_TRACKERCB info)
vrpn_Serial: Pulls all the serial port routines into one file to make porting to new operating system...
static int VRPN_CALLBACK handle_t2r_request(void *userdata, vrpn_HANDLERPARAM p)
virtual int register_types(void)
Register the types of messages this device sends/receives. Return 0 on success, -1 on fail.
virtual int encode_tracker2room_to(char *buf)
Encodes the "Tracker to Room" transformation into the buffer specified.
int register_handler(void *userdata, HANDLER_TYPE handler)
Call this to add a handler to the list.
const vrpn_uint32 vrpn_CONNECTION_LOW_LATENCY
vrpn_Tracker_NULL(const char *name, vrpn_Connection *c, vrpn_int32 sensors=1, vrpn_float64 Hz=1.0)
virtual int get_report(void)=0
Gets reports if some are available, returns 0 if not, 1 if complete report(s).
VRPN_API int vrpn_unbuffer(const char **buffer, timeval *t)
Utility routine for taking a struct timeval from a buffer that was sent as a message.
virtual ~vrpn_Tracker_Remote(void)
vrpn_int32 workspace_m_id
vrpn_Connection * d_connection
Connection that this object talks to.
virtual vrpn_int32 register_message_type(const char *name)
virtual int encode_workspace_to(char *buf)
void(VRPN_CALLBACK * vrpn_TRACKERACCCHANGEHANDLER)(void *userdata, const vrpn_TRACKERACCCB info)
const vrpn_uint32 vrpn_CONNECTION_RELIABLE
Classes of service for messages, specify multiple by ORing them together Priority of satisfying these...
This structure is what is passed to a vrpn_Connection message callback.
const int vrpn_TRACKER_PARTIAL
vrpn_RedundantTransmission * d_redundancy
vrpn_Tracker_Pos * unit2sensor
virtual void send_report(void)
virtual ~vrpn_Tracker_Serial()
static int VRPN_CALLBACK handle_unit2sensor_change_message(void *userdata, vrpn_HANDLERPARAM p)
vrpn_int32 d_sender_id
Sender ID registered with the connection.
int set_update_rate(vrpn_float64 samplesPerSecond)
static int VRPN_CALLBACK handle_tracker2room_change_message(void *userdata, vrpn_HANDLERPARAM p)
void(VRPN_CALLBACK * vrpn_TRACKERUNIT2SENSORCHANGEHANDLER)(void *userdata, const vrpn_TRACKERUNIT2SENSORCB info)
vrpn_int32 request_workspace_m_id
virtual void mainloop()
This function should be called each time through app mainloop.
vrpn_Tracker_Quat * unit2sensor_quat
virtual void mainloop()
Uses the get_report, send_report, and reset routines to implement a server.
vrpn_float64 vrpn_Tracker_Quat[4]
virtual int mainloop(const struct timeval *timeout=NULL)=0
Call each time through program main loop to handle receiving any incoming messages and sending any pa...
virtual int encode_acc_to(char *buf)
Generic connection class not specific to the transport mechanism.
void get_local_u2s(vrpn_int32 sensor, vrpn_float64 *vec, vrpn_float64 *quat)
const int vrpn_TRACKER_FAIL
virtual int pack_message(vrpn_uint32 len, timeval time, vrpn_uint32 type, vrpn_uint32 sender, const char *buffer, vrpn_uint32 class_of_service, vrpn_int32 numRetransmissions=-1, timeval *transmissionInterval=NULL)
If !isEnabled(), does a normal pack_message(), but if isEnabled() ignores class_of_service and sends ...
const int vrpn_TRACKER_RESETTING
vrpn_int32 request_u2s_m_id
vrpn_Tracker_Sensor_Callbacks all_sensor_callbacks
#define vrpn_gettimeofday
struct timeval watchdog_timestamp
int register_server_handlers(void)
virtual void mainloop()
Called once through each main loop iteration to handle updates. Remote object mainloop() should call ...
vrpn_Callback_List< vrpn_TRACKERTRACKER2ROOMCB > d_tracker2roomchange_list
vrpn_Callback_List< vrpn_TRACKERACCCB > d_accchange
vrpn_float64 workspace_min[3]
virtual ~vrpn_Tracker(void)
int vrpn_close_commport(int comm)
static int VRPN_CALLBACK handle_vel_change_message(void *userdata, vrpn_HANDLERPARAM p)
#define vrpn_ser_tkr_MAX_TIME_INTERVAL
struct libusb_device_handle * _device_handle
const int vrpn_TRACKER_SYNCING
static int VRPN_CALLBACK handle_acc_change_message(void *userdata, vrpn_HANDLERPARAM p)
virtual void reset(void)=0
Reset the tracker.
vrpn_Callback_List< vrpn_TRACKERWORKSPACECB > d_workspacechange_list
virtual void mainloop()
Called once through each main loop iteration to handle updates. Remote object mainloop() should call ...
static int VRPN_CALLBACK handle_u2s_request(void *userdata, vrpn_HANDLERPARAM p)
struct libusb_context * _context
static int VRPN_CALLBACK handle_change_message(void *userdata, vrpn_HANDLERPARAM p)
virtual int unregister_change_handler(void *userdata, vrpn_TRACKERCHANGEHANDLER handler, vrpn_int32 sensor=vrpn_ALL_SENSORS)
virtual int init(void)
Initialize things that the constructor can't. Returns 0 on success, -1 on failure.
unsigned num_unit2sensors
const int vrpn_TRACKER_AWAITING_STATION
VRPN_API int vrpn_buffer(char **insertPt, vrpn_int32 *buflen, const timeval t)
Utility routine for placing a timeval struct into a buffer that is to be sent as a message.
vrpn_float64 tracker2room[3]
vrpn_Tracker_Server(const char *name, vrpn_Connection *c, vrpn_int32 sensors=1)
int vrpn_open_commport(const char *portname, long baud, int charsize, vrpn_SER_PARITY parity, bool rts_flow)
Open a serial port, given its name and baud rate.
vrpn_int32 request_t2r_m_id
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.
vrpn_int32 reset_origin_m_id
virtual void mainloop()
Uses the get_report, send_report, and reset routines to implement a server.
void(VRPN_CALLBACK * vrpn_TRACKERVELCHANGEHANDLER)(void *userdata, const vrpn_TRACKERVELCB info)
bool ensure_enough_sensor_callbacks(unsigned num)
void call_handlers(const CALLBACK_STRUCT &info)
This will pass the referenced parameter as a const to all the callbacks.
int unregister_handler(void *userdata, HANDLER_TYPE handler)
Call this to remove a handler from the list (if it exists)
void print_latest_report(void)
vrpn_int32 unit2sensor_m_id
vrpn_Tracker(const char *name, vrpn_Connection *c=NULL, const char *tracker_cfg_file_name=NULL)
void get_local_t2r(vrpn_float64 *vec, vrpn_float64 *quat)
vrpn_Tracker_Remote(const char *name, vrpn_Connection *c=NULL)
void setRedundantTransmission(vrpn_RedundantTransmission *)
vrpn_int32 tracker2room_m_id
void server_mainloop(void)
Handles functions that all servers should provide in their mainloop() (ping/pong, for example) Should...
Class from which all user-level (and other) classes that communicate with vrpn_Connections should der...
vrpn_Callback_List< vrpn_TRACKERVELCB > d_velchange
const int vrpn_ALL_SENSORS
virtual int get_report(void)=0
Gets a report if one is available, returns 0 if not, 1 if complete report.
virtual void reset(void)=0
Reset the tracker.
vrpn_MESSAGEHANDLER handler
static int VRPN_CALLBACK handle_workspace_change_message(void *userdata, vrpn_HANDLERPARAM p)
int request_workspace(void)