Skip to content

Magnetic disturbance and flight mode on CAN, User Reset Command #57

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
May 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion NAV_Algorithms/data_structures.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ typedef struct
float integrator_vario;
float3vector wind;
float3vector wind_average;
uint32_t circle_mode;
uint32_t flight_mode;
quaternion<float> q;
eulerangle<float> euler;
float effective_vertical_acceleration;
Expand Down
6 changes: 5 additions & 1 deletion NAV_Algorithms/navigator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,11 @@ void navigator_t::report_data( output_data_t &d)
d.effective_vertical_acceleration
= variometer.get_effective_vertical_acceleration();

d.circle_mode = ahrs.get_circling_state();
if( airborne_detector.is_airborne())
d.flight_mode = ahrs.get_circling_state();
else
d.flight_mode = 3; // = ON_GROUND

d.turn_rate = ahrs.get_turn_rate();
d.slip_angle = ahrs.getSlipAngle();
d.pitch_angle = ahrs.getPitchAngle();
Expand Down
8 changes: 7 additions & 1 deletion Output_Formatter/CAN_output.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ enum CAN_ID_SENSOR
CAN_Id_SlipPitch = 0x128, //!< float slip angle from body-acc, float pitch angle from body-acc
CAN_Id_Voltage_Circle = 0x129, //!< float supply voltage, uint8_t circle-mode
CAN_Id_SystemState = 0x12a, //!< u32 system_state, u32 git_tag dec
CAN_Id_Sensor_Health = 0x12b, //!< float magnetic disturbance

CAN_Id_GPS_Date_Time = 0x140, //!< uint8_t year-2000, month, day, hour, mins, secs
CAN_Id_GPS_Lat = 0x141, //!< double latitude
Expand Down Expand Up @@ -121,7 +122,12 @@ void CAN_output ( const output_data_t &x, bool horizon_activated)
p.id=CAN_Id_Voltage_Circle;
p.dlc=5;
p.data_f[0] = x.m.supply_voltage;
p.data_b[4] = (uint8_t)(x.circle_mode);
p.data_b[4] = (uint8_t)(x.flight_mode);
CAN_send(p, 1);

p.id=CAN_Id_Sensor_Health;
p.dlc=4;
p.data_f[0] = x.magnetic_disturbance;
CAN_send(p, 1);

p.id=CAN_Id_GPS_Date_Time;
Expand Down
1 change: 1 addition & 0 deletions Output_Formatter/CAN_output.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
#define CMD_MEASURE_LEVEL 0x3002
#define CMD_CALCULATE 0x3003
#define CMD_TUNE 0x3004
#define CMD_RESET_SENSOR 0x3005

void CAN_output ( const output_data_t &x, bool horizon_activated);
void CAN_heartbeat( void);
Expand Down
4 changes: 3 additions & 1 deletion Output_Formatter/system_state.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ enum availability_bits
USB_OUTPUT_ACTIVE = 0x1000,
BLUEZ_OUTPUT_ACTIVE = 0x2000,
CAN_OUTPUT_ACTIVE = 0x4000,
USART_2_OUTPUT_ACTIVE = 0x8000
USART_2_OUTPUT_ACTIVE = 0x8000,

HORIZON_NOT_AVAILABLE = 0x10000
};

extern uint32_t system_state; //!< bits collected from availability_bits
Expand Down