Skip to content

Commit 71ca9f6

Browse files
feat: change command message to vector from named force-torque values
* Initial changes to mavlink and other message handling * Updated mixer.h and mixer.cpp to have mixers be 10 by 10 * Added params for new larger mixers * Fixed array initialization, created new mixers, made all files look for u[i] instead of fx, etc * cleanup: remove comments and consolidate with some for loops * feat: switch default ordering of command vector to be [forces, torques] to match mixers * fix bugs detected by copilot --------- Co-authored-by: M1tchM355 <mitchell.messerly@gmail.com>
1 parent 2da05c1 commit 71ca9f6

19 files changed

+789
-770
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.Qx.value = ctrl.Qx;
468-
control.Qy.value = ctrl.Qy;
469-
control.Qz.value = ctrl.Qz;
470-
control.Fx.value = ctrl.Fx;
471-
control.Fy.value = ctrl.Fy;
472-
control.Fz.value = ctrl.Fz;
473-
474-
control.Qx.valid = !(ctrl.ignore & IGNORE_VALUE1);
475-
control.Qy.valid = !(ctrl.ignore & IGNORE_VALUE2);
476-
control.Qz.valid = !(ctrl.ignore & IGNORE_VALUE3);
477-
control.Fx.valid = !(ctrl.ignore & IGNORE_VALUE4);
478-
control.Fy.valid = !(ctrl.ignore & IGNORE_VALUE5);
479-
control.Fz.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: 24 additions & 17 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"/>
@@ -196,15 +208,10 @@ See the generating_v1.0_instructions.txt to regenerate mavlink headers based off
196208

197209
<messages>
198210
<message id="180" name="OFFBOARD_CONTROL">
199-
<description>Offboard Control (6-DOF)</description>
211+
<description>Offboard Control (10-DOF)</description>
200212
<field type="uint8_t" name="mode" enum="OFFBOARD_CONTROL_MODE">Offboard control mode, see OFFBOARD_CONTROL_MODE</field>
201-
<field type="uint8_t" name="ignore" enum="OFFBOARD_CONTROL_IGNORE">Bitfield specifying which fields should be ignored, see OFFBOARD_CONTROL_IGNORE</field>
202-
<field type="float" name="Qx">Qx control channel interpreted according to mode</field>
203-
<field type="float" name="Qy">Qy control channel, interpreted according to mode</field>
204-
<field type="float" name="Qz">Qz control channel, interpreted according to mode</field>
205-
<field type="float" name="Fx">Fx control channel interpreted according to mode</field>
206-
<field type="float" name="Fy">Fy control channel, interpreted according to mode</field>
207-
<field type="float" name="Fz">Fz control channel, interpreted according to mode</field>
213+
<field type="uint16_t" name="ignore" enum="OFFBOARD_CONTROL_IGNORE">Bitfield specifying which fields should be ignored, see OFFBOARD_CONTROL_IGNORE</field>
214+
<field type="float[10]" name="u">u control channel interpreted according to mode</field>
208215
</message>
209216
<message id="181" name="SMALL_IMU">
210217
<description>IMU data</description>
@@ -313,7 +320,7 @@ See the generating_v1.0_instructions.txt to regenerate mavlink headers based off
313320
<field type="float" name="battery_voltage"/> <!-- V -->
314321
<field type="float" name="battery_current"/> <!-- A -->
315322
</message>
316-
<!-- From Common -->
323+
<!-- From Common -->
317324
<message id="0" name="HEARTBEAT">
318325
<description>The heartbeat message shows that a system is present and responding. The type of the MAV and Autopilot hardware allow the receiving system to treat further messages from this system appropriate (e.g. by laying out the user interface based on the autopilot).</description>
319326
<field type="uint8_t" name="type">Type of the MAV (quadrotor, helicopter, etc., up to 15 types, defined in MAV_TYPE ENUM)</field>

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 1891770357406712603
9+
#define MAVLINK_PRIMARY_XML_HASH 2561919675776321086
1010

1111
#ifndef MAVLINK_STX
1212
#define MAVLINK_STX 254

0 commit comments

Comments
 (0)