Skip to content

Commit

Permalink
reformat
Browse files Browse the repository at this point in the history
  • Loading branch information
avtoku committed Nov 22, 2024
1 parent 1acbde0 commit 7286be5
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 36 deletions.
55 changes: 23 additions & 32 deletions comm_link.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,8 @@ namespace rosflight_firmware
{
class CommLinkInterface
{
#define cast_in_range(val, type) \
(static_cast<uint32_t>(val) < static_cast<uint32_t>(type::END)) ? static_cast<type>(val) \
: type::END
#define cast_in_range(val, type) \
(static_cast<uint32_t>(val) < static_cast<uint32_t>(type::END)) ? static_cast<type>(val) : type::END

public:
enum class LogSeverity
Expand Down Expand Up @@ -93,17 +92,14 @@ class CommLinkInterface

enum class OffboardControlMode // c.f., MAVlink OFFBOARD_CONTROL_MODE
{
MODE_PASS_THROUGH = 0, /* Pass commanded values directly to actuators | */
MODE_ROLLRATE_PITCHRATE_YAWRATE_THROTTLE =
1, /* Command roll rate, pitch rate, yaw rate, and throttle | */
MODE_ROLL_PITCH_YAWRATE_THROTTLE =
2, /* Command roll angle, pitch angle, yaw rate, and throttle | */
MODE_ROLL_PITCH_YAWRATE_ALTITUDE =
3, /* Command roll angle, pitch angle, yaw rate, and altitude above ground | */
MODE_PASS_THROUGH = 0, /* Pass commanded values directly to actuators | */
MODE_ROLLRATE_PITCHRATE_YAWRATE_THROTTLE = 1, /* Command roll rate, pitch rate, yaw rate, and throttle | */
MODE_ROLL_PITCH_YAWRATE_THROTTLE = 2, /* Command roll angle, pitch angle, yaw rate, and throttle | */
MODE_ROLL_PITCH_YAWRATE_ALTITUDE = 3, /* Command roll angle, pitch angle, yaw rate, and altitude above ground | */
MODE_XVEL_YVEL_YAWRATE_ALTITUDE =
4, /* Command body-fixed, x and y velocity, and yaw rate, and altitude above ground | */
MODE_XPOS_YPOS_YAW_ALTITUDE =
5, /* Command inertial x, y position (m) wrt origin, yaw angle wrt north, and altitude above ground | */
5, /* Command inertial x, y position (m) wrt origin, yaw angle wrt north, and altitude above ground | */
END = 6, /* | */
};

Expand Down Expand Up @@ -196,49 +192,44 @@ class CommLinkInterface

virtual void send_baro(uint8_t system_id, const PressureStruct & baro) = 0;

virtual void send_command_ack(uint8_t system_id, uint64_t timestamp_us,
CommMessageCommand command, RosflightCmdResponse success) = 0;
virtual void send_command_ack(uint8_t system_id, uint64_t timestamp_us, CommMessageCommand command,
RosflightCmdResponse success) = 0;

virtual void send_diff_pressure(uint8_t system_id, const PressureStruct & p) = 0;

virtual void send_heartbeat(uint8_t system_id, uint64_t timestamp_us, bool fixed_wing) = 0;

virtual void send_imu(uint8_t system_id, const ImuStruct & imu) = 0;

virtual void send_log_message(uint8_t system_id, uint64_t timestamp_us, LogSeverity severity,
const char * text) = 0;
virtual void send_log_message(uint8_t system_id, uint64_t timestamp_us, LogSeverity severity, const char * text) = 0;

virtual void send_mag(uint8_t system_id, const MagStruct & mag) = 0;

virtual void send_named_value_int(uint8_t system_id, uint64_t timestamp_us,
const char * const name, int32_t value) = 0;
virtual void send_named_value_int(uint8_t system_id, uint64_t timestamp_us, const char * const name,
int32_t value) = 0;

virtual void send_named_value_float(uint8_t system_id, uint64_t timestamp_us,
const char * const name, float value) = 0;
virtual void send_named_value_float(uint8_t system_id, uint64_t timestamp_us, const char * const name,
float value) = 0;

virtual void send_output_raw(uint8_t system_id, const RcStruct & rc) = 0;

virtual void send_param_value_int(uint8_t system_id, uint64_t timestamp_us, uint16_t index,
const char * const name, int32_t value,
uint16_t param_count) = 0;
virtual void send_param_value_int(uint8_t system_id, uint64_t timestamp_us, uint16_t index, const char * const name,
int32_t value, uint16_t param_count) = 0;

virtual void send_param_value_float(uint8_t system_id, uint64_t timestamp_us, uint16_t index,
const char * const name, float value,
uint16_t param_count) = 0;
virtual void send_param_value_float(uint8_t system_id, uint64_t timestamp_us, uint16_t index, const char * const name,
float value, uint16_t param_count) = 0;

virtual void send_rc_raw(uint8_t system_id, const RcStruct & rc_raw) = 0;

virtual void send_sonar(uint8_t system_id, const RangeStruct & range) = 0;

virtual void send_status(uint8_t system_id, uint64_t timestamp_us, bool armed, bool failsafe,
bool rc_override, bool offboard, uint8_t error_code,
uint8_t control_mode, int16_t num_errors, int16_t loop_time_us) = 0;
virtual void send_status(uint8_t system_id, uint64_t timestamp_us, bool armed, bool failsafe, bool rc_override,
bool offboard, uint8_t error_code, uint8_t control_mode, int16_t num_errors,
int16_t loop_time_us) = 0;

virtual void send_timesync(uint8_t system_id, uint64_t timestamp_us, int64_t tc1,
int64_t ts1) = 0;
virtual void send_timesync(uint8_t system_id, uint64_t timestamp_us, int64_t tc1, int64_t ts1) = 0;

virtual void send_version(uint8_t system_id, uint64_t timestamp_us,
const char * const version) = 0;
virtual void send_version(uint8_t system_id, uint64_t timestamp_us, const char * const version) = 0;

virtual void send_gnss(uint8_t system_id, const GnssStruct & gnss) = 0;

Expand Down
6 changes: 2 additions & 4 deletions rosflight_structs.h
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ typedef struct
} got_flags;

// 16 analog + 8 digital MUST BE > 14 (Mavlink message size is hardware to 14)
#define RC_STRUCT_CHANNELS 24
#define RC_STRUCT_CHANNELS 24
typedef struct //__attribute__((packed))
{
uint64_t timestamp; // us, time of data read complete
Expand All @@ -175,15 +175,13 @@ typedef struct //__attribute__((packed))
bool failsafeActivated;
} RcStruct;


typedef struct //__attribute__((__packed__))
{
uint64_t timestamp; // us, time of data read complete
float q[4]; // quaternions
float rate[3];
} AttitudeStruct;

}

} // namespace rosflight_firmware

#endif /* INCLUDE_INTERFACE_ROSFLIGHT_STRUCTS_H_ */

0 comments on commit 7286be5

Please sign in to comment.