Skip to content

Commit

Permalink
Some fixes after testing the code
Browse files Browse the repository at this point in the history
  • Loading branch information
avtoku committed Nov 14, 2024
1 parent 5cdb03b commit 2e3b696
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 14 deletions.
2 changes: 1 addition & 1 deletion boards/varmint_h7
4 changes: 3 additions & 1 deletion comms/mavlink/mavlink.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -269,8 +269,10 @@ void Mavlink::send_command_ack(uint8_t system_id, uint64_t timestamp_us,

void Mavlink::send_diff_pressure(uint8_t system_id, const PressureStruct & p)
{

float ias = (p.pressure<0.0?-1.0:1.0)*sqrt(fabs(p.pressure) / (0.5 * 1.225));
mavlink_message_t msg;
mavlink_msg_diff_pressure_pack(system_id, compid_, &msg, sqrt(p.pressure / (0.5 * 1.225)),
mavlink_msg_diff_pressure_pack(system_id, compid_, &msg, ias,
p.pressure, p.temperature);
send_message(msg);
}
Expand Down
1 change: 0 additions & 1 deletion include/board.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ class Board

// IMU
virtual bool imu_read(rosflight_firmware::ImuStruct * imu) = 0;
virtual void imu_not_responding_error() = 0;

// Mag
virtual bool mag_read(rosflight_firmware::MagStruct * mag) = 0;
Expand Down
10 changes: 7 additions & 3 deletions include/mixer.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
#include <cstdbool>
#include <cstdint>

#include <sensors.h>

namespace rosflight_firmware
{
class ROSflight;
Expand All @@ -47,7 +49,6 @@ class Mixer : public ParamListenerInterface
public:
static constexpr uint8_t NUM_TOTAL_OUTPUTS = 14;
static constexpr uint8_t NUM_MIXER_OUTPUTS = 10;
float * raw_outputs(void);

enum
{
Expand Down Expand Up @@ -102,7 +103,9 @@ class Mixer : public ParamListenerInterface
private:
ROSflight & RF_;

float raw_outputs_[NUM_TOTAL_OUTPUTS];
RcStruct output_raw_ = {};
//float raw_outputs_[NUM_TOTAL_OUTPUTS];
float *raw_outputs_ = output_raw_.chan;
float outputs_[NUM_TOTAL_OUTPUTS];
aux_command_t aux_command_;
output_type_t combined_output_type_[NUM_TOTAL_OUTPUTS];
Expand Down Expand Up @@ -258,7 +261,8 @@ class Mixer : public ParamListenerInterface
void mix_output();
void param_change_callback(uint16_t param_id) override;
void set_new_aux_command(aux_command_t new_aux_command);
inline const float * get_outputs() const { return raw_outputs_; }
float * raw_outputs() { return raw_outputs_; }
RcStruct * get_output_raw(void) { return &output_raw_; }
};

} // namespace rosflight_firmware
Expand Down
6 changes: 2 additions & 4 deletions include/sensors.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ typedef struct //__attribute__((packed))
float temperature; // K
} MagStruct;

#define RC_STRUCT_CHANNELS \
24 // 16 analog + 8 digital MUST BE > 14 (Mavlink message size is hardware to 14)
// 16 analog + 8 digital MUST BE > 14 (Mavlink message size is hardware to 14)
#define RC_STRUCT_CHANNELS 24
typedef struct //__attribute__((packed))
{
uint64_t timestamp; // us, time of data read complete
Expand Down Expand Up @@ -194,7 +194,6 @@ class Sensors : public ParamListenerInterface
RangeStruct * get_sonar(void) { return &sonar_; }
ImuStruct * get_imu(void) { return &imu_; }
BatteryStruct * get_battery(void) { return &battery_; }
RcStruct * get_output_raw(void) { return &output_raw_; }
RcStruct * get_rc_(void) { return &rc_; }
MagStruct * get_mag(void) { return &mag_; }
GnssStruct * get_gnss(void) { return &gnss_; }
Expand All @@ -221,7 +220,6 @@ class Sensors : public ParamListenerInterface
RangeStruct sonar_ = {};
ImuStruct imu_ = {};
BatteryStruct battery_ = {};
RcStruct output_raw_ = {};
RcStruct rc_ = {};
MagStruct mag_ = {};
GnssStruct gnss_ = {};
Expand Down
4 changes: 2 additions & 2 deletions src/comm_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ void CommManager::send_imu(void) { comm_link_.send_imu(sysid_, *RF_.sensors_.get

void CommManager::send_output_raw(void)
{
comm_link_.send_output_raw(sysid_, *RF_.sensors_.get_output_raw());
comm_link_.send_output_raw(sysid_, *RF_.mixer_.get_output_raw());
}

void CommManager::send_rc_raw(void) { comm_link_.send_rc_raw(sysid_, *RF_.sensors_.get_rc_()); }
Expand All @@ -192,7 +192,7 @@ void CommManager::send_diff_pressure(void)

void CommManager::send_baro(void)
{
comm_link_.send_diff_pressure(sysid_, *RF_.sensors_.get_baro());
comm_link_.send_baro(sysid_, *RF_.sensors_.get_baro());
}

void CommManager::send_sonar(void) { comm_link_.send_sonar(sysid_, *RF_.sensors_.get_sonar()); }
Expand Down
2 changes: 0 additions & 2 deletions src/mixer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ Mixer::Mixer(ROSflight & _rf)

void Mixer::init() { init_mixing(); }

float * Mixer::raw_outputs(void) { return raw_outputs_; }

void Mixer::param_change_callback(uint16_t param_id)
{
switch (param_id) {
Expand Down

0 comments on commit 2e3b696

Please sign in to comment.