Skip to content

Commit 320a465

Browse files
committed
cleanup: remove comments and consolidate with some for loops
1 parent 802a6c2 commit 320a465

File tree

11 files changed

+101
-139
lines changed

11 files changed

+101
-139
lines changed

comms/mavlink/mavlink.cpp

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#include "board.h"
3434

3535
#include <cstdint>
36+
#include <iterator>
3637

3738
namespace rosflight_firmware
3839
{
@@ -464,19 +465,21 @@ void Mavlink::handle_msg_offboard_control(const mavlink_message_t * const msg)
464465
return;
465466
}
466467

467-
control.u[0].value = ctrl.u[0];
468-
control.u[1].value = ctrl.u[1];
469-
control.u[2].value = ctrl.u[2];
470-
control.u[3].value = ctrl.u[3];
471-
control.u[4].value = ctrl.u[4];
472-
control.u[5].value = ctrl.u[5];
473-
474-
control.u[0].valid = !(ctrl.ignore & IGNORE_VALUE1);
475-
control.u[1].valid = !(ctrl.ignore & IGNORE_VALUE2);
476-
control.u[2].valid = !(ctrl.ignore & IGNORE_VALUE3);
477-
control.u[3].valid = !(ctrl.ignore & IGNORE_VALUE4);
478-
control.u[4].valid = !(ctrl.ignore & IGNORE_VALUE5);
479-
control.u[5].valid = !(ctrl.ignore & IGNORE_VALUE6);
468+
for (std::size_t i=0; i<std::size(ctrl.u); ++i)
469+
{
470+
control.u[i].value = ctrl.u[i];
471+
}
472+
473+
control.u[0].valid = !(ctrl.ignore & IGNORE_VALUE0);
474+
control.u[1].valid = !(ctrl.ignore & IGNORE_VALUE1);
475+
control.u[2].valid = !(ctrl.ignore & IGNORE_VALUE2);
476+
control.u[3].valid = !(ctrl.ignore & IGNORE_VALUE3);
477+
control.u[4].valid = !(ctrl.ignore & IGNORE_VALUE4);
478+
control.u[5].valid = !(ctrl.ignore & IGNORE_VALUE5);
479+
control.u[6].valid = !(ctrl.ignore & IGNORE_VALUE6);
480+
control.u[7].valid = !(ctrl.ignore & IGNORE_VALUE7);
481+
control.u[8].valid = !(ctrl.ignore & IGNORE_VALUE8);
482+
control.u[9].valid = !(ctrl.ignore & IGNORE_VALUE9);
480483

481484
if (listener_ != nullptr) { listener_->offboard_control_callback(control); }
482485
}

comms/mavlink/rosflight.xml

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,24 +53,36 @@ See the generating_v1.0_instructions.txt to regenerate mavlink headers based off
5353
<entry value="0x00" name="IGNORE_NONE">
5454
<description>Convenience value for specifying no fields should be ignored</description>
5555
</entry>
56-
<entry value="0x01" name="IGNORE_VALUE1">
56+
<entry value="0x01" name="IGNORE_VALUE0">
57+
<description>Field value0 should be ignored</description>
58+
</entry>
59+
<entry value="0x02" name="IGNORE_VALUE1">
5760
<description>Field value1 should be ignored</description>
5861
</entry>
59-
<entry value="0x02" name="IGNORE_VALUE2">
62+
<entry value="0x04" name="IGNORE_VALUE2">
6063
<description>Field value2 should be ignored</description>
6164
</entry>
62-
<entry value="0x04" name="IGNORE_VALUE3">
65+
<entry value="0x08" name="IGNORE_VALUE3">
6366
<description>Field value3 should be ignored</description>
6467
</entry>
65-
<entry value="0x08" name="IGNORE_VALUE4">
66-
<description>Field value4 should be ignored</description>
67-
</entry>
68-
<entry value="0x16" name="IGNORE_VALUE5">
68+
<entry value="0x10" name="IGNORE_VALUE4">
69+
<description>Field value4 should be ignored</description>
70+
</entry>
71+
<entry value="0x20" name="IGNORE_VALUE5">
6972
<description>Field value5 should be ignored</description>
7073
</entry>
71-
<entry value="0x32" name="IGNORE_VALUE6">
74+
<entry value="0x40" name="IGNORE_VALUE6">
7275
<description>Field value6 should be ignored</description>
7376
</entry>
77+
<entry value="0x80" name="IGNORE_VALUE7">
78+
<description>Field value7 should be ignored</description>
79+
</entry>
80+
<entry value="0x100" name="IGNORE_VALUE8">
81+
<description>Field value8 should be ignored</description>
82+
</entry>
83+
<entry value="0x200" name="IGNORE_VALUE9">
84+
<description>Field value9 should be ignored</description>
85+
</entry>
7486
</enum>
7587
<enum name="ROSFLIGHT_ERROR_CODE">
7688
<entry value="0x00" name="ROSFLIGHT_ERROR_NONE"/>

