Skip to content

Commit 13e43a9

Browse files
James-Wade1JMoore5353
authored andcommitted
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 24d074a commit 13e43a9

File tree

5 files changed

+16
-22
lines changed

5 files changed

+16
-22
lines changed

comms/mavlink/mavlink.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ void Mavlink::send_sonar(uint8_t system_id,
260260
send_message(msg);
261261
}
262262

263-
void Mavlink::send_status(uint8_t system_id, bool armed, bool failsafe, bool rc_override,
263+
void Mavlink::send_status(uint8_t system_id, bool armed, bool failsafe, uint8_t rc_override,
264264
bool offboard, uint8_t error_code, uint8_t control_mode,
265265
int16_t num_errors, int16_t loop_time_us)
266266
{

comms/mavlink/mavlink.h

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

include/comm_link.h

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

include/command_manager.h

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -161,16 +161,15 @@ class CommandManager : public ParamListenerInterface
161161
ROSflight & RF_;
162162

163163
bool new_command_;
164-
bool rc_throttle_override_;
165-
bool rc_attitude_override_;
164+
uint8_t rc_override_;
166165

167166
control_t & failsafe_command_;
168167

169168
void param_change_callback(uint16_t param_id) override;
170169
void init_failsafe();
171170

172-
bool do_roll_pitch_yaw_muxing(MuxChannel channel);
173-
bool do_throttle_muxing(void);
171+
uint8_t do_roll_pitch_yaw_muxing(MuxChannel channel);
172+
uint8_t do_throttle_muxing(void);
174173
void do_min_throttle_muxing();
175174

176175
void interpret_rc(void);
@@ -180,9 +179,7 @@ class CommandManager : public ParamListenerInterface
180179
CommandManager(ROSflight & _rf);
181180
void init();
182181
bool run();
183-
bool rc_override_active();
184-
bool rc_throttle_override_active();
185-
bool rc_attitude_override_active();
182+
uint8_t rc_override_active();
186183
bool offboard_control_active();
187184
void set_new_offboard_command(control_t new_offboard_command);
188185
void set_new_rc_command(control_t new_rc_command);

src/command_manager.cpp

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ bool CommandManager::stick_deviated(MuxChannel channel)
212212
}
213213
}
214214

215-
bool CommandManager::do_roll_pitch_yaw_muxing(MuxChannel channel)
215+
uint8_t CommandManager::do_roll_pitch_yaw_muxing(MuxChannel channel)
216216
{
217217
bool override_this_channel = false;
218218
// Check if the override switch exists and is triggered, or if the sticks have deviated enough to
@@ -229,10 +229,11 @@ bool CommandManager::do_roll_pitch_yaw_muxing(MuxChannel channel)
229229
}
230230
// set the combined channel output depending on whether RC is overriding for this channel or not
231231
*muxes[channel].combined = override_this_channel ? *muxes[channel].rc : *muxes[channel].onboard;
232-
return override_this_channel;
232+
if (override_this_channel) return 1U;
233+
else return 0;
233234
}
234235

235-
bool CommandManager::do_throttle_muxing(void)
236+
uint8_t CommandManager::do_throttle_muxing(void)
236237
{
237238
bool override_this_channel = false;
238239
MuxChannel selected_channel;
@@ -285,11 +286,7 @@ bool CommandManager::do_throttle_muxing(void)
285286
return override_this_channel;
286287
}
287288

288-
bool CommandManager::rc_override_active() { return rc_throttle_override_ || rc_attitude_override_; }
289-
290-
bool CommandManager::rc_throttle_override_active() { return rc_throttle_override_; }
291-
292-
bool CommandManager::rc_attitude_override_active() { return rc_attitude_override_; }
289+
uint8_t CommandManager::rc_override_active() { return rc_override_; }
293290

294291
bool CommandManager::offboard_control_active()
295292
{
@@ -341,10 +338,10 @@ bool CommandManager::run()
341338
}
342339

343340
// Perform muxing
344-
rc_attitude_override_ = do_roll_pitch_yaw_muxing(MUX_QX);
345-
rc_attitude_override_ |= do_roll_pitch_yaw_muxing(MUX_QY);
346-
rc_attitude_override_ |= do_roll_pitch_yaw_muxing(MUX_QZ);
347-
rc_throttle_override_ = do_throttle_muxing();
341+
rc_override_ = do_roll_pitch_yaw_muxing(MUX_QX);
342+
rc_override_ |= do_roll_pitch_yaw_muxing(MUX_QY);
343+
rc_override_ |= do_roll_pitch_yaw_muxing(MUX_QZ);
344+
rc_override_ += 2U*do_throttle_muxing();
348345

349346
// Light to indicate override
350347
if (rc_override_active()) {

0 commit comments

Comments
 (0)