peripherals  1.4.2
RoadNarrows Robotics Hardware Peripherals Package
yost.h
1 #ifndef _YOST_H
2 #define _YOST_H
3 
4 #include <libusb-1.0/libusb.h>
5 using namespace std;
6 
7 #define YOST_ID_VENDOR 0x2476
8 #define YOST_ID_PRODUCTA 0x1010
9 #define YOST_ID_PRODUCTB 0x1040
10 #define YOST_NUMBER_OF_INTERFACES 3
11 #define YOST_READ_WRITE_T 3000
12 #define YOST_MAX_BUFF_LEN 75
13 #define YOST_WE_OK 0
14 class Yost {
15 public:
16  Yost();
17  ~Yost();
18  /*
19  * Function which detects if a YOST is attached to the system.
20  * If one is found it searches for and binds to it.
21  */
22  int OpenYost();
23 
24  /*
25  * Function which frees a connection to a previously bound YOST
26  */
27  void CloseYost();
28 
29  /*
30  * Function which sets the current attitude & heading as the reference
31  */
32  int ResetAngles();
33 
34  /*
35  * Function which disengages the magnetometer from the orientation assesment.
36  */
37  int MagOff();
38 
39  /*
40  * Function which disengages the magnetometer from the orientation assesment.
41  */
42  int MagOn();
43 
44  /*
45  * Function which reads the tared euler angles for X Y and Z.
46  * Needs to be passed: X, Y, and Z, float variables to be filled/modified
47  * (values are in radians)
48  */
49  int ReadEuler(float &ex, float &why, float &zee);
50 
51  /*
52  * Function which reads the tared quaternion W,X,Y,Z.
53  * Needs to be passed: W, X, Y, and Z, float variables to be filled/modified
54  * (values are in radians)
55  */
56  int ReadQuat(float &dubya, float &ex, float &why, float &zee);
57 
58 
59  /*
60  * Function which reads in two unit vectors, one which indicates down with respect
61  * to the sensor, and one which indicates forward with respect to the sensor.
62  */
63  int ReadVectors(float &downx, float &downy, float &downz,
64  float &forx, float &fory, float &forz);
65 
66 
67  int ReadDecoupleAngles(float &yaw, float &pitch, float &roll);
68 
69  /*
70  * Function which reads the raw Accelerometer values.
71  * Needs to be passed: X, Y, and Z, float variables to be filled/modified
72  * (values are in Gs)
73  */
74  int ReadAccel(float &ex, float &why, float &zee);
75 
76  /*
77  * Function which reads the confidence value as generated by the Kalman.
78  * Needs to be passed: a confidence variable. Float to be filled/modified
79  * (values from 0->1 [0% to 100%])
80  */
81  int ReadConfidence(float &cee);
82 
83  /*
84  * Function which reads the temperature value.
85  * Needs to be passed: a temperature variable. Float to be filled/modified
86  * (value is in Fahrenheit)
87  */
88  int ReadTemp(int &tee);
89 
90 
91 private:
92  struct libusb_device_handle *USB_lock;
93  struct libusb_context *tmpcntxt;
94  int FD;
95 
96  int checkYost();
97  int setAttributes(int fileDesc);
98  int writeNRead(uint8_t *from, const char *to);
99  int checkIfYost(const char *dev);
100  //Function to set the expected speed range of gyro
101  //0 = 250 DPS, 1= 500 DPS, 2 = 2000 DPS
102  int gyroSpeed(int speed);
103  int setYostToDefault();
104  int calibGyro();
105  int resetKalman();
106  void normalize(double *nx, double *ny, double *nz);
107 };
108 #endif
Definition: yost.h:14