comms/mavlink/v1.0/rosflight/mavlink.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#ifndef MAVLINK_H
77
#define MAVLINK_H
88

9-
#define MAVLINK_PRIMARY_XML_HASH -8687897947424539972
9+
#define MAVLINK_PRIMARY_XML_HASH 4604780551857209085
1010

1111
#ifndef MAVLINK_STX
1212
#define MAVLINK_STX 254

comms/mavlink/v1.0/rosflight/rosflight.h

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#error Wrong include order: MAVLINK_ROSFLIGHT.H MUST NOT BE DIRECTLY USED. Include mavlink.h from the same directory instead or set ALL AND EVERY defines from MAVLINK.H manually accordingly, including the #define MAVLINK_H call.
1111
#endif
1212

13-
#define MAVLINK_ROSFLIGHT_XML_HASH -8687897947424539972
13+
#define MAVLINK_ROSFLIGHT_XML_HASH 4604780551857209085
1414

1515
#ifdef __cplusplus
1616
extern "C" {
@@ -19,11 +19,11 @@ extern "C" {
1919
// MESSAGE LENGTHS AND CRCS
2020

2121
#ifndef MAVLINK_MESSAGE_LENGTHS
22-
#define MAVLINK_MESSAGE_LENGTHS {9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 2, 25, 23, 0, 0, 0, 0, 0, 0, 0, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 42, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 214, 159, 220, 168, 0, 0, 0, 0, 0, 0, 0, 246, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 118, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 34, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 209, 67, 218, 206, 169, 0, 0, 60, 249, 113, 181, 12, 134, 1, 0, 65, 10, 221, 0, 48, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 83, 0, 0}
2727
#endif
2828

2929
#include "../protocol.h"
@@ -99,13 +99,17 @@ typedef enum OFFBOARD_CONTROL_MODE
9999
typedef enum OFFBOARD_CONTROL_IGNORE
100100
{
101101
IGNORE_NONE=0, /* Convenience value for specifying no fields should be ignored | */
102-
IGNORE_VALUE1=1, /* Field value1 should be ignored | */
103-
IGNORE_VALUE2=2, /* Field value2 should be ignored | */
104-
IGNORE_VALUE3=4, /* Field value3 should be ignored | */
105-
IGNORE_VALUE4=8, /* Field value4 should be ignored | */
106-
IGNORE_VALUE5=22, /* Field value5 should be ignored | */
107-
IGNORE_VALUE6=50, /* Field value6 should be ignored | */
108-
OFFBOARD_CONTROL_IGNORE_ENUM_END=51, /* | */
102+
IGNORE_VALUE0=1, /* Field value0 should be ignored | */
103+
IGNORE_VALUE1=2, /* Field value1 should be ignored | */
104+
IGNORE_VALUE2=4, /* Field value2 should be ignored | */
105+
IGNORE_VALUE3=8, /* Field value3 should be ignored | */
106+
IGNORE_VALUE4=16, /* Field value4 should be ignored | */
107+
IGNORE_VALUE5=32, /* Field value5 should be ignored | */
108+
IGNORE_VALUE6=64, /* Field value6 should be ignored | */
109+
IGNORE_VALUE7=128, /* Field value7 should be ignored | */
110+
IGNORE_VALUE8=256, /* Field value8 should be ignored | */
111+
IGNORE_VALUE9=512, /* Field value9 should be ignored | */
112+
OFFBOARD_CONTROL_IGNORE_ENUM_END=513, /* | */
109113
} OFFBOARD_CONTROL_IGNORE;
110114
#endif
111115

comms/mavlink/v1.0/rosflight/version.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#ifndef MAVLINK_VERSION_H
88
#define MAVLINK_VERSION_H
99

10-
#define MAVLINK_BUILD_DATE "Wed Nov 12 2025"
10+
#define MAVLINK_BUILD_DATE "Fri Jan 23 2026"
1111
#define MAVLINK_WIRE_PROTOCOL_VERSION "1.0"
1212
#define MAVLINK_MAX_DIALECT_PAYLOAD_SIZE 70
1313

include/comm_link.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ class CommLinkInterface
8484
};
8585

8686
Mode mode;
87-
Channel u[10]; // Qx, Qy, Qz, Fx, Fy, Fz, aux1, aux2, aux3, aux4
87+
Channel u[10]; // Interpreted according to mode
8888
};
8989

