pros_sys/
gps.rs

1#[repr(packed, C)]
2pub struct gps_status_s_t {
3    ///< X Position (meters)
4    pub x: f64,
5    ///< Y Position (meters)
6    pub y: f64,
7    ///< Perceived Pitch based on GPS + IMU
8    pub pitch: f64,
9    ///< Perceived Roll based on GPS + IMU
10    pub roll: f64,
11    ///< Perceived Yaw based on GPS + IMU
12    pub yaw: f64,
13}
14
15#[repr(C)]
16pub struct gps_raw_s {
17    ///< Perceived Pitch based on GPS + IMU
18    pub x: f64,
19    ///< Perceived Roll based on GPS + IMU
20    pub y: f64,
21    ///< Perceived Yaw based on GPS + IMU
22    pub z: f64,
23}
24
25pub type gps_accel_s_t = gps_raw_s;
26pub type gps_gyro_s_t = gps_raw_s;
27
28extern "C" {
29    /**
30    Set the GPS's offset relative to the center of turning in meters,
31    as well as its initial position.
32
33    This function uses the following values of errno when an error state is
34    reached:
35    ENXIO - The given value is not within the range of V5 ports (1-21).
36    ENODEV - The port cannot be configured as a GPS
37    EAGAIN - The sensor is still calibrating
38
39    \param  port
40                     The V5 GPS port number from 1-21
41    \param  xOffset
42                     Cartesian 4-Quadrant X offset from center of turning (meters)
43    \param  yOffset
44                     Cartesian 4-Quadrant Y offset from center of turning (meters)
45    \param  xInitial
46                     Initial 4-Quadrant X Position, with (0,0) being at the center of the field (meters)
47    \param  yInitial
48                     Initial 4-Quadrant Y Position, with (0,0) being at the center of the field (meters)
49    \param  headingInitial
50                  Heading with 0 being north on the field, in degrees [0,360) going clockwise
51    \return 1 if the operation was successful or PROS_ERR if the operation
52    failed, setting errno.
53    */
54    pub fn gps_initialize_full(
55        port: u8,
56        xInitial: f64,
57        yInitial: f64,
58        headingInitial: f64,
59        xOffset: f64,
60        yOffset: f64,
61    ) -> i32;
62    /**
63    Set the GPS's offset relative to the center of turning in meters.
64
65    This function uses the following values of errno when an error state is
66    reached:
67    ENXIO - The given value is not within the range of V5 ports (1-21).
68    ENODEV - The port cannot be configured as a GPS
69    EAGAIN - The sensor is still calibrating
70
71    \param  port
72                     The V5 GPS port number from 1-21
73    \param  xOffset
74                     Cartesian 4-Quadrant X offset from center of turning (meters)
75    \param  yOffset
76                     Cartesian 4-Quadrant Y offset from center of turning (meters)
77    \return 1 if the operation was successful or PROS_ERR if the operation
78    failed, setting errno.
79    */
80    pub fn gps_set_offset(port: u8, xOffset: f64, yOffset: f64) -> i32;
81    /**
82    Get the GPS's location relative to the center of turning/origin in meters.
83
84    This function uses the following values of errno when an error state is
85    reached:
86    ENXIO - The given value is not within the range of V5 ports (1-21).
87    ENODEV - The port cannot be configured as a GPS
88    EAGAIN - The sensor is still calibrating
89
90    \param  port
91                     The V5 GPS port number from 1-21
92    \param  xOffset
93                     Pointer to cartesian 4-Quadrant X offset from center of turning (meters)
94    \param  yOffset
95                     Pointer to cartesian 4-Quadrant Y offset from center of turning (meters)
96    \return 1 if the operation was successful or PROS_ERR if the operation
97    failed, setting errno.
98    */
99    pub fn gps_get_offset(port: u8, xOffset: *mut f64, yOffset: *mut f64) -> i32;
100    /**
101    Sets the robot's location relative to the center of the field in meters.
102
103    This function uses the following values of errno when an error state is
104    reached:
105    ENXIO - The given value is not within the range of V5 ports (1-21).
106    ENODEV - The port cannot be configured as a GPS
107    EAGAIN - The sensor is still calibrating
108
109    \param  port
110                     The V5 GPS port number from 1-21
111    \param  xInitial
112                     Initial 4-Quadrant X Position, with (0,0) being at the center of the field (meters)
113    \param  yInitial
114                     Initial 4-Quadrant Y Position, with (0,0) being at the center of the field (meters)
115    \param  headingInitial
116                  Heading with 0 being north on the field, in degrees [0,360) going clockwise
117    \return 1 if the operation was successful or PROS_ERR if the operation
118    failed, setting errno.
119    */
120    pub fn gps_set_position(port: u8, xInitial: f64, yInitial: f64, headingInitial: f64) -> i32;
121    /**
122    Set the GPS sensor's data rate in milliseconds, only applies to IMU on GPS.
123
124    This function uses the following values of errno when an error state is
125    reached:
126    ENXIO - The given value is not within the range of V5 ports (1-21).
127    ENODEV - The port cannot be configured as a GPS
128    EAGAIN - The sensor is still calibrating
129
130    \param  port
131                     The V5 GPS port number from 1-21
132    \param  rate
133                     Data rate in milliseconds (Minimum: 5 ms)
134    \return 1 if the operation was successful or PROS_ERR if the operation
135    failed, setting errno.
136    */
137    pub fn gps_set_data_rate(port: u8, rate: u32) -> i32;
138    /**
139    Get the possible RMS (Root Mean Squared) error in meters for GPS position.
140
141    This function uses the following values of errno when an error state is
142    reached:
143    ENXIO - The given value is not within the range of V5 ports (1-21).
144    ENODEV - The port cannot be configured as a GPS
145    EAGAIN - The sensor is still calibrating
146
147    \param  port
148                     The V5 GPS port number from 1-21
149
150    \return Possible RMS (Root Mean Squared) error in meters for GPS position.
151    If the operation failed, returns PROS_ERR_F and errno is set.
152    */
153    pub fn gps_get_error(port: u8) -> f64;
154    /**
155    Gets the position and roll, yaw, and pitch of the GPS.
156
157    This function uses the following values of errno when an error state is
158    reached:
159    ENXIO - The given value is not within the range of V5 ports (1-21).
160    ENODEV - The port cannot be configured as a GPS
161    EAGAIN - The sensor is still calibrating
162
163    \param  port
164                     The V5 GPS port number from 1-21
165
166    \return A struct (gps_status_s_t) containing values mentioned above.
167    If the operation failed, all the structure's members are filled with
168    PROS_ERR_F and errno is set.
169    */
170    pub fn gps_get_status(port: u8) -> gps_status_s_t;
171    /**
172    Get the heading in [0,360) degree values.
173
174    This function uses the following values of errno when an error state is
175    reached:
176    ENXIO - The given value is not within the range of V5 ports (1-21).
177    ENODEV - The port cannot be configured as a GPS
178    EAGAIN - The sensor is still calibrating
179
180    \param  port
181                     The V5 GPS port number from 1-21
182
183    \return The heading in [0,360) degree values. If the operation failed,
184    returns PROS_ERR_F and errno is set.
185    */
186    pub fn gps_get_heading(port: u8) -> f64;
187    /**
188    Get the heading in the max double value and min double value scale.
189
190    This function uses the following values of errno when an error state is
191    reached:
192    ENXIO - The given value is not within the range of V5 ports (1-21).
193    ENODEV - The port cannot be configured as a GPS
194    EAGAIN - The sensor is still calibrating
195
196    \param  port
197                     The V5 GPS port number from 1-21
198
199    \return The heading in [DOUBLE_MIN, DOUBLE_MAX] values. If the operation
200    fails, returns PROS_ERR_F and errno is set.
201    */
202    pub fn gps_get_heading_raw(port: u8) -> f64;
203    /**
204    Gets the GPS sensor's elapsed rotation value
205
206    This function uses the following values of errno when an error state is
207    reached:
208    ENXIO - The given value is not within the range of V5 ports (1-21).
209    ENODEV - The port cannot be configured as a GPS
210    EAGAIN - The sensor is still calibrating
211
212    \param  port
213                     The V5 GPS port number from 1-21
214    \return The elapsed heading in degrees. If the operation fails, returns
215    PROS_ERR_F and errno is set.
216    */
217    pub fn gps_get_rotation(port: u8) -> f64;
218    /**
219    Set the GPS sensor's rotation value to target value
220
221    This function uses the following values of errno when an error state is
222    reached:
223    ENXIO - The given value is not within the range of V5 ports (1-21).
224    ENODEV - The port cannot be configured as a GPS
225    EAGAIN - The sensor is still calibrating
226
227    \param  port
228                     The V5 GPS port number from 1-21
229    \param  target
230                     Target rotation value to set rotation value to
231    \return 1 if the operation was successful or PROS_ERR if the operation
232    failed, setting errno.
233    */
234    pub fn gps_set_rotation(port: u8, targe: f64) -> i32;
235    /**
236    Tare the GPS sensor's rotation value
237
238    This function uses the following values of errno when an error state is
239    reached:
240    ENXIO - The given value is not within the range of V5 ports (1-21).
241    ENODEV - The port cannot be configured as a GPS
242    EAGAIN - The sensor is still calibrating
243
244    \param  port
245                     The V5 GPS port number from 1-21
246    \return 1 if the operation was successful or PROS_ERR if the operation
247    failed, setting errno.
248    */
249    pub fn gps_tare_rotation(port: u8) -> i32;
250    /**
251    Get the GPS's raw gyroscope values
252
253    This function uses the following values of errno when an error state is
254    reached:
255    ENXIO - The given value is not within the range of V5 ports (1-21).
256    ENODEV - The port cannot be configured as a GPS
257    EAGAIN - The sensor is still calibrating
258
259    \param  port
260                     The V5 GPS port number from 1-21
261    \return The raw gyroscope values. If the operation failed, all the
262    structure's members are filled with PROS_ERR_F and errno is set.
263    */
264    pub fn gps_get_gyro_rate(port: u8) -> gps_gyro_s_t;
265    /**
266    Get the GPS's raw accelerometer values
267
268    This function uses the following values of errno when an error state is
269    reached:
270    ENXIO - The given value is not within the range of V5 ports (1-21).
271    ENODEV - The port cannot be configured as an GPS
272    EAGAIN - The sensor is still calibrating
273
274    \param  port
275                     The V5 GPS's port number from 1-21
276    \return The raw accelerometer values. If the operation failed, all the
277    structure's members are filled with PROS_ERR_F and errno is set.
278    */
279    pub fn gps_get_accel(port: u8) -> gps_accel_s_t;
280}