RflySimSDK v3.08
RflySimSDK说明文档
载入中...
搜索中...
未找到
vrpn_Tracker_Crossbow.h
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
14class VRPN_API vrpn_Connection;
15
17public:
18 /// The constructor is given the name of the tracker (the name of
19 /// the sender it should use), the connection on which it is to
20 /// send its messages, the name of the serial port it is to open
21 /// (default is /dev/ttyS0 (first serial port in Linux), the baud
22 /// rate at which it is to communicate (default 38400), the linear
23 /// acceleration range of the sensor in Gs (default 2), and the
24 /// angular acceleration range of the sensor in degrees per second
25 /// (default 100).
26
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
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
53protected:
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;
70 float lin_accel_range;
71 float ang_accel_range;
72
73 vrpn_uint32 device_serial; // Device serial number
74 char *device_version; // Device version string
75
76 int just_read_something;
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
Generic connection class not specific to the transport mechanism.
定义 vrpn_Connection.h:562
定义 vrpn_Tracker_Crossbow.h:16
virtual void mainloop()
vrpn_Tracker_Crossbow(const char *name, vrpn_Connection *c, const char *port="/dev/ttyS0", long baud=38400, float g_range=2.0f, float ar_range=100.0f)
void reset()
Reset the tracker.
定义 vrpn_Tracker.h:144
定义 vrpn_Tracker_Crossbow.h:54