9090
struct AuxCommand
@@ -156,7 +156,7 @@ class CommLinkInterface
156156
int16_t num_errors, int16_t loop_time_us) = 0;
157157
virtual void send_timesync(uint8_t system_id, int64_t tc1, int64_t ts1) = 0;
158158
virtual void send_version(uint8_t system_id, const char * const version) = 0;
159-
virtual void send_gnss(uint8_t system_id, GnssStruct *data) = 0;
159+
virtual void send_gnss(uint8_t system_id, GnssStruct * data) = 0;
160160
virtual void send_error_data(uint8_t system_id, const StateManager::BackupData & error_data) = 0;
161161
virtual void send_battery_status(uint8_t system_id, float voltage, float current) = 0;
162162

include/comm_manager.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ class CommManager : public CommLinkInterface::ListenerInterface, public ParamLis
8181
uint64_t offboard_control_time_;
8282
ROSflight & RF_;
8383
CommLinkInterface & comm_link_;
84-
uint8_t send_params_index_;
84+
uint16_t send_params_index_;
8585
bool initialized_ = false;
8686
bool connected_ = false;
8787

include/command_manager.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ typedef enum
6868
typedef struct
6969
{
7070
uint32_t stamp_ms;
71-
control_channel_t u[10]; // Control channels, first 6 are hard coded to be Qx, Qy, Qz, Fx, Fy, Fz
71+
control_channel_t u[10]; // Control channels, interpreted according to mode/mixer
7272
} control_t;
7373

7474
class CommandManager : public ParamListenerInterface
@@ -102,12 +102,12 @@ class CommandManager : public ParamListenerInterface
102102
control_channel_t * combined;
103103
} mux_t;
104104

105-
mux_t muxes[6] = {{&rc_command_.u[0], &offboard_command_.u[0], &combined_command_.u[0]}, // Qx
106-
{&rc_command_.u[1], &offboard_command_.u[1], &combined_command_.u[1]}, // Qy
107-
{&rc_command_.u[2], &offboard_command_.u[2], &combined_command_.u[2]}, // Qz
108-
{&rc_command_.u[3], &offboard_command_.u[3], &combined_command_.u[3]}, // Fx
109-
{&rc_command_.u[4], &offboard_command_.u[4], &combined_command_.u[4]}, // Fy
110-
{&rc_command_.u[5], &offboard_command_.u[5], &combined_command_.u[5]}}; // Fz
105+
mux_t muxes_[6] = {{&rc_command_.u[0], &offboard_command_.u[0], &combined_command_.u[0]},
106+
{&rc_command_.u[1], &offboard_command_.u[1], &combined_command_.u[1]},
107+
{&rc_command_.u[2], &offboard_command_.u[2], &combined_command_.u[2]},
108+
{&rc_command_.u[3], &offboard_command_.u[3], &combined_command_.u[3]},
109+
{&rc_command_.u[4], &offboard_command_.u[4], &combined_command_.u[4]},
110+
{&rc_command_.u[5], &offboard_command_.u[5], &combined_command_.u[5]}};
111111

