vrpn  07.33
Virtual Reality Peripheral Network
vrpn_Tracker_Crossbow.h
Go to the documentation of this file.
1 // vrpn_Tracker_Crossbow.h
2 // This file contains the class header for a Crossbow RGA300CA Tracker.
3 // This version was written in the summer of 2005 by Chris VanderKnyff.
4 
5 #ifndef VRPN_TRACKER_CROSSBOW_H
6 #define VRPN_TRACKER_CROSSBOW_H
7 
8 #include "quat.h" // for q_type
9 #include "vrpn_Configure.h" // for VRPN_API
10 #include "vrpn_Shared.h" // for timeval
11 #include "vrpn_Tracker.h" // for vrpn_Tracker_Serial
12 #include "vrpn_Types.h" // for vrpn_int16, vrpn_uint16, etc
13 
15 
17 public:
26 
27  vrpn_Tracker_Crossbow(const char *name, vrpn_Connection *c,
28  const char *port = "/dev/ttyS0", long baud = 38400,
29  float g_range = 2.0f, float ar_range = 100.0f);
30 
32 
33  // Run through the main loop once, sending notification messages as necessary
34  virtual void mainloop();
35 
36  // Reset the tracker.
37  void reset();
38 
39  // Get reports from the serial port
40  int get_report();
41 
42  // Retrieve the device's serial number. This is cached between resets.
43  vrpn_uint32 get_serial_number();
44 
45  // Retrieve the device's version string. This is cached between resets.
46  const char *get_version_string();
47 
48  // Recalibrates and zeros the device's rate sensors over a specified # of samples.
49  // This takes about 3-4ms per sample, during which time the process blocks.
50  // The device does not have to be level when zeroing, but must be still.
51  void recalibrate(vrpn_uint16 num_samples = 20000);
52 
53 protected:
54  struct raw_packet {
55  vrpn_uint16 header;
56  vrpn_int16 roll_angle;
57  vrpn_int16 pitch_angle;
58  vrpn_int16 yaw_rate;
59  vrpn_int16 accel_x;
60  vrpn_int16 accel_y;
61  vrpn_int16 accel_z;
62  vrpn_uint16 timer;
63  vrpn_int16 temp_voltage;
64  vrpn_int16 part_number;
65  vrpn_int16 status;
66  vrpn_uint16 checksum;
67  };
68 
69  struct timeval init_time;
72 
73  vrpn_uint32 device_serial; // Device serial number
74  char *device_version; // Device version string
75 
77 
78  void unbuffer_packet(raw_packet &dest, unsigned char *buffer);
79  int validate_packet(const raw_packet &packet);
80  void process_packet(const raw_packet &packet);
81 
82  float convert_scalar(vrpn_int16 data, float scale) const;
83  void xb_quat_from_euler(q_type destQuat, double pitch, double roll) const;
84 
85  void send_report();
86 
87  void ping();
88 
89 };
90 
91 #endif
92 
virtual void mainloop()
Uses the get_report, send_report, and reset routines to implement a server.
Definition: vrpn_Tracker.C:907
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.
Generic connection class not specific to the transport mechanism.
virtual void send_report(void)
Definition: vrpn_Tracker.C:885
#define VRPN_API