Skip to content

Commit

Permalink
Conversion to 2021 ADS-DV interface.
Browse files Browse the repository at this point in the history
Separated out IMU & GPS data interfaces.
  • Loading branch information
IanMurphy-Rockfort committed May 29, 2021
1 parent f1ec669 commit afdda52
Show file tree
Hide file tree
Showing 10 changed files with 1,164 additions and 751 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,6 @@ Mkfile.old
dkms.conf

# Extras
.vscode/
FS-AI_API_Console/fs-ai_api_console
FS-AI_API_Tester/fs-ai_api_tester
Binary file not shown.
Binary file added Docs/PCAN-GPS_UserMan_eng.pdf
Binary file not shown.
Binary file not shown.

Large diffs are not rendered by default.

848 changes: 585 additions & 263 deletions FS-AI_API/fs-ai_api.c

Large diffs are not rendered by default.

166 changes: 139 additions & 27 deletions FS-AI_API/fs-ai_api.h
Original file line number Diff line number Diff line change
@@ -1,11 +1,36 @@
/*********************************************************************
* Copyright: Preston EV Limited 2018, Rockfort Engineering Ltd. 2019
/**************************************************************************
* Copyright: Preston EV Limited 2018, Rockfort Engineering Ltd. 2019, 2021
*
* File: fs-ai_api.h
* Author: Ian Murphy
* Date: 2018-06-25, 2019-05-14
* Date: 2018-06-25, 2019-05-14, 2021-05-22
*
********************************************************************/
*************************************************************************/


/**************************************************************************
MIT License
Copyright (c) 2021 IMechE Formula Student AI
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*************************************************************************/


#ifndef FS_AI_API_H
Expand Down Expand Up @@ -33,9 +58,9 @@ typedef enum fs_ai_api_ami_state_e {
AMI_SKIDPAD = 2,
AMI_AUTOCROSS = 3,
AMI_TRACK_DRIVE = 4,
AMI_BRAKE_TEST = 5,
AMI_INSPECTION = 6,
AMI_MANUAL = 7,
AMI_STATIC_INSPECTION_A = 5,
AMI_STATIC_INSPECTION_B = 6,
AMI_AUTONOMOUS_DEMO = 7,
} fs_ai_api_ami_state_e;


Expand All @@ -45,14 +70,21 @@ typedef enum fs_ai_api_handshake_receive_bit_e {
} fs_ai_api_handshake_receive_bit_e;


typedef enum fs_ai_api_res_go_signal_bit_e {
RES_GO_SIGNAL_NO_GO = 0,
RES_GO_SIGNAL_GO = 1,
} fs_ai_api_res_go_signal_bit_e;