112112
// clang-format off
113113
control_t rc_command_ = {0,

src/comm_manager.cpp

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737

3838
#include <cstdint>
3939
#include <cstring>
40+
#include <iterator>
4041

4142
namespace rosflight_firmware
4243
{
@@ -232,24 +233,18 @@ void CommManager::timesync_callback(int64_t tc1, int64_t ts1)
232233

233234
void CommManager::offboard_control_callback(const CommLinkInterface::OffboardControl & control)
234235
{
235-
// put values into a new command struct
236+
// put values and flags into a new command struct
236237
control_t new_offboard_command;
237-
new_offboard_command.u[0].value = control.u[0].value;
238-
new_offboard_command.u[1].value = control.u[1].value;
239-
new_offboard_command.u[2].value = control.u[2].value;
240-
new_offboard_command.u[3].value = control.u[3].value;
241-
new_offboard_command.u[4].value = control.u[4].value;
242-
new_offboard_command.u[5].value = control.u[5].value;
243-
244-
// Move flags into standard message
245-
new_offboard_command.u[0].active = control.u[0].valid;
246-
new_offboard_command.u[1].active = control.u[1].valid;
247-
new_offboard_command.u[2].active = control.u[2].valid;
248-
new_offboard_command.u[3].active = control.u[3].valid;
249-
new_offboard_command.u[4].active = control.u[4].valid;
250-
new_offboard_command.u[5].active = control.u[5].valid;
238+
for (std::size_t i=0; i<std::size(control.u); ++i)
239+
{
240+
new_offboard_command.u[i].value = control.u[i].value;
241+
new_offboard_command.u[i].active = control.u[i].valid;
242+
243+
}
251244

252245
// translate modes into standard message
246+
// TODO: Need to standardize which channels are interpreted as what when using modes
247+
// other than the passthrough mode... We should set all unused channels to passthrough?
253248
switch (control.mode) {
254249
case CommLinkInterface::OffboardControl::Mode::PASS_THROUGH:
255250
new_offboard_command.u[0].type = PASSTHROUGH;
@@ -258,6 +253,10 @@ void CommManager::offboard_control_callback(const CommLinkInterface::OffboardCon
258253
new_offboard_command.u[3].type = PASSTHROUGH;
259254
new_offboard_command.u[4].type = PASSTHROUGH;
260255
new_offboard_command.u[5].type = PASSTHROUGH;
256+
new_offboard_command.u[6].type = PASSTHROUGH;
257+
new_offboard_command.u[7].type = PASSTHROUGH;
258+
new_offboard_command.u[8].type = PASSTHROUGH;
259+
new_offboard_command.u[9].type = PASSTHROUGH;
261260
break;
262261
case CommLinkInterface::OffboardControl::Mode::ROLLRATE_PITCHRATE_YAWRATE_THROTTLE:
263262
new_offboard_command.u[0].type = RATE;
@@ -266,6 +265,10 @@ void CommManager::offboard_control_callback(const CommLinkInterface::OffboardCon
266265
new_offboard_command.u[3].type = THROTTLE;
267266
new_offboard_command.u[4].type = THROTTLE;
268267
new_offboard_command.u[5].type = THROTTLE;
268+
new_offboard_command.u[6].type = PASSTHROUGH;
269+
new_offboard_command.u[7].type = PASSTHROUGH;
270+
new_offboard_command.u[8].type = PASSTHROUGH;
271+
new_offboard_command.u[9].type = PASSTHROUGH;
269272
break;
270273
case CommLinkInterface::OffboardControl::Mode::ROLL_PITCH_YAWRATE_THROTTLE:
271274
new_offboard_command.u[0].type = ANGLE;
@@ -274,6 +277,10 @@ void CommManager::offboard_control_callback(const CommLinkInterface::OffboardCon
274277
new_offboard_command.u[3].type = THROTTLE;
275278
new_offboard_command.u[4].type = THROTTLE;
276279
new_offboard_command.u[5].type = THROTTLE;
280+
new_offboard_command.u[6].type = PASSTHROUGH;
281+
new_offboard_command.u[7].type = PASSTHROUGH;
282+
new_offboard_command.u[8].type = PASSTHROUGH;
283+
new_offboard_command.u[9].type = PASSTHROUGH;
277284
break;
278285
}
279286

@@ -363,6 +370,8 @@ void CommManager::send_status(void)
363370

364371
uint8_t control_mode = 0;
365372
if (RF_.params_.get_param_int(PARAM_FIXED_WING)
373+
// TODO: This works, since the first value in the control vector is interpreted as the attitude
374+
// commands (previously the Qx field). It feels a bit fragile... Is there a more robust way to do this?
366375
|| RF_.command_manager_.combined_control().u[0].type == PASSTHROUGH) {
367376
control_mode = MODE_PASS_THROUGH;
368377
} else if (RF_.command_manager_.combined_control().u[0].type == ANGLE) {
@@ -515,7 +524,7 @@ void CommManager::stream(got_flags got)
515524
void CommManager::send_next_param(void)
516525
{
517526
if (send_params_index_ < PARAMS_COUNT) {
518-
send_param_value(static_cast<uint16_t>(send_params_index_));
527+
send_param_value(send_params_index_);
519528
send_params_index_++;
520529
}
521530
}

src/command_manager.cpp

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -108,30 +108,22 @@ void CommandManager::interpret_rc(void)
108108
rc_command_.u[2].value = RF_.rc_.stick(RC::STICK_Z);
109109

110110
// Load the RC command based on the axis associated with the RC F command
111-
rc_command_.Fx.value = 0.0;
112-
rc_command_.Fy.value = 0.0;
113-
rc_command_.Fz.value = 0.0;
111+
rc_command_.u[3].value = 0.0;
112+
rc_command_.u[4].value = 0.0;
113+
rc_command_.u[5].value = 0.0;
114114
switch (static_cast<rc_f_axis_t>(RF_.params_.get_param_int(PARAM_RC_F_AXIS))) {
115115
case X_AXIS: // RC F = X axis
116116
rc_command_.u[3].value = RF_.rc_.stick(RC::STICK_F);
117-
rc_command_.u[4].value = 0.0;
118-
rc_command_.u[5].value = 0.0;
119117
break;
120118
case Y_AXIS: // RC F = Y axis
121-
rc_command_.u[3].value = 0.0;
122119
rc_command_.u[4].value = RF_.rc_.stick(RC::STICK_F);
123-
rc_command_.u[5].value = 0.0;
124120
break;
125121
case Z_AXIS:
126-
rc_command_.u[3].value = 0.0;
127-
rc_command_.u[4].value = 0.0;
128122
rc_command_.u[5].value = RF_.rc_.stick(RC::STICK_F);
129123
break;
130124
default:
131125
RF_.comm_manager_.log(CommLinkInterface::LogSeverity::LOG_WARNING,
132126
"Invalid RC F axis. Defaulting to z-axis.");
133-
rc_command_.u[3].value = 0.0;
134-
rc_command_.u[4].value = 0.0;
135127
rc_command_.u[5].value = RF_.rc_.stick(RC::STICK_F);
136128
break;
137129
}

0 commit comments

Comments
 (0)