Skip to content

Commit 69de494

Browse files
committed
Working on more verbose rc override messages. The necessary function prototypes, definitions, and rc_override type has been changed to allow uint8_t inputs rather than boolean.
1 parent f192818 commit 69de494

File tree

5 files changed

+15
-13
lines changed

5 files changed

+15
-13
lines changed

comms/mavlink/mavlink.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ void Mavlink::send_sonar(uint8_t system_id,
283283
send_message(msg);
284284
}
285285

286-
void Mavlink::send_status(uint8_t system_id, bool armed, bool failsafe, bool rc_override,
286+
void Mavlink::send_status(uint8_t system_id, bool armed, bool failsafe, uint8_t rc_override,
287287
bool offboard, uint8_t error_code, uint8_t control_mode,
288288
int16_t num_errors, int16_t loop_time_us)
289289
{

comms/mavlink/mavlink.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ class Mavlink : public CommLinkInterface
8383
void send_sonar(uint8_t system_id,
8484
/* TODO enum type*/ uint8_t type, float range, float max_range,
8585
float min_range) override;
86-
void send_status(uint8_t system_id, bool armed, bool failsafe, bool rc_override, bool offboard,
86+
void send_status(uint8_t system_id, bool armed, bool failsafe, uint8_t rc_override, bool offboard,
8787
uint8_t error_code, uint8_t control_mode, int16_t num_errors,
8888
int16_t loop_time_us) override;
8989
void send_timesync(uint8_t system_id, int64_t tc1, int64_t ts1) override;

include/command_manager.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -138,15 +138,15 @@ class CommandManager : public ParamListenerInterface
138138
ROSflight & RF_;
139139

140140
bool new_command_;
141-
bool rc_override_;
141+
uint8_t rc_override_;
142142

143143
control_t & failsafe_command_;
144144

145145
void param_change_callback(uint16_t param_id) override;
146146
void init_failsafe();
147147

148-
bool do_roll_pitch_yaw_muxing(MuxChannel channel);
149-
bool do_throttle_muxing(void);
148+
uint8_t do_roll_pitch_yaw_muxing(MuxChannel channel);
149+
uint8_t do_throttle_muxing(void);
150150
void do_min_throttle_muxing();
151151

152152
void interpret_rc(void);
@@ -156,7 +156,7 @@ class CommandManager : public ParamListenerInterface
156156
CommandManager(ROSflight & _rf);
157157
void init();
158158
bool run();
159-
bool rc_override_active();
159+
uint8_t rc_override_active();
160160
bool offboard_control_active();
161161
void set_new_offboard_command(control_t new_offboard_command);
162162
void set_new_rc_command(control_t new_rc_command);

include/interface/comm_link.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ class CommLinkInterface
159159
virtual void send_sonar(uint8_t system_id,
160160
/* TODO enum type*/ uint8_t type, float range, float max_range,
161161
float min_range) = 0;
162-
virtual void send_status(uint8_t system_id, bool armed, bool failsafe, bool rc_override,
162+
virtual void send_status(uint8_t system_id, bool armed, bool failsafe, uint8_t rc_override,
163163
bool offboard, uint8_t error_code, uint8_t control_mode,
164164
int16_t num_errors, int16_t loop_time_us) = 0;
165165
virtual void send_timesync(uint8_t system_id, int64_t tc1, int64_t ts1) = 0;

src/command_manager.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ bool CommandManager::stick_deviated(MuxChannel channel)
167167
}
168168
}
169169

170-
bool CommandManager::do_roll_pitch_yaw_muxing(MuxChannel channel)
170+
uint8_t CommandManager::do_roll_pitch_yaw_muxing(MuxChannel channel)
171171
{
172172
bool override_this_channel = false;
173173
// Check if the override switch exists and is triggered, or if the sticks have deviated enough to
@@ -184,10 +184,11 @@ bool CommandManager::do_roll_pitch_yaw_muxing(MuxChannel channel)
184184
}
185185
// set the combined channel output depending on whether RC is overriding for this channel or not
186186
*muxes[channel].combined = override_this_channel ? *muxes[channel].rc : *muxes[channel].onboard;
187-
return override_this_channel;
187+
if (override_this_channel) return 1U;
188+
else return 0;
188189
}
189190

190-
bool CommandManager::do_throttle_muxing(void)
191+
uint8_t CommandManager::do_throttle_muxing(void)
191192
{
192193
bool override_this_channel = false;
193194
// Check if the override switch exists and is triggered
@@ -209,10 +210,11 @@ bool CommandManager::do_throttle_muxing(void)
209210

210211
// Set the combined channel output depending on whether RC is overriding for this channel or not
211212
*muxes[MUX_F].combined = override_this_channel ? *muxes[MUX_F].rc : *muxes[MUX_F].onboard;
212-
return override_this_channel;
213+
if (override_this_channel) return 1U;
214+
else return 0;
213215
}
214216

215-
bool CommandManager::rc_override_active() { return rc_override_; }
217+
uint8_t CommandManager::rc_override_active() { return rc_override_; }
216218

217219
bool CommandManager::offboard_control_active()
218220
{
@@ -265,7 +267,7 @@ bool CommandManager::run()
265267
rc_override_ = do_roll_pitch_yaw_muxing(MUX_X);
266268
rc_override_ |= do_roll_pitch_yaw_muxing(MUX_Y);
267269
rc_override_ |= do_roll_pitch_yaw_muxing(MUX_Z);
268-
rc_override_ |= do_throttle_muxing();
270+
rc_override_ += 2U*do_throttle_muxing();
269271

270272
// Light to indicate override
271273
if (rc_override_) {

0 commit comments

Comments
 (0)