#ifdef __cplusplus
typedef volatile struct alignas(4) fs_ai_api_vcu2ai_struct {
volatile fs_ai_api_handshake_receive_bit_e VCU2AI_HANDSHAKE_RECEIVE_BIT;
volatile fs_ai_api_res_go_signal_bit_e VCU2AI_RES_GO_SIGNAL;
volatile fs_ai_api_as_state_e VCU2AI_AS_STATE;
volatile fs_ai_api_ami_state_e VCU2AI_AMI_STATE;
volatile fs_ai_api_handshake_receive_bit_e VCU2AI_HANDSHAKE_RECEIVE_BIT;
volatile float VCU2AI_STEER_ANGLE_MAX_deg;
volatile float VCU2AI_STEER_ANGLE_deg;
volatile float VCU2AI_WHEEL_SPEED_MAX_rpm;
volatile float VCU2AI_BRAKE_PRESS_F_pct;
volatile float VCU2AI_BRAKE_PRESS_R_pct;
volatile float VCU2AI_FL_WHEEL_SPEED_rpm;
volatile float VCU2AI_FR_WHEEL_SPEED_rpm;
volatile float VCU2AI_RL_WHEEL_SPEED_rpm;
Expand All @@ -61,21 +93,16 @@ typedef volatile struct alignas(4) fs_ai_api_vcu2ai_struct {
volatile uint16_t VCU2AI_FR_PULSE_COUNT;
volatile uint16_t VCU2AI_RL_PULSE_COUNT;
volatile uint16_t VCU2AI_RR_PULSE_COUNT;
volatile float VCU2AI_Accel_longitudinal_ms2;
volatile float VCU2AI_Accel_lateral_ms2;
volatile float VCU2AI_Accel_vertical_ms2;
volatile float VCU2AI_Yaw_rate_degps;
volatile float VCU2AI_Roll_rate_degps;
volatile float VCU2AI_Pitch_rate_degps;
} fs_ai_api_vcu2ai;
#else
typedef volatile struct fs_ai_api_vcu2ai_struct {
volatile _Alignas(4) fs_ai_api_handshake_receive_bit_e VCU2AI_HANDSHAKE_RECEIVE_BIT;
volatile _Alignas(4) fs_ai_api_res_go_signal_bit_e VCU2AI_RES_GO_SIGNAL;
volatile _Alignas(4) fs_ai_api_as_state_e VCU2AI_AS_STATE;
volatile _Alignas(4) fs_ai_api_ami_state_e VCU2AI_AMI_STATE;
volatile _Alignas(4) fs_ai_api_handshake_receive_bit_e VCU2AI_HANDSHAKE_RECEIVE_BIT;
volatile _Alignas(4) float VCU2AI_STEER_ANGLE_MAX_deg;
volatile _Alignas(4) float VCU2AI_STEER_ANGLE_deg;
volatile _Alignas(4) float VCU2AI_WHEEL_SPEED_MAX_rpm;
volatile _Alignas(4) float VCU2AI_BRAKE_PRESS_F_pct;
volatile _Alignas(4) float VCU2AI_BRAKE_PRESS_R_pct;
volatile _Alignas(4) float VCU2AI_FL_WHEEL_SPEED_rpm;
volatile _Alignas(4) float VCU2AI_FR_WHEEL_SPEED_rpm;
volatile _Alignas(4) float VCU2AI_RL_WHEEL_SPEED_rpm;
Expand All @@ -84,12 +111,6 @@ typedef volatile struct fs_ai_api_vcu2ai_struct {
volatile _Alignas(4) uint16_t VCU2AI_FR_PULSE_COUNT;
volatile _Alignas(4) uint16_t VCU2AI_RL_PULSE_COUNT;
volatile _Alignas(4) uint16_t VCU2AI_RR_PULSE_COUNT;
volatile _Alignas(4) float VCU2AI_Accel_longitudinal_ms2;
volatile _Alignas(4) float VCU2AI_Accel_lateral_ms2;
volatile _Alignas(4) float VCU2AI_Accel_vertical_ms2;
volatile _Alignas(4) float VCU2AI_Yaw_rate_degps;
volatile _Alignas(4) float VCU2AI_Roll_rate_degps;
volatile _Alignas(4) float VCU2AI_Pitch_rate_degps;
} fs_ai_api_vcu2ai;
#endif

Expand Down Expand Up @@ -127,7 +148,9 @@ typedef volatile struct alignas(4) fs_ai_api_ai2vcu_struct {
volatile fs_ai_api_estop_request_e AI2VCU_ESTOP_REQUEST;
volatile fs_ai_api_handshake_send_bit_e AI2VCU_HANDSHAKE_SEND_BIT;
volatile float AI2VCU_STEER_ANGLE_REQUEST_deg;
volatile float AI2VCU_WHEEL_SPEED_REQUEST_rpm;
volatile float AI2VCU_AXLE_SPEED_REQUEST_rpm;
volatile float AI2VCU_AXLE_TORQUE_REQUEST_Nm;
volatile float AI2VCU_BRAKE_PRESS_REQUEST_pct;
} fs_ai_api_ai2vcu;
#else
typedef volatile struct fs_ai_api_ai2vcu_struct {
Expand All @@ -136,16 +159,105 @@ typedef volatile struct fs_ai_api_ai2vcu_struct {
volatile _Alignas(4) fs_ai_api_estop_request_e AI2VCU_ESTOP_REQUEST;
volatile _Alignas(4) fs_ai_api_handshake_send_bit_e AI2VCU_HANDSHAKE_SEND_BIT;
volatile _Alignas(4) float AI2VCU_STEER_ANGLE_REQUEST_deg;
volatile _Alignas(4) float AI2VCU_WHEEL_SPEED_REQUEST_rpm;
volatile _Alignas(4) float AI2VCU_AXLE_SPEED_REQUEST_rpm;
volatile _Alignas(4) float AI2VCU_AXLE_TORQUE_REQUEST_Nm;
volatile _Alignas(4) float AI2VCU_BRAKE_PRESS_REQUEST_pct;
} fs_ai_api_ai2vcu;
#endif


#ifdef __cplusplus
typedef volatile struct alignas(4) fs_ai_api_gps_struct {
volatile uint8_t GPS_AntennaStatus;
volatile uint8_t GPS_NumSatellites;
volatile uint8_t GPS_NavigationMethod;
volatile float GPS_Course_deg;
volatile float GPS_Speed_kmh;
volatile float GPS_Longitude_Minutes;
volatile uint16_t GPS_Longitude_Degree;
volatile uint8_t GPS_Longitude_IndicatorEW;
volatile float GPS_Latitude_Minutes;
volatile uint16_t GPS_Latitude_Degree;
volatile uint8_t GPS_Latitude_IndicatorNS;
volatile float GPS_Altitude;
volatile float GPS_PDOP;
volatile float GPS_HDOP;
volatile float GPS_VDOP;
volatile uint8_t GPS_UTC_Year;
volatile uint8_t GPS_UTC_Month;
volatile uint8_t GPS_UTC_DayOfMonth;
volatile uint8_t GPS_UTC_Hour;
volatile uint8_t GPS_UTC_Minute;
volatile uint8_t GPS_UTC_Second;
} fs_ai_api_gps;
#else
typedef volatile struct fs_ai_api_gps_struct {
volatile _Alignas(4) uint8_t GPS_AntennaStatus;
volatile _Alignas(4) uint8_t GPS_NumSatellites;
volatile _Alignas(4) uint8_t GPS_NavigationMethod;
volatile _Alignas(4) float GPS_Course_deg;
volatile _Alignas(4) float GPS_Speed_kmh;
volatile _Alignas(4) float GPS_Longitude_Minutes;
volatile _Alignas(4) uint16_t GPS_Longitude_Degree;
volatile _Alignas(4) uint8_t GPS_Longitude_IndicatorEW;
volatile _Alignas(4) float GPS_Latitude_Minutes;
volatile _Alignas(4) uint16_t GPS_Latitude_Degree;
volatile _Alignas(4) uint8_t GPS_Latitude_IndicatorNS;
volatile _Alignas(4) float GPS_Altitude;
volatile _Alignas(4) float GPS_PDOP;
volatile _Alignas(4) float GPS_HDOP;
volatile _Alignas(4) float GPS_VDOP;
volatile _Alignas(4) uint8_t GPS_UTC_Year;
volatile _Alignas(4) uint8_t GPS_UTC_Month;
volatile _Alignas(4) uint8_t GPS_UTC_DayOfMonth;
volatile _Alignas(4) uint8_t GPS_UTC_Hour;
volatile _Alignas(4) uint8_t GPS_UTC_Minute;
volatile _Alignas(4) uint8_t GPS_UTC_Second;
} fs_ai_api_gps;
#endif


#ifdef __cplusplus
typedef volatile struct alignas(4) fs_ai_api_imu_struct {
volatile float IMU_Acceleration_X_mG;
volatile float IMU_Acceleration_Y_mG;
volatile float IMU_Acceleration_Z_mG;
volatile float IMU_Temperature_degC;
volatile uint8_t IMU_VerticalAxis;
volatile uint8_t IMU_Orientation;
volatile float IMU_MagneticField_X_uT;
volatile float IMU_MagneticField_Y_uT;
volatile float IMU_MagneticField_Z_uT;
volatile float IMU_Rotation_X_degps;
volatile float IMU_Rotation_Y_degps;
volatile float IMU_Rotation_Z_degps;
} fs_ai_api_imu;
#else
typedef volatile struct fs_ai_api_imu_struct {
volatile _Alignas(4) float IMU_Acceleration_X_mG;
volatile _Alignas(4) float IMU_Acceleration_Y_mG;
volatile _Alignas(4) float IMU_Acceleration_Z_mG;
volatile _Alignas(4) float IMU_Temperature_degC;
volatile _Alignas(4) uint8_t IMU_VerticalAxis;
volatile _Alignas(4) uint8_t IMU_Orientation;
volatile _Alignas(4) float IMU_MagneticField_X_uT;
volatile _Alignas(4) float IMU_MagneticField_Y_uT;
volatile _Alignas(4) float IMU_MagneticField_Z_uT;
volatile _Alignas(4) float IMU_Rotation_X_degps;
volatile _Alignas(4) float IMU_Rotation_Y_degps;
volatile _Alignas(4) float IMU_Rotation_Z_degps;
} fs_ai_api_imu;
#endif


int fs_ai_api_init(char *CAN_interface, int debug, int simulate);

void fs_ai_api_vcu2ai_get_data(fs_ai_api_vcu2ai *data);
void fs_ai_api_ai2vcu_set_data(fs_ai_api_ai2vcu *data);

void fs_ai_api_imu_get_data(fs_ai_api_imu *data);
void fs_ai_api_gps_get_data(fs_ai_api_gps *data);


#ifdef __cplusplus
}
Expand Down
Loading

0 comments on commit afdda52

Please sign in to comment.