Skip to content

Commit 85fd44c

Browse files
authored
Merge pull request #471 from rosflight/better_rc_override
Change rc_override to enum for more verbose RC override
2 parents 24d074a + 451fd9d commit 85fd44c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+378
-255
lines changed

comms/mavlink/generating_v1.0_instructions.txt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
# get the mavlink/mavlink repository
2-
# git clone https://github.com/rosflight/mavlink.git
3-
git clone https://github.com/mavlink/mavlink.git
2+
git clone https://github.com/mavlink/mavlink.git --recursive
43

54
# Go to your rosflight_firmware/comms/mavlink folder
65
# Put the rosflight.xml file there if not already there
76

87
# Create the .c/h files from that directory
98
# If python3 doesn't work try installing future (pip install future).
10-
# If that doesn't work install Python2.7 and run with python2.7 instead.
9+
# If that doesn't work install Python3.8 and run with python3.8 instead.
1110
# in windows:
1211
rmdir /s v1.0
1312
set PYTHONPATH=%PYTHONPATH%;path\to\mavlink\repo && python3 -m pymavlink.tools.mavgen --lang=C --wire-protocol=1.0 --output=./v1.0 rosflight.xml

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, uint16_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, uint16_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;

comms/mavlink/rosflight.xml

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,6 @@
11
<?xml version="1.0"?>
22
<?note
3-
# get the mavlink/mavlink repository
4-
git clone https://github.com/rosflight/mavlink.git
5-
6-
# Go to your rosflight_firmware/comms/mavlink folder
7-
# Put the rosflight.xml file there if not already there
8-
9-
# Create the .c/h files from that directory
10-
# If python3 doesn't work try installing future (pip install future).
11-
# If that doesn't work install Python2.7 and run with python2.7 instead.
12-
# in windows:
13-
rmdir /s v1.0
14-
set PYTHONPATH=%PYTHONPATH%;path\to\mavlink\repo && python3 -m pymavlink.tools.mavgen --lang=C --wire-protocol=1.0 --output=./v1.0 rosflight.xml
15-
16-
# e.g.,
17-
rmdir /s v1.0
18-
set PYTHONPATH=%PYTHONPATH%;C:\Projects\mavlink && python3 -m pymavlink.tools.mavgen --lang=C --wire-protocol=1.0 --output=./v1.0 rosflight.xml
19-
20-
# in Linux:
21-
sudo rm -r ./v1.0
22-
PYTHONPATH=$PYTHONPATH:/path/to/mavlink/repo python3 -m pymavlink.tools.mavgen --lang=C --wire-protocol=1.0 --output=./v1.0 rosflight.xml
23-
24-
# If you are in the mavlink repo environment with rosflight.xml in the standard location:
25-
python3 -m pymavlink.tools.mavgen --lang=C --wire-protocol=1.0 --output=generated/include/mavlink/v1.0 message_definitions/v1.0/rosflight.xml
26-
# copy/paste the v1.0 directory into your rosflight_firmware/comms/mavlink folder
3+
See the generating_v1.0_instructions.txt to regenerate mavlink headers based off this file.
274
?>
285
<mavlink>
296
<enums>
@@ -283,7 +260,7 @@ python3 -m pymavlink.tools.mavgen --lang=C --wire-protocol=1.0 --output=generate
283260
<description>Flight Status</description>
284261
<field type="uint8_t" name="armed"/>
285262
<field type="uint8_t" name="failsafe"/>
286-
<field type="uint8_t" name="rc_override"/>
263+
<field type="uint16_t" name="rc_override"/>
287264
<field type="uint8_t" name="offboard"/>
288265
<field type="uint8_t" name="error_code" enum="ROSFLIGHT_ERROR_CODE"/>
289266
<field type="uint8_t" name="control_mode" enum="OFFBOARD_CONTROL_MODE"/>

comms/mavlink/v1.0/protocol.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,14 @@
3434
#define MAVLINK_END_UART_SEND(chan, length)
3535
#endif
3636

37+
/*
38+
to get warnings when any WIP message is used, add this:
39+
#define MAVLINK_WIP __attribute__((warning("MAVLink work in progress")))
40+
*/
41+
#ifndef MAVLINK_WIP
42+
#define MAVLINK_WIP
43+
#endif
44+
3745
/* option to provide alternative implementation of mavlink_helpers.h */
3846
#ifdef MAVLINK_SEPARATE_HELPERS
3947

@@ -179,6 +187,13 @@ static inline void byte_copy_8(char *dst, const char *src)
179187
*/
180188
static inline void mav_array_memcpy(void *dest, const void *src, size_t n)
181189
{
190+
// It would be tempting to do a strcpy/strncpy for the char[] type. Unfortunately, some
191+
// existing MAVLink messages such as PARAM_EXT_VALUE.param_value use the char[] type for
192+
// arbitrary data (including null), and would break.
193+
//
194+
// It would be nice to change such char[] types to uint8_t[] but that would change the
195+
// CRC_EXTRA.
196+
182197
if (src == NULL) {
183198
memset(dest, 0, n);
184199
} else {

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

1111
#ifndef MAVLINK_STX
1212
#define MAVLINK_STX 254

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ static inline void mavlink_msg_attitude_quaternion_send_struct(mavlink_channel_t
310310

311311
#if MAVLINK_MSG_ID_ATTITUDE_QUATERNION_LEN <= MAVLINK_MAX_PAYLOAD_LEN
312312
/*
313-
This variant of _send() can be used to save stack space by re-using
313+
This variant of _send() can be used to save stack space by reusing
314314
memory from the receive buffer. The caller provides a
315315
mavlink_message_t which is the size of a full mavlink message. This
316316
is usually the receive buffer for the channel, and allows a reply to an

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ static inline void mavlink_msg_diff_pressure_send_struct(mavlink_channel_t chan,
235235

236236
#if MAVLINK_MSG_ID_DIFF_PRESSURE_LEN <= MAVLINK_MAX_PAYLOAD_LEN
237237
/*
238-
This variant of _send() can be used to save stack space by re-using
238+
This variant of _send() can be used to save stack space by reusing
239239
memory from the receive buffer. The caller provides a
240240
mavlink_message_t which is the size of a full mavlink message. This
241241
is usually the receive buffer for the channel, and allows a reply to an

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ static inline void mavlink_msg_external_attitude_send_struct(mavlink_channel_t c
250250

251251
#if MAVLINK_MSG_ID_EXTERNAL_ATTITUDE_LEN <= MAVLINK_MAX_PAYLOAD_LEN
252252
/*
253-
This variant of _send() can be used to save stack space by re-using
253+
This variant of _send() can be used to save stack space by reusing
254254
memory from the receive buffer. The caller provides a
255255
mavlink_message_t which is the size of a full mavlink message. This
256256
is usually the receive buffer for the channel, and allows a reply to an

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ static inline void mavlink_msg_heartbeat_send_struct(mavlink_channel_t chan, con
276276

277277
#if MAVLINK_MSG_ID_HEARTBEAT_LEN <= MAVLINK_MAX_PAYLOAD_LEN
278278
/*
279-
This variant of _send() can be used to save stack space by re-using
279+
This variant of _send() can be used to save stack space by reusing
280280
memory from the receive buffer. The caller provides a
281281
mavlink_message_t which is the size of a full mavlink message. This
282282
is usually the receive buffer for the channel, and allows a reply to an

0 commit comments

Comments
 (0)