vex_sdk/
gps.rs

1//! V5 GPS
2
3use core::ffi::c_double;
4
5use crate::{map_jump_table, V5_DeviceT};
6
7#[repr(C, packed)]
8#[derive(Default, Debug, Copy, Clone, PartialEq)]
9pub struct V5_DeviceGpsRaw {
10    pub x: c_double,
11    pub y: c_double,
12    pub z: c_double,
13    pub w: c_double,
14}
15
16#[repr(C, packed)]
17#[derive(Default, Debug, Copy, Clone, PartialEq)]
18pub struct V5_DeviceGpsAttitude {
19    pub pitch: c_double, // x
20    pub roll: c_double,  // y
21    pub yaw: c_double,   // z
22
23    // spacial position on the field
24    pub position_x: c_double,
25    pub position_y: c_double,
26    pub position_z: c_double,
27
28    // alternative roll, pitch and yaw
29    pub az: c_double,
30    pub el: c_double,
31    pub rot: c_double,
32}
33
34#[repr(C, packed)]
35#[derive(Default, Debug, Copy, Clone, PartialEq)]
36pub struct V5_DeviceGpsQuaternion {
37    pub x: c_double,
38    pub y: c_double,
39    pub z: c_double,
40    pub w: c_double,
41}
42
43map_jump_table! {
44    0x5c8 => pub fn vexDeviceGpsReset(device: V5_DeviceT),
45    0x5cc => pub fn vexDeviceGpsHeadingGet(device: V5_DeviceT) -> c_double,
46    0x5d0 => pub fn vexDeviceGpsDegreesGet(device: V5_DeviceT) -> c_double,
47    0x5d4 => pub fn vexDeviceGpsQuaternionGet(device: V5_DeviceT, data: *mut V5_DeviceGpsQuaternion),
48    0x5d8 => pub fn vexDeviceGpsAttitudeGet(device: V5_DeviceT, data: *mut V5_DeviceGpsAttitude, bRaw: bool),
49    0x5dc => pub fn vexDeviceGpsRawGyroGet(device: V5_DeviceT, data: *mut V5_DeviceGpsRaw),
50    0x5e0 => pub fn vexDeviceGpsRawAccelGet(device: V5_DeviceT, data: *mut V5_DeviceGpsRaw),
51    0x5e4 => pub fn vexDeviceGpsStatusGet(device: V5_DeviceT) -> u32,
52    0x5f0 => pub fn vexDeviceGpsModeSet(device: V5_DeviceT, mode: u32),
53    0x5f4 => pub fn vexDeviceGpsModeGet(device: V5_DeviceT) -> u32,
54    0x5f8 => pub fn vexDeviceGpsDataRateSet(device: V5_DeviceT, rate: u32),
55    0x5fc => pub fn vexDeviceGpsOriginSet(device: V5_DeviceT, ox: c_double, oy: c_double),
56    0x600 => pub fn vexDeviceGpsOriginGet(device: V5_DeviceT, ox: *mut c_double, oy: *mut c_double),
57    0x604 => pub fn vexDeviceGpsRotationSet(device: V5_DeviceT, value: c_double),
58    0x608 => pub fn vexDeviceGpsRotationGet(device: V5_DeviceT) -> c_double,
59    0x60c => pub fn vexDeviceGpsInitialPositionSet(device: V5_DeviceT, initial_x: c_double, initial_y: c_double, initial_rotation: c_double),
60    0x614 => pub fn vexDeviceGpsErrorGet(device: V5_DeviceT) -> c_double,
61}