From e41ae1fadc3b09d78e5fe66e707645f94f358687 Mon Sep 17 00:00:00 2001 From: "pienk@planet.nl" Date: Mon, 20 May 2013 12:02:17 +0000 Subject: [PATCH] [mavlink] Updated mavlink code to work with the current Arducopter (and probably plane and rover). Mavlink library has been updated to V 1.0. --- src/GCS_MAVLink/{license.txt => COPYING} | 0 src/GCS_MAVLink/GCS_MAVLink.cpp | 27 - src/GCS_MAVLink/GCS_MAVLink.h | 128 --- src/GCS_MAVLink/Mavlink_compat.h | 172 ---- .../ardupilotmega/ardupilotmega.h | 83 +- .../ardupilotmega/mavlink_msg_ahrs.h | 276 ++++++ .../ardupilotmega/mavlink_msg_ap_adc.h | 8 +- .../ardupilotmega/mavlink_msg_data16.h | 182 ++++ .../ardupilotmega/mavlink_msg_data32.h | 182 ++++ .../ardupilotmega/mavlink_msg_data64.h | 182 ++++ .../ardupilotmega/mavlink_msg_data96.h | 182 ++++ .../mavlink_msg_digicam_configure.h | 8 +- .../mavlink_msg_digicam_control.h | 8 +- .../mavlink_msg_fence_fetch_point.h | 8 +- .../ardupilotmega/mavlink_msg_fence_point.h | 8 +- .../ardupilotmega/mavlink_msg_fence_status.h | 8 +- .../ardupilotmega/mavlink_msg_hwstatus.h | 166 ++++ .../ardupilotmega/mavlink_msg_limits_status.h | 320 +++++++ .../ardupilotmega/mavlink_msg_meminfo.h | 8 +- .../mavlink_msg_mount_configure.h | 8 +- .../ardupilotmega/mavlink_msg_mount_control.h | 8 +- .../ardupilotmega/mavlink_msg_mount_status.h | 8 +- .../ardupilotmega/mavlink_msg_radio.h | 276 ++++++ .../ardupilotmega/mavlink_msg_rangefinder.h | 166 ++++ .../mavlink_msg_sensor_offsets.h | 8 +- .../mavlink_msg_set_mag_offsets.h | 8 +- .../ardupilotmega/mavlink_msg_simstate.h | 364 ++++++++ .../ardupilotmega/mavlink_msg_wind.h | 188 ++++ .../include_v1.0/ardupilotmega/testsuite.h | 618 +++++++++++- .../include_v1.0/ardupilotmega/version.h | 4 +- src/GCS_MAVLink/include_v1.0/checksum.h | 4 +- src/GCS_MAVLink/include_v1.0/common/common.h | 154 +-- .../common/mavlink_msg_attitude.h | 38 +- .../common/mavlink_msg_attitude_quaternion.h | 8 +- .../common/mavlink_msg_auth_key.h | 8 +- .../common/mavlink_msg_battery_status.h | 320 +++++++ .../mavlink_msg_change_operator_control.h | 8 +- .../mavlink_msg_change_operator_control_ack.h | 8 +- .../common/mavlink_msg_command_ack.h | 8 +- .../common/mavlink_msg_command_long.h | 8 +- .../common/mavlink_msg_data_stream.h | 8 +- .../include_v1.0/common/mavlink_msg_debug.h | 8 +- .../common/mavlink_msg_debug_vect.h | 8 +- .../mavlink_msg_file_transfer_dir_list.h | 182 ++++ .../common/mavlink_msg_file_transfer_res.h | 166 ++++ .../common/mavlink_msg_file_transfer_start.h | 226 +++++ .../common/mavlink_msg_global_position_int.h | 8 +- ...mavlink_msg_global_position_setpoint_int.h | 8 +- ...link_msg_global_vision_position_estimate.h | 18 +- .../common/mavlink_msg_gps_global_origin.h | 8 +- .../common/mavlink_msg_gps_raw_int.h | 8 +- .../common/mavlink_msg_gps_status.h | 8 +- .../common/mavlink_msg_heartbeat.h | 42 +- .../common/mavlink_msg_highres_imu.h | 452 +++++++++ .../common/mavlink_msg_hil_controls.h | 8 +- .../common/mavlink_msg_hil_rc_inputs_raw.h | 8 +- .../common/mavlink_msg_hil_state.h | 8 +- .../common/mavlink_msg_local_position_ned.h | 8 +- ..._local_position_ned_system_global_offset.h | 276 ++++++ .../mavlink_msg_local_position_setpoint.h | 8 +- .../common/mavlink_msg_manual_control.h | 284 +++--- .../common/mavlink_msg_manual_setpoint.h | 276 ++++++ .../common/mavlink_msg_memory_vect.h | 8 +- .../common/mavlink_msg_mission_ack.h | 8 +- .../common/mavlink_msg_mission_clear_all.h | 8 +- .../common/mavlink_msg_mission_count.h | 8 +- .../common/mavlink_msg_mission_current.h | 8 +- .../common/mavlink_msg_mission_item.h | 8 +- .../common/mavlink_msg_mission_item_reached.h | 8 +- .../common/mavlink_msg_mission_request.h | 8 +- .../common/mavlink_msg_mission_request_list.h | 8 +- ...mavlink_msg_mission_request_partial_list.h | 8 +- .../common/mavlink_msg_mission_set_current.h | 8 +- .../mavlink_msg_mission_write_partial_list.h | 8 +- .../common/mavlink_msg_named_value_float.h | 8 +- .../common/mavlink_msg_named_value_int.h | 8 +- .../mavlink_msg_nav_controller_output.h | 8 +- .../common/mavlink_msg_omnidirectional_flow.h | 249 +++++ .../common/mavlink_msg_optical_flow.h | 142 ++- .../common/mavlink_msg_param_request_list.h | 8 +- .../common/mavlink_msg_param_request_read.h | 28 +- .../common/mavlink_msg_param_set.h | 28 +- .../common/mavlink_msg_param_value.h | 28 +- .../include_v1.0/common/mavlink_msg_ping.h | 8 +- .../include_v1.0/common/mavlink_msg_raw_imu.h | 8 +- .../common/mavlink_msg_raw_pressure.h | 8 +- .../common/mavlink_msg_rc_channels_override.h | 8 +- .../common/mavlink_msg_rc_channels_raw.h | 108 +-- .../common/mavlink_msg_rc_channels_scaled.h | 108 +-- .../common/mavlink_msg_request_data_stream.h | 8 +- ...msg_roll_pitch_yaw_rates_thrust_setpoint.h | 232 +++++ ...msg_roll_pitch_yaw_speed_thrust_setpoint.h | 8 +- ...vlink_msg_roll_pitch_yaw_thrust_setpoint.h | 8 +- .../common/mavlink_msg_safety_allowed_area.h | 8 +- .../mavlink_msg_safety_set_allowed_area.h | 8 +- .../common/mavlink_msg_scaled_imu.h | 8 +- .../common/mavlink_msg_scaled_pressure.h | 18 +- .../common/mavlink_msg_servo_output_raw.h | 18 +- ...ink_msg_set_global_position_setpoint_int.h | 8 +- .../mavlink_msg_set_gps_global_origin.h | 8 +- .../mavlink_msg_set_local_position_setpoint.h | 8 +- .../common/mavlink_msg_set_mode.h | 8 +- .../mavlink_msg_set_quad_motors_setpoint.h | 232 +++++ ...set_quad_swarm_led_roll_pitch_yaw_thrust.h | 320 +++++++ ...msg_set_quad_swarm_roll_pitch_yaw_thrust.h | 251 +++++ ...link_msg_set_roll_pitch_yaw_speed_thrust.h | 8 +- .../mavlink_msg_set_roll_pitch_yaw_thrust.h | 8 +- .../common/mavlink_msg_setpoint_6dof.h | 276 ++++++ .../common/mavlink_msg_setpoint_8dof.h | 320 +++++++ .../common/mavlink_msg_state_correction.h | 8 +- .../common/mavlink_msg_statustext.h | 18 +- .../common/mavlink_msg_sys_status.h | 8 +- .../common/mavlink_msg_system_time.h | 8 +- .../include_v1.0/common/mavlink_msg_vfr_hud.h | 8 +- .../mavlink_msg_vicon_position_estimate.h | 18 +- .../mavlink_msg_vision_position_estimate.h | 18 +- .../mavlink_msg_vision_speed_estimate.h | 18 +- .../include_v1.0/common/testsuite.h | 878 ++++++++++++++++-- src/GCS_MAVLink/include_v1.0/common/version.h | 4 +- .../include_v1.0/mavlink_helpers.h | 88 +- .../include_v1.0/mavlink_protobuf_manager.hpp | 377 ++++++++ src/GCS_MAVLink/include_v1.0/mavlink_types.h | 90 +- src/GCS_MAVLink/include_v1.0/protocol.h | 17 +- .../ardupilotmega.xml | 128 ++- .../message_definitions_v1.0/common.xml | 656 +++++++------ .../message_definitions_v1.0/matrixpilot.xml | 284 +++++- .../message_definitions_v1.0/minimal.xml | 181 +++- .../message_definitions_v1.0/pixhawk.proto | 163 ++++ .../message_definitions_v1.0/pixhawk.xml | 17 + .../message_definitions_v1.0/sensesoar.xml | 143 +++ .../message_definitions_v1.0/slugs.xml | 22 +- .../message_definitions_v1.0/ualberta.xml | 44 +- .../missionlib/mavlink_missionlib_data.h | 58 ++ .../missionlib/mavlink_parameters.c | 150 +++ .../missionlib/mavlink_parameters.h | 38 + src/GCS_MAVLink/missionlib/testing/main.c | 137 ++- .../testing/mavlink_missionlib_data.h | 54 ++ .../testing/udptest.xcodeproj/project.pbxproj | 15 +- src/GCS_MAVLink/missionlib/waypoints.c | 496 +++++----- src/GCS_MAVLink/missionlib/waypoints.h | 33 +- src/GCS_MAVLink/sync | 2 +- src/Makefile | 2 +- src/gui/view_mavlink.cpp | 319 +++++++ src/gui/view_mavlink.h | 77 ++ src/opentx.h | 1 - src/rotarysw.cpp | 121 --- src/rotarysw.h | 113 --- src/serial.cpp | 2 +- src/telemetry/mavlink.cpp | 494 +++------- src/telemetry/mavlink.h | 152 +-- 150 files changed, 11617 insertions(+), 2659 deletions(-) rename src/GCS_MAVLink/{license.txt => COPYING} (100%) delete mode 100644 src/GCS_MAVLink/GCS_MAVLink.cpp delete mode 100644 src/GCS_MAVLink/GCS_MAVLink.h delete mode 100644 src/GCS_MAVLink/Mavlink_compat.h create mode 100644 src/GCS_MAVLink/include_v1.0/ardupilotmega/mavlink_msg_ahrs.h create mode 100644 src/GCS_MAVLink/include_v1.0/ardupilotmega/mavlink_msg_data16.h create mode 100644 src/GCS_MAVLink/include_v1.0/ardupilotmega/mavlink_msg_data32.h create mode 100644 src/GCS_MAVLink/include_v1.0/ardupilotmega/mavlink_msg_data64.h create mode 100644 src/GCS_MAVLink/include_v1.0/ardupilotmega/mavlink_msg_data96.h create mode 100644 src/GCS_MAVLink/include_v1.0/ardupilotmega/mavlink_msg_hwstatus.h create mode 100644 src/GCS_MAVLink/include_v1.0/ardupilotmega/mavlink_msg_limits_status.h create mode 100644 src/GCS_MAVLink/include_v1.0/ardupilotmega/mavlink_msg_radio.h create mode 100644 src/GCS_MAVLink/include_v1.0/ardupilotmega/mavlink_msg_rangefinder.h create mode 100644 src/GCS_MAVLink/include_v1.0/ardupilotmega/mavlink_msg_simstate.h create mode 100644 src/GCS_MAVLink/include_v1.0/ardupilotmega/mavlink_msg_wind.h create mode 100644 src/GCS_MAVLink/include_v1.0/common/mavlink_msg_battery_status.h create mode 100644 src/GCS_MAVLink/include_v1.0/common/mavlink_msg_file_transfer_dir_list.h create mode 100644 src/GCS_MAVLink/include_v1.0/common/mavlink_msg_file_transfer_res.h create mode 100644 src/GCS_MAVLink/include_v1.0/common/mavlink_msg_file_transfer_start.h create mode 100644 src/GCS_MAVLink/include_v1.0/common/mavlink_msg_highres_imu.h create mode 100644 src/GCS_MAVLink/include_v1.0/common/mavlink_msg_local_position_ned_system_global_offset.h create mode 100644 src/GCS_MAVLink/include_v1.0/common/mavlink_msg_manual_setpoint.h create mode 100644 src/GCS_MAVLink/include_v1.0/common/mavlink_msg_omnidirectional_flow.h create mode 100644 src/GCS_MAVLink/include_v1.0/common/mavlink_msg_roll_pitch_yaw_rates_thrust_setpoint.h create mode 100644 src/GCS_MAVLink/include_v1.0/common/mavlink_msg_set_quad_motors_setpoint.h create mode 100644 src/GCS_MAVLink/include_v1.0/common/mavlink_msg_set_quad_swarm_led_roll_pitch_yaw_thrust.h create mode 100644 src/GCS_MAVLink/include_v1.0/common/mavlink_msg_set_quad_swarm_roll_pitch_yaw_thrust.h create mode 100644 src/GCS_MAVLink/include_v1.0/common/mavlink_msg_setpoint_6dof.h create mode 100644 src/GCS_MAVLink/include_v1.0/common/mavlink_msg_setpoint_8dof.h create mode 100644 src/GCS_MAVLink/include_v1.0/mavlink_protobuf_manager.hpp create mode 100644 src/GCS_MAVLink/message_definitions_v1.0/pixhawk.proto create mode 100644 src/GCS_MAVLink/message_definitions_v1.0/sensesoar.xml create mode 100644 src/GCS_MAVLink/missionlib/mavlink_missionlib_data.h create mode 100644 src/GCS_MAVLink/missionlib/mavlink_parameters.c create mode 100644 src/GCS_MAVLink/missionlib/mavlink_parameters.h create mode 100644 src/GCS_MAVLink/missionlib/testing/mavlink_missionlib_data.h create mode 100644 src/gui/view_mavlink.cpp create mode 100644 src/gui/view_mavlink.h delete mode 100644 src/rotarysw.cpp delete mode 100644 src/rotarysw.h diff --git a/src/GCS_MAVLink/license.txt b/src/GCS_MAVLink/COPYING similarity index 100% rename from src/GCS_MAVLink/license.txt rename to src/GCS_MAVLink/COPYING diff --git a/src/GCS_MAVLink/GCS_MAVLink.cpp b/src/GCS_MAVLink/GCS_MAVLink.cpp deleted file mode 100644 index bbf3cf441..000000000 --- a/src/GCS_MAVLink/GCS_MAVLink.cpp +++ /dev/null @@ -1,27 +0,0 @@ -// -*- tab-width: 4; Mode: C++; c-basic-offset: 4; indent-tabs-mode: t -*- - -/// @file GCS_MAVLink.cpp -/// @brief Supporting bits for MAVLink. - -#include "GCS_MAVLink.h" - -BetterStream *mavlink_comm_0_port; -BetterStream *mavlink_comm_1_port; - -// this might need to move to the flight software -mavlink_system_t mavlink_system = {7,1,0,0}; - -#ifdef MAVLINK10 -# include "include_v1.0/mavlink_helpers.h" -#else -# include "include/mavlink_helpers.h" -#endif - -uint8_t mavlink_check_target(uint8_t sysid, uint8_t compid) -{ - if (sysid != mavlink_system.sysid) - return 1; - // Currently we are not checking for correct compid since APM is not passing mavlink info to any subsystem - // If it is addressed to our system ID we assume it is for us - return 0; // no error -} diff --git a/src/GCS_MAVLink/GCS_MAVLink.h b/src/GCS_MAVLink/GCS_MAVLink.h deleted file mode 100644 index 4b3a038e0..000000000 --- a/src/GCS_MAVLink/GCS_MAVLink.h +++ /dev/null @@ -1,128 +0,0 @@ -// -*- tab-width: 4; Mode: C++; c-basic-offset: 4; indent-tabs-mode: t -*- - -/// @file GCS_MAVLink.h -/// @brief One size fits all header for MAVLink integration. - -#ifndef GCS_MAVLink_h -#define GCS_MAVLink_h - -#include - -#define MAVLINK_SEPARATE_HELPERS - -#ifdef MAVLINK10 -# include "include_v1.0/ardupilotmega/version.h" -#else -# include "include/ardupilotmega/version.h" -#endif - -// this allows us to make mavlink_message_t much smaller -#define MAVLINK_MAX_PAYLOAD_LEN MAVLINK_MAX_DIALECT_PAYLOAD_SIZE - -#define MAVLINK_COMM_NUM_BUFFERS 2 -#ifdef MAVLINK10 -# include "include_v1.0/mavlink_types.h" -#else -# include "include/mavlink_types.h" -#endif - -/// MAVLink stream used for HIL interaction -extern BetterStream *mavlink_comm_0_port; - -/// MAVLink stream used for ground control communication -extern BetterStream *mavlink_comm_1_port; - -/// MAVLink system definition -extern mavlink_system_t mavlink_system; - -/// Send a byte to the nominated MAVLink channel -/// -/// @param chan Channel to send to -/// @param ch Byte to send -/// -static inline void comm_send_ch(mavlink_channel_t chan, uint8_t ch) -{ - switch(chan) { - case MAVLINK_COMM_0: - mavlink_comm_0_port->write(ch); - break; - case MAVLINK_COMM_1: - mavlink_comm_1_port->write(ch); - break; - default: - break; - } -} - -/// Read a byte from the nominated MAVLink channel -/// -/// @param chan Channel to receive on -/// @returns Byte read -/// -static inline uint8_t comm_receive_ch(mavlink_channel_t chan) -{ - uint8_t data = 0; - - switch(chan) { - case MAVLINK_COMM_0: - data = mavlink_comm_0_port->read(); - break; - case MAVLINK_COMM_1: - data = mavlink_comm_1_port->read(); - break; - default: - break; - } - return data; -} - -/// Check for available data on the nominated MAVLink channel -/// -/// @param chan Channel to check -/// @returns Number of bytes available -static inline uint16_t comm_get_available(mavlink_channel_t chan) -{ - uint16_t bytes = 0; - switch(chan) { - case MAVLINK_COMM_0: - bytes = mavlink_comm_0_port->available(); - break; - case MAVLINK_COMM_1: - bytes = mavlink_comm_1_port->available(); - break; - default: - break; - } - return bytes; -} - - -/// Check for available transmit space on the nominated MAVLink channel -/// -/// @param chan Channel to check -/// @returns Number of bytes available, -1 for error -static inline int comm_get_txspace(mavlink_channel_t chan) -{ - switch(chan) { - case MAVLINK_COMM_0: - return mavlink_comm_0_port->txspace(); - break; - case MAVLINK_COMM_1: - return mavlink_comm_1_port->txspace(); - break; - default: - break; - } - return -1; -} - -#define MAVLINK_USE_CONVENIENCE_FUNCTIONS -#ifdef MAVLINK10 -# include "include_v1.0/ardupilotmega/mavlink.h" -#else -# include "include/ardupilotmega/mavlink.h" -#endif - -uint8_t mavlink_check_target(uint8_t sysid, uint8_t compid); - -#endif // GCS_MAVLink_h diff --git a/src/GCS_MAVLink/Mavlink_compat.h b/src/GCS_MAVLink/Mavlink_compat.h deleted file mode 100644 index c53544721..000000000 --- a/src/GCS_MAVLink/Mavlink_compat.h +++ /dev/null @@ -1,172 +0,0 @@ -/* - compatibility header during transition to MAVLink 1.0 - */ - -#ifdef MAVLINK10 -// in MAVLink 1.0 'waypoint' becomes 'mission'. We can remove these -// mappings once we are not trying to support both protocols - -#define MAVLINK_MSG_ID_WAYPOINT_CURRENT MAVLINK_MSG_ID_MISSION_CURRENT -#define MAVLINK_MSG_ID_WAYPOINT_CURRENT_LEN MAVLINK_MSG_ID_MISSION_CURRENT_LEN -#define mavlink_msg_waypoint_current_send mavlink_msg_mission_current_send -#define mavlink_msg_waypoint_current_decode mavlink_msg_mission_current_decode - -#define MAVLINK_MSG_ID_WAYPOINT_COUNT MAVLINK_MSG_ID_MISSION_COUNT -#define MAVLINK_MSG_ID_WAYPOINT_COUNT_LEN MAVLINK_MSG_ID_MISSION_COUNT_LEN -#define mavlink_msg_waypoint_count_send mavlink_msg_mission_count_send -#define mavlink_msg_waypoint_count_decode mavlink_msg_mission_count_decode -#define mavlink_waypoint_count_t mavlink_mission_count_t - -#define MAVLINK_MSG_ID_WAYPOINT_REQUEST MAVLINK_MSG_ID_MISSION_REQUEST -#define MAVLINK_MSG_ID_WAYPOINT_REQUEST_LEN MAVLINK_MSG_ID_MISSION_REQUEST_LEN -#define mavlink_msg_waypoint_request_send mavlink_msg_mission_request_send -#define mavlink_msg_waypoint_request_decode mavlink_msg_mission_request_decode -#define mavlink_waypoint_request_t mavlink_mission_request_t - -#define MAVLINK_MSG_ID_WAYPOINT_REQUEST_LIST MAVLINK_MSG_ID_MISSION_REQUEST_LIST -#define MAVLINK_MSG_ID_WAYPOINT_REQUEST_LIST_LEN MAVLINK_MSG_ID_MISSION_REQUEST_LIST_LEN -#define mavlink_msg_waypoint_request_list_send mavlink_msg_mission_request_list_send -#define mavlink_msg_waypoint_request_list_decode mavlink_msg_mission_request_list_decode -#define mavlink_waypoint_request_list_t mavlink_mission_request_list_t - -#define MAVLINK_MSG_ID_WAYPOINT MAVLINK_MSG_ID_MISSION_ITEM -#define MAVLINK_MSG_ID_WAYPOINT_LEN MAVLINK_MSG_ID_MISSION_ITEM_LEN -#define mavlink_msg_waypoint_send mavlink_msg_mission_item_send -#define mavlink_msg_waypoint_decode mavlink_msg_mission_item_decode -#define mavlink_waypoint_t mavlink_mission_item_t - -#define MAVLINK_MSG_ID_WAYPOINT_ACK MAVLINK_MSG_ID_MISSION_ACK -#define MAVLINK_MSG_ID_WAYPOINT_ACK_LEN MAVLINK_MSG_ID_MISSION_ACK_LEN -#define mavlink_msg_waypoint_ack_send mavlink_msg_mission_ack_send -#define mavlink_msg_waypoint_ack_decode mavlink_msg_mission_ack_decode -#define mavlink_waypoint_ack_t mavlink_mission_ack_t - -#define MAVLINK_MSG_ID_WAYPOINT_CLEAR_ALL MAVLINK_MSG_ID_MISSION_CLEAR_ALL -#define MAVLINK_MSG_ID_WAYPOINT_CLEAR_ALL_LEN MAVLINK_MSG_ID_MISSION_CLEAR_ALL_LEN -#define mavlink_msg_waypoint_clear_all_send mavlink_msg_mission_clear_all_send -#define mavlink_msg_waypoint_clear_all_decode mavlink_msg_mission_clear_all_decode -#define mavlink_waypoint_clear_all_t mavlink_mission_clear_all_t - -#define MAVLINK_MSG_ID_WAYPOINT_SET_CURRENT MAVLINK_MSG_ID_MISSION_SET_CURRENT -#define MAVLINK_MSG_ID_WAYPOINT_SET_CURRENT_LEN MAVLINK_MSG_ID_MISSION_SET_CURRENT_LEN -#define mavlink_msg_waypoint_set_current_send mavlink_msg_mission_set_current_send -#define mavlink_msg_waypoint_set_current_decode mavlink_msg_mission_set_current_decode -#define mavlink_waypoint_set_current_t mavlink_mission_set_current_t - -static uint8_t mav_var_type(enum ap_var_type t) -{ - if (t == AP_PARAM_INT8) { - return MAV_VAR_INT8; - } - if (t == AP_PARAM_INT16) { - return MAV_VAR_INT16; - } - if (t == AP_PARAM_INT32) { - return MAV_VAR_INT32; - } - // treat any others as float - return MAV_VAR_FLOAT; -} - -#define MAV_FIXED_WING MAV_TYPE_FIXED_WING - -#else // MAVLINK10 - -static uint8_t mav_var_type(enum ap_var_type t) -{ - return 0; -} - -#define MAV_MISSION_ACCEPTED 0 -#define MAV_MISSION_UNSUPPORTED 1 -#define MAV_MISSION_UNSUPPORTED_FRAME 1 -#define MAV_MISSION_ERROR 1 -#define MAV_MISSION_INVALID_SEQUENCE 1 - -/* - some functions have some extra params in MAVLink 1.0 - */ - -static void mavlink_msg_global_position_int_send(mavlink_channel_t chan, uint32_t time_boot_ms, int32_t lat, int32_t lon, - int32_t alt, int32_t relative_alt, int16_t vx, int16_t vy, - int16_t vz, uint16_t hdg) -{ - mavlink_msg_global_position_int_send( - chan, - lat, - lon, - alt, - vx, vy, vz); -} - -static void mavlink_msg_rc_channels_scaled_send(mavlink_channel_t chan, uint32_t time_boot_ms, uint8_t port, - int16_t chan1_scaled, int16_t chan2_scaled, int16_t chan3_scaled, - int16_t chan4_scaled, int16_t chan5_scaled, int16_t chan6_scaled, - int16_t chan7_scaled, int16_t chan8_scaled, uint8_t rssi) -{ - mavlink_msg_rc_channels_scaled_send( - chan, - chan1_scaled, - chan2_scaled, - chan3_scaled, - chan4_scaled, - chan5_scaled, - chan6_scaled, - chan7_scaled, - chan8_scaled, - rssi); -} - -static void mavlink_msg_rc_channels_raw_send(mavlink_channel_t chan, uint32_t time_boot_ms, uint8_t port, - uint16_t chan1_raw, uint16_t chan2_raw, uint16_t chan3_raw, - uint16_t chan4_raw, uint16_t chan5_raw, uint16_t chan6_raw, - uint16_t chan7_raw, uint16_t chan8_raw, uint8_t rssi) -{ - mavlink_msg_rc_channels_raw_send( - chan, - chan1_raw, - chan2_raw, - chan3_raw, - chan4_raw, - chan5_raw, - chan6_raw, - chan7_raw, - chan8_raw, - rssi); -} - - -static void mavlink_msg_servo_output_raw_send(mavlink_channel_t chan, uint32_t time_usec, uint8_t port, - uint16_t servo1_raw, uint16_t servo2_raw, uint16_t servo3_raw, - uint16_t servo4_raw, uint16_t servo5_raw, uint16_t servo6_raw, - uint16_t servo7_raw, uint16_t servo8_raw) -{ - mavlink_msg_servo_output_raw_send( - chan, - servo1_raw, - servo2_raw, - servo3_raw, - servo4_raw, - servo5_raw, - servo6_raw, - servo7_raw, - servo8_raw); -} - -static void mavlink_msg_statustext_send(mavlink_channel_t chan, uint8_t severity, const char *text) -{ - mavlink_msg_statustext_send(chan, severity, (const int8_t*) text); -} - -static void mavlink_msg_param_value_send(mavlink_channel_t chan, const char *param_id, - float param_value, uint8_t param_type, - uint16_t param_count, uint16_t param_index) -{ - mavlink_msg_param_value_send( - chan, - (int8_t *)param_id, - param_value, - param_count, - param_index); -} -#endif // MAVLINK10 diff --git a/src/GCS_MAVLink/include_v1.0/ardupilotmega/ardupilotmega.h b/src/GCS_MAVLink/include_v1.0/ardupilotmega/ardupilotmega.h index 4b68f0862..fb8164fdb 100644 --- a/src/GCS_MAVLink/include_v1.0/ardupilotmega/ardupilotmega.h +++ b/src/GCS_MAVLink/include_v1.0/ardupilotmega/ardupilotmega.h @@ -12,34 +12,21 @@ extern "C" { // MESSAGE LENGTHS AND CRCS #ifndef MAVLINK_MESSAGE_LENGTHS -#define MAVLINK_MESSAGE_LENGTHS {9, 31, 12, 0, 14, 28, 3, 32, 0, 0, 0, 6, 0, 0, 0, 0, 0, 0, 0, 0, 20, 2, 25, 23, 30, 101, 22, 26, 16, 14, 28, 32, 28, 28, 22, 22, 21, 6, 6, 37, 4, 4, 2, 2, 4, 2, 2, 3, 13, 12, 19, 17, 15, 15, 27, 25, 18, 18, 20, 20, 0, 0, 26, 0, 36, 0, 6, 4, 0, 21, 18, 0, 0, 0, 20, 0, 33, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 56, 42, 33, 0, 0, 0, 0, 0, 0, 0, 18, 32, 32, 20, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 42, 8, 4, 12, 15, 13, 6, 15, 14, 0, 12, 3, 8, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 36, 30, 18, 18, 51, 9, 3} +#define MAVLINK_MESSAGE_LENGTHS {9, 31, 12, 0, 14, 28, 3, 32, 0, 0, 0, 6, 0, 0, 0, 0, 0, 0, 0, 0, 20, 2, 25, 23, 30, 101, 22, 26, 16, 14, 28, 32, 28, 28, 22, 22, 21, 6, 6, 37, 4, 4, 2, 2, 4, 2, 2, 3, 13, 12, 19, 17, 15, 15, 27, 25, 18, 18, 20, 20, 9, 34, 26, 46, 36, 0, 6, 4, 0, 11, 18, 0, 0, 0, 20, 0, 33, 3, 0, 0, 20, 22, 0, 0, 0, 0, 0, 0, 0, 28, 56, 42, 33, 0, 0, 0, 0, 0, 0, 0, 26, 32, 32, 20, 32, 62, 54, 0, 0, 0, 254, 249, 9, 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, 33, 25, 42, 8, 4, 12, 15, 13, 6, 15, 14, 0, 12, 3, 8, 28, 44, 3, 9, 22, 12, 18, 34, 66, 98, 8, 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, 0, 0, 0, 0, 0, 0, 0, 36, 30, 18, 18, 51, 9, 0} #endif #ifndef MAVLINK_MESSAGE_CRCS -#define MAVLINK_MESSAGE_CRCS {50, 124, 137, 0, 237, 217, 104, 119, 0, 0, 0, 89, 0, 0, 0, 0, 0, 0, 0, 0, 214, 159, 220, 168, 24, 23, 170, 144, 67, 115, 39, 246, 185, 104, 237, 244, 222, 212, 9, 254, 230, 28, 28, 132, 221, 232, 11, 153, 41, 39, 214, 223, 141, 33, 15, 3, 100, 24, 239, 238, 0, 0, 183, 0, 130, 0, 148, 21, 0, 52, 124, 0, 0, 0, 20, 0, 152, 143, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 183, 63, 54, 0, 0, 0, 0, 0, 0, 0, 19, 102, 158, 208, 56, 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, 134, 219, 208, 188, 84, 22, 19, 21, 134, 0, 78, 68, 189, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 204, 49, 170, 44, 83, 46, 247} +#define MAVLINK_MESSAGE_CRCS {50, 124, 137, 0, 237, 217, 104, 119, 0, 0, 0, 89, 0, 0, 0, 0, 0, 0, 0, 0, 214, 159, 220, 168, 24, 23, 170, 144, 67, 115, 39, 246, 185, 104, 237, 244, 222, 212, 9, 254, 230, 28, 28, 132, 221, 232, 11, 153, 41, 39, 214, 223, 141, 33, 15, 3, 100, 24, 239, 238, 30, 240, 183, 130, 130, 0, 148, 21, 0, 243, 124, 0, 0, 0, 20, 0, 152, 143, 0, 0, 127, 106, 0, 0, 0, 0, 0, 0, 0, 231, 183, 63, 54, 0, 0, 0, 0, 0, 0, 0, 175, 102, 158, 208, 56, 93, 211, 0, 0, 0, 235, 93, 124, 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, 42, 241, 15, 134, 219, 208, 188, 84, 22, 19, 21, 134, 0, 78, 68, 189, 127, 111, 21, 21, 144, 1, 234, 73, 181, 22, 83, 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, 0, 0, 0, 0, 0, 0, 0, 204, 49, 170, 44, 83, 46, 0} #endif #ifndef MAVLINK_MESSAGE_INFO -#define MAVLINK_MESSAGE_INFO {MAVLINK_MESSAGE_INFO_HEARTBEAT, MAVLINK_MESSAGE_INFO_SYS_STATUS, MAVLINK_MESSAGE_INFO_SYSTEM_TIME, {NULL}, MAVLINK_MESSAGE_INFO_PING, MAVLINK_MESSAGE_INFO_CHANGE_OPERATOR_CONTROL, MAVLINK_MESSAGE_INFO_CHANGE_OPERATOR_CONTROL_ACK, MAVLINK_MESSAGE_INFO_AUTH_KEY, {NULL}, {NULL}, {NULL}, MAVLINK_MESSAGE_INFO_SET_MODE, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, MAVLINK_MESSAGE_INFO_PARAM_REQUEST_READ, MAVLINK_MESSAGE_INFO_PARAM_REQUEST_LIST, MAVLINK_MESSAGE_INFO_PARAM_VALUE, MAVLINK_MESSAGE_INFO_PARAM_SET, MAVLINK_MESSAGE_INFO_GPS_RAW_INT, MAVLINK_MESSAGE_INFO_GPS_STATUS, MAVLINK_MESSAGE_INFO_SCALED_IMU, MAVLINK_MESSAGE_INFO_RAW_IMU, MAVLINK_MESSAGE_INFO_RAW_PRESSURE, MAVLINK_MESSAGE_INFO_SCALED_PRESSURE, MAVLINK_MESSAGE_INFO_ATTITUDE, MAVLINK_MESSAGE_INFO_ATTITUDE_QUATERNION, MAVLINK_MESSAGE_INFO_LOCAL_POSITION_NED, MAVLINK_MESSAGE_INFO_GLOBAL_POSITION_INT, MAVLINK_MESSAGE_INFO_RC_CHANNELS_SCALED, MAVLINK_MESSAGE_INFO_RC_CHANNELS_RAW, MAVLINK_MESSAGE_INFO_SERVO_OUTPUT_RAW, MAVLINK_MESSAGE_INFO_MISSION_REQUEST_PARTIAL_LIST, MAVLINK_MESSAGE_INFO_MISSION_WRITE_PARTIAL_LIST, MAVLINK_MESSAGE_INFO_MISSION_ITEM, MAVLINK_MESSAGE_INFO_MISSION_REQUEST, MAVLINK_MESSAGE_INFO_MISSION_SET_CURRENT, MAVLINK_MESSAGE_INFO_MISSION_CURRENT, MAVLINK_MESSAGE_INFO_MISSION_REQUEST_LIST, MAVLINK_MESSAGE_INFO_MISSION_COUNT, MAVLINK_MESSAGE_INFO_MISSION_CLEAR_ALL, MAVLINK_MESSAGE_INFO_MISSION_ITEM_REACHED, MAVLINK_MESSAGE_INFO_MISSION_ACK, MAVLINK_MESSAGE_INFO_SET_GPS_GLOBAL_ORIGIN, MAVLINK_MESSAGE_INFO_GPS_GLOBAL_ORIGIN, MAVLINK_MESSAGE_INFO_SET_LOCAL_POSITION_SETPOINT, MAVLINK_MESSAGE_INFO_LOCAL_POSITION_SETPOINT, MAVLINK_MESSAGE_INFO_GLOBAL_POSITION_SETPOINT_INT, MAVLINK_MESSAGE_INFO_SET_GLOBAL_POSITION_SETPOINT_INT, MAVLINK_MESSAGE_INFO_SAFETY_SET_ALLOWED_AREA, MAVLINK_MESSAGE_INFO_SAFETY_ALLOWED_AREA, MAVLINK_MESSAGE_INFO_SET_ROLL_PITCH_YAW_THRUST, MAVLINK_MESSAGE_INFO_SET_ROLL_PITCH_YAW_SPEED_THRUST, MAVLINK_MESSAGE_INFO_ROLL_PITCH_YAW_THRUST_SETPOINT, MAVLINK_MESSAGE_INFO_ROLL_PITCH_YAW_SPEED_THRUST_SETPOINT, {NULL}, {NULL}, MAVLINK_MESSAGE_INFO_NAV_CONTROLLER_OUTPUT, {NULL}, MAVLINK_MESSAGE_INFO_STATE_CORRECTION, {NULL}, MAVLINK_MESSAGE_INFO_REQUEST_DATA_STREAM, MAVLINK_MESSAGE_INFO_DATA_STREAM, {NULL}, MAVLINK_MESSAGE_INFO_MANUAL_CONTROL, MAVLINK_MESSAGE_INFO_RC_CHANNELS_OVERRIDE, {NULL}, {NULL}, {NULL}, MAVLINK_MESSAGE_INFO_VFR_HUD, {NULL}, MAVLINK_MESSAGE_INFO_COMMAND_LONG, MAVLINK_MESSAGE_INFO_COMMAND_ACK, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, MAVLINK_MESSAGE_INFO_HIL_STATE, MAVLINK_MESSAGE_INFO_HIL_CONTROLS, MAVLINK_MESSAGE_INFO_HIL_RC_INPUTS_RAW, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, MAVLINK_MESSAGE_INFO_OPTICAL_FLOW, MAVLINK_MESSAGE_INFO_GLOBAL_VISION_POSITION_ESTIMATE, MAVLINK_MESSAGE_INFO_VISION_POSITION_ESTIMATE, MAVLINK_MESSAGE_INFO_VISION_SPEED_ESTIMATE, MAVLINK_MESSAGE_INFO_VICON_POSITION_ESTIMATE, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, MAVLINK_MESSAGE_INFO_SENSOR_OFFSETS, MAVLINK_MESSAGE_INFO_SET_MAG_OFFSETS, MAVLINK_MESSAGE_INFO_MEMINFO, MAVLINK_MESSAGE_INFO_AP_ADC, MAVLINK_MESSAGE_INFO_DIGICAM_CONFIGURE, MAVLINK_MESSAGE_INFO_DIGICAM_CONTROL, MAVLINK_MESSAGE_INFO_MOUNT_CONFIGURE, MAVLINK_MESSAGE_INFO_MOUNT_CONTROL, MAVLINK_MESSAGE_INFO_MOUNT_STATUS, {NULL}, MAVLINK_MESSAGE_INFO_FENCE_POINT, MAVLINK_MESSAGE_INFO_FENCE_FETCH_POINT, MAVLINK_MESSAGE_INFO_FENCE_STATUS, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, MAVLINK_MESSAGE_INFO_MEMORY_VECT, MAVLINK_MESSAGE_INFO_DEBUG_VECT, MAVLINK_MESSAGE_INFO_NAMED_VALUE_FLOAT, MAVLINK_MESSAGE_INFO_NAMED_VALUE_INT, MAVLINK_MESSAGE_INFO_STATUSTEXT, MAVLINK_MESSAGE_INFO_DEBUG, MAVLINK_MESSAGE_INFO_EXTENDED_MESSAGE} +#define MAVLINK_MESSAGE_INFO {MAVLINK_MESSAGE_INFO_HEARTBEAT, MAVLINK_MESSAGE_INFO_SYS_STATUS, MAVLINK_MESSAGE_INFO_SYSTEM_TIME, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, MAVLINK_MESSAGE_INFO_PING, MAVLINK_MESSAGE_INFO_CHANGE_OPERATOR_CONTROL, MAVLINK_MESSAGE_INFO_CHANGE_OPERATOR_CONTROL_ACK, MAVLINK_MESSAGE_INFO_AUTH_KEY, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, MAVLINK_MESSAGE_INFO_SET_MODE, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, MAVLINK_MESSAGE_INFO_PARAM_REQUEST_READ, MAVLINK_MESSAGE_INFO_PARAM_REQUEST_LIST, MAVLINK_MESSAGE_INFO_PARAM_VALUE, MAVLINK_MESSAGE_INFO_PARAM_SET, MAVLINK_MESSAGE_INFO_GPS_RAW_INT, MAVLINK_MESSAGE_INFO_GPS_STATUS, MAVLINK_MESSAGE_INFO_SCALED_IMU, MAVLINK_MESSAGE_INFO_RAW_IMU, MAVLINK_MESSAGE_INFO_RAW_PRESSURE, MAVLINK_MESSAGE_INFO_SCALED_PRESSURE, MAVLINK_MESSAGE_INFO_ATTITUDE, MAVLINK_MESSAGE_INFO_ATTITUDE_QUATERNION, MAVLINK_MESSAGE_INFO_LOCAL_POSITION_NED, MAVLINK_MESSAGE_INFO_GLOBAL_POSITION_INT, MAVLINK_MESSAGE_INFO_RC_CHANNELS_SCALED, MAVLINK_MESSAGE_INFO_RC_CHANNELS_RAW, MAVLINK_MESSAGE_INFO_SERVO_OUTPUT_RAW, MAVLINK_MESSAGE_INFO_MISSION_REQUEST_PARTIAL_LIST, MAVLINK_MESSAGE_INFO_MISSION_WRITE_PARTIAL_LIST, MAVLINK_MESSAGE_INFO_MISSION_ITEM, MAVLINK_MESSAGE_INFO_MISSION_REQUEST, MAVLINK_MESSAGE_INFO_MISSION_SET_CURRENT, MAVLINK_MESSAGE_INFO_MISSION_CURRENT, MAVLINK_MESSAGE_INFO_MISSION_REQUEST_LIST, MAVLINK_MESSAGE_INFO_MISSION_COUNT, MAVLINK_MESSAGE_INFO_MISSION_CLEAR_ALL, MAVLINK_MESSAGE_INFO_MISSION_ITEM_REACHED, MAVLINK_MESSAGE_INFO_MISSION_ACK, MAVLINK_MESSAGE_INFO_SET_GPS_GLOBAL_ORIGIN, MAVLINK_MESSAGE_INFO_GPS_GLOBAL_ORIGIN, MAVLINK_MESSAGE_INFO_SET_LOCAL_POSITION_SETPOINT, MAVLINK_MESSAGE_INFO_LOCAL_POSITION_SETPOINT, MAVLINK_MESSAGE_INFO_GLOBAL_POSITION_SETPOINT_INT, MAVLINK_MESSAGE_INFO_SET_GLOBAL_POSITION_SETPOINT_INT, MAVLINK_MESSAGE_INFO_SAFETY_SET_ALLOWED_AREA, MAVLINK_MESSAGE_INFO_SAFETY_ALLOWED_AREA, MAVLINK_MESSAGE_INFO_SET_ROLL_PITCH_YAW_THRUST, MAVLINK_MESSAGE_INFO_SET_ROLL_PITCH_YAW_SPEED_THRUST, MAVLINK_MESSAGE_INFO_ROLL_PITCH_YAW_THRUST_SETPOINT, MAVLINK_MESSAGE_INFO_ROLL_PITCH_YAW_SPEED_THRUST_SETPOINT, MAVLINK_MESSAGE_INFO_SET_QUAD_MOTORS_SETPOINT, MAVLINK_MESSAGE_INFO_SET_QUAD_SWARM_ROLL_PITCH_YAW_THRUST, MAVLINK_MESSAGE_INFO_NAV_CONTROLLER_OUTPUT, MAVLINK_MESSAGE_INFO_SET_QUAD_SWARM_LED_ROLL_PITCH_YAW_THRUST, MAVLINK_MESSAGE_INFO_STATE_CORRECTION, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, MAVLINK_MESSAGE_INFO_REQUEST_DATA_STREAM, MAVLINK_MESSAGE_INFO_DATA_STREAM, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, MAVLINK_MESSAGE_INFO_MANUAL_CONTROL, MAVLINK_MESSAGE_INFO_RC_CHANNELS_OVERRIDE, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, MAVLINK_MESSAGE_INFO_VFR_HUD, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, MAVLINK_MESSAGE_INFO_COMMAND_LONG, MAVLINK_MESSAGE_INFO_COMMAND_ACK, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, MAVLINK_MESSAGE_INFO_ROLL_PITCH_YAW_RATES_THRUST_SETPOINT, MAVLINK_MESSAGE_INFO_MANUAL_SETPOINT, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, MAVLINK_MESSAGE_INFO_LOCAL_POSITION_NED_SYSTEM_GLOBAL_OFFSET, MAVLINK_MESSAGE_INFO_HIL_STATE, MAVLINK_MESSAGE_INFO_HIL_CONTROLS, MAVLINK_MESSAGE_INFO_HIL_RC_INPUTS_RAW, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, MAVLINK_MESSAGE_INFO_OPTICAL_FLOW, MAVLINK_MESSAGE_INFO_GLOBAL_VISION_POSITION_ESTIMATE, MAVLINK_MESSAGE_INFO_VISION_POSITION_ESTIMATE, MAVLINK_MESSAGE_INFO_VISION_SPEED_ESTIMATE, MAVLINK_MESSAGE_INFO_VICON_POSITION_ESTIMATE, MAVLINK_MESSAGE_INFO_HIGHRES_IMU, MAVLINK_MESSAGE_INFO_OMNIDIRECTIONAL_FLOW, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, MAVLINK_MESSAGE_INFO_FILE_TRANSFER_START, MAVLINK_MESSAGE_INFO_FILE_TRANSFER_DIR_LIST, MAVLINK_MESSAGE_INFO_FILE_TRANSFER_RES, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, MAVLINK_MESSAGE_INFO_BATTERY_STATUS, MAVLINK_MESSAGE_INFO_SETPOINT_8DOF, MAVLINK_MESSAGE_INFO_SETPOINT_6DOF, MAVLINK_MESSAGE_INFO_SENSOR_OFFSETS, MAVLINK_MESSAGE_INFO_SET_MAG_OFFSETS, MAVLINK_MESSAGE_INFO_MEMINFO, MAVLINK_MESSAGE_INFO_AP_ADC, MAVLINK_MESSAGE_INFO_DIGICAM_CONFIGURE, MAVLINK_MESSAGE_INFO_DIGICAM_CONTROL, MAVLINK_MESSAGE_INFO_MOUNT_CONFIGURE, MAVLINK_MESSAGE_INFO_MOUNT_CONTROL, MAVLINK_MESSAGE_INFO_MOUNT_STATUS, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, MAVLINK_MESSAGE_INFO_FENCE_POINT, MAVLINK_MESSAGE_INFO_FENCE_FETCH_POINT, MAVLINK_MESSAGE_INFO_FENCE_STATUS, MAVLINK_MESSAGE_INFO_AHRS, MAVLINK_MESSAGE_INFO_SIMSTATE, MAVLINK_MESSAGE_INFO_HWSTATUS, MAVLINK_MESSAGE_INFO_RADIO, MAVLINK_MESSAGE_INFO_LIMITS_STATUS, MAVLINK_MESSAGE_INFO_WIND, MAVLINK_MESSAGE_INFO_DATA16, MAVLINK_MESSAGE_INFO_DATA32, MAVLINK_MESSAGE_INFO_DATA64, MAVLINK_MESSAGE_INFO_DATA96, MAVLINK_MESSAGE_INFO_RANGEFINDER, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, MAVLINK_MESSAGE_INFO_MEMORY_VECT, MAVLINK_MESSAGE_INFO_DEBUG_VECT, MAVLINK_MESSAGE_INFO_NAMED_VALUE_FLOAT, MAVLINK_MESSAGE_INFO_NAMED_VALUE_INT, MAVLINK_MESSAGE_INFO_STATUSTEXT, MAVLINK_MESSAGE_INFO_DEBUG, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}} #endif #include "../protocol.h" #define MAVLINK_ENABLED_ARDUPILOTMEGA -#include "../common/common.h" - -// MAVLINK VERSION - -#ifndef MAVLINK_VERSION -#define MAVLINK_VERSION 2 -#endif - -#if (MAVLINK_VERSION == 0) -#undef MAVLINK_VERSION -#define MAVLINK_VERSION 2 -#endif - // ENUM DEFINITIONS @@ -69,10 +56,7 @@ enum MAV_CMD MAV_CMD_NAV_RETURN_TO_LAUNCH=20, /* Return to launch location |Empty| Empty| Empty| Empty| Empty| Empty| Empty| */ MAV_CMD_NAV_LAND=21, /* Land at location |Empty| Empty| Empty| Desired yaw angle.| Latitude| Longitude| Altitude| */ MAV_CMD_NAV_TAKEOFF=22, /* Takeoff from ground / hand |Minimum pitch (if airspeed sensor present), desired pitch without sensor| Empty| Empty| Yaw angle (if magnetometer present), ignored without magnetometer| Latitude| Longitude| Altitude| */ - MAV_CMD_NAV_ROI=80, /* Sets the region of interest (ROI) for a sensor set or the - vehicle itself. This can then be used by the vehicles control - system to control the vehicle attitude and the attitude of various - sensors such as cameras. |Region of intereset mode. (see MAV_ROI enum)| MISSION index/ target ID. (see MAV_ROI enum)| ROI index (allows a vehicle to manage multiple ROI's)| Empty| x the location of the fixed ROI (see MAV_FRAME)| y| z| */ + MAV_CMD_NAV_ROI=80, /* Sets the region of interest (ROI) for a sensor set or the vehicle itself. This can then be used by the vehicles control system to control the vehicle attitude and the attitude of various sensors such as cameras. |Region of intereset mode. (see MAV_ROI enum)| MISSION index/ target ID. (see MAV_ROI enum)| ROI index (allows a vehicle to manage multiple ROI's)| Empty| x the location of the fixed ROI (see MAV_FRAME)| y| z| */ MAV_CMD_NAV_PATHPLANNING=81, /* Control autonomous path planning on the MAV. |0: Disable local obstacle avoidance / local path planning (without resetting map), 1: Enable local path planning, 2: Enable and reset local path planning| 0: Disable full path planning (without resetting map), 1: Enable, 2: Enable and reset map/occupancy grid, 3: Enable and reset planned route, but not occupancy grid| Empty| Yaw angle at goal, in compass degrees, [0..360]| Latitude/X of goal| Longitude/Y of goal| Altitude/Z of goal| */ MAV_CMD_NAV_LAST=95, /* NOP - This command is only used to mark the upper limit of the NAV/ACTION commands in the enumeration |Empty| Empty| Empty| Empty| Empty| Empty| Empty| */ MAV_CMD_CONDITION_DELAY=112, /* Delay mission state machine. |Delay in seconds (decimal)| Empty| Empty| Empty| Empty| Empty| Empty| */ @@ -95,13 +79,14 @@ enum MAV_CMD MAV_CMD_DO_MOUNT_CONFIGURE=204, /* Mission command to configure a camera or antenna mount |Mount operation mode (see MAV_MOUNT_MODE enum)| stabilize roll? (1 = yes, 0 = no)| stabilize pitch? (1 = yes, 0 = no)| stabilize yaw? (1 = yes, 0 = no)| Empty| Empty| Empty| */ MAV_CMD_DO_MOUNT_CONTROL=205, /* Mission command to control a camera or antenna mount |pitch(deg*100) or lat, depending on mount mode.| roll(deg*100) or lon depending on mount mode| yaw(deg*100) or alt (in cm) depending on mount mode| Empty| Empty| Empty| Empty| */ MAV_CMD_DO_LAST=240, /* NOP - This command is only used to mark the upper limit of the DO commands in the enumeration |Empty| Empty| Empty| Empty| Empty| Empty| Empty| */ - MAV_CMD_PREFLIGHT_CALIBRATION=241, /* Trigger calibration. This command will be only accepted if in pre-flight mode. |Gyro calibration: 0: no, 1: yes| Magnetometer calibration: 0: no, 1: yes| Ground pressure: 0: no, 1: yes| Radio calibration: 0: no, 1: yes| Empty| Empty| Empty| */ + MAV_CMD_PREFLIGHT_CALIBRATION=241, /* Trigger calibration. This command will be only accepted if in pre-flight mode. |Gyro calibration: 0: no, 1: yes| Magnetometer calibration: 0: no, 1: yes| Ground pressure: 0: no, 1: yes| Radio calibration: 0: no, 1: yes| Accelerometer calibration: 0: no, 1: yes| Empty| Empty| */ MAV_CMD_PREFLIGHT_SET_SENSOR_OFFSETS=242, /* Set sensor offsets. This command will be only accepted if in pre-flight mode. |Sensor to adjust the offsets for: 0: gyros, 1: accelerometer, 2: magnetometer, 3: barometer, 4: optical flow| X axis offset (or generic dimension 1), in the sensor's raw units| Y axis offset (or generic dimension 2), in the sensor's raw units| Z axis offset (or generic dimension 3), in the sensor's raw units| Generic dimension 4, in the sensor's raw units| Generic dimension 5, in the sensor's raw units| Generic dimension 6, in the sensor's raw units| */ MAV_CMD_PREFLIGHT_STORAGE=245, /* Request storage of different parameter values and logs. This command will be only accepted if in pre-flight mode. |Parameter storage: 0: READ FROM FLASH/EEPROM, 1: WRITE CURRENT TO FLASH/EEPROM| Mission storage: 0: READ FROM FLASH/EEPROM, 1: WRITE CURRENT TO FLASH/EEPROM| Reserved| Reserved| Empty| Empty| Empty| */ MAV_CMD_PREFLIGHT_REBOOT_SHUTDOWN=246, /* Request the reboot or shutdown of system components. |0: Do nothing for autopilot, 1: Reboot autopilot, 2: Shutdown autopilot.| 0: Do nothing for onboard computer, 1: Reboot onboard computer, 2: Shutdown onboard computer.| Reserved| Reserved| Empty| Empty| Empty| */ MAV_CMD_OVERRIDE_GOTO=252, /* Hold / continue the current action |MAV_GOTO_DO_HOLD: hold MAV_GOTO_DO_CONTINUE: continue with next item in mission plan| MAV_GOTO_HOLD_AT_CURRENT_POSITION: Hold at current position MAV_GOTO_HOLD_AT_SPECIFIED_POSITION: hold at specified position| MAV_FRAME coordinate frame of hold point| Desired yaw angle in degrees| Latitude / X position| Longitude / Y position| Altitude / Z position| */ MAV_CMD_MISSION_START=300, /* start running a mission |first_item: the first mission item to run| last_item: the last mission item to run (after this item is run, the mission ends)| */ - MAV_CMD_ENUM_END=301, /* | */ + MAV_CMD_COMPONENT_ARM_DISARM=400, /* Arms / Disarms a component |1 to arm, 0 to disarm| */ + MAV_CMD_ENUM_END=401, /* | */ }; #endif @@ -112,7 +97,8 @@ enum FENCE_ACTION { FENCE_ACTION_NONE=0, /* Disable fenced mode | */ FENCE_ACTION_GUIDED=1, /* Switched to guided mode to return point (fence point 0) | */ - FENCE_ACTION_ENUM_END=2, /* | */ + FENCE_ACTION_REPORT=2, /* Report fence breach, but don't take action | */ + FENCE_ACTION_ENUM_END=3, /* | */ }; #endif @@ -129,6 +115,46 @@ enum FENCE_BREACH }; #endif +/** @brief */ +#ifndef HAVE_ENUM_LIMITS_STATE +#define HAVE_ENUM_LIMITS_STATE +enum LIMITS_STATE +{ + LIMITS_INIT=0, /* pre-initialization | */ + LIMITS_DISABLED=1, /* disabled | */ + LIMITS_ENABLED=2, /* checking limits | */ + LIMITS_TRIGGERED=3, /* a limit has been breached | */ + LIMITS_RECOVERING=4, /* taking action eg. RTL | */ + LIMITS_RECOVERED=5, /* we're no longer in breach of a limit | */ + LIMITS_STATE_ENUM_END=6, /* | */ +}; +#endif + +/** @brief */ +#ifndef HAVE_ENUM_LIMIT_MODULE +#define HAVE_ENUM_LIMIT_MODULE +enum LIMIT_MODULE +{ + LIMIT_GPSLOCK=1, /* pre-initialization | */ + LIMIT_GEOFENCE=2, /* disabled | */ + LIMIT_ALTITUDE=4, /* checking limits | */ + LIMIT_MODULE_ENUM_END=5, /* | */ +}; +#endif + +#include "../common/common.h" + +// MAVLINK VERSION + +#ifndef MAVLINK_VERSION +#define MAVLINK_VERSION 2 +#endif + +#if (MAVLINK_VERSION == 0) +#undef MAVLINK_VERSION +#define MAVLINK_VERSION 2 +#endif + // MESSAGE DEFINITIONS #include "./mavlink_msg_sensor_offsets.h" #include "./mavlink_msg_set_mag_offsets.h" @@ -142,6 +168,17 @@ enum FENCE_BREACH #include "./mavlink_msg_fence_point.h" #include "./mavlink_msg_fence_fetch_point.h" #include "./mavlink_msg_fence_status.h" +#include "./mavlink_msg_ahrs.h" +#include "./mavlink_msg_simstate.h" +#include "./mavlink_msg_hwstatus.h" +#include "./mavlink_msg_radio.h" +#include "./mavlink_msg_limits_status.h" +#include "./mavlink_msg_wind.h" +#include "./mavlink_msg_data16.h" +#include "./mavlink_msg_data32.h" +#include "./mavlink_msg_data64.h" +#include "./mavlink_msg_data96.h" +#include "./mavlink_msg_rangefinder.h" #ifdef __cplusplus } diff --git a/src/GCS_MAVLink/include_v1.0/ardupilotmega/mavlink_msg_ahrs.h b/src/GCS_MAVLink/include_v1.0/ardupilotmega/mavlink_msg_ahrs.h new file mode 100644 index 000000000..a59f89aee --- /dev/null +++ b/src/GCS_MAVLink/include_v1.0/ardupilotmega/mavlink_msg_ahrs.h @@ -0,0 +1,276 @@ +// MESSAGE AHRS PACKING + +#define MAVLINK_MSG_ID_AHRS 163 + +typedef struct __mavlink_ahrs_t +{ + float omegaIx; ///< X gyro drift estimate rad/s + float omegaIy; ///< Y gyro drift estimate rad/s + float omegaIz; ///< Z gyro drift estimate rad/s + float accel_weight; ///< average accel_weight + float renorm_val; ///< average renormalisation value + float error_rp; ///< average error_roll_pitch value + float error_yaw; ///< average error_yaw value +} mavlink_ahrs_t; + +#define MAVLINK_MSG_ID_AHRS_LEN 28 +#define MAVLINK_MSG_ID_163_LEN 28 + + + +#define MAVLINK_MESSAGE_INFO_AHRS { \ + "AHRS", \ + 7, \ + { { "omegaIx", NULL, MAVLINK_TYPE_FLOAT, 0, 0, offsetof(mavlink_ahrs_t, omegaIx) }, \ + { "omegaIy", NULL, MAVLINK_TYPE_FLOAT, 0, 4, offsetof(mavlink_ahrs_t, omegaIy) }, \ + { "omegaIz", NULL, MAVLINK_TYPE_FLOAT, 0, 8, offsetof(mavlink_ahrs_t, omegaIz) }, \ + { "accel_weight", NULL, MAVLINK_TYPE_FLOAT, 0, 12, offsetof(mavlink_ahrs_t, accel_weight) }, \ + { "renorm_val", NULL, MAVLINK_TYPE_FLOAT, 0, 16, offsetof(mavlink_ahrs_t, renorm_val) }, \ + { "error_rp", NULL, MAVLINK_TYPE_FLOAT, 0, 20, offsetof(mavlink_ahrs_t, error_rp) }, \ + { "error_yaw", NULL, MAVLINK_TYPE_FLOAT, 0, 24, offsetof(mavlink_ahrs_t, error_yaw) }, \ + } \ +} + + +/** + * @brief Pack a ahrs message + * @param system_id ID of this system + * @param component_id ID of this component (e.g. 200 for IMU) + * @param msg The MAVLink message to compress the data into + * + * @param omegaIx X gyro drift estimate rad/s + * @param omegaIy Y gyro drift estimate rad/s + * @param omegaIz Z gyro drift estimate rad/s + * @param accel_weight average accel_weight + * @param renorm_val average renormalisation value + * @param error_rp average error_roll_pitch value + * @param error_yaw average error_yaw value + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_ahrs_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, + float omegaIx, float omegaIy, float omegaIz, float accel_weight, float renorm_val, float error_rp, float error_yaw) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[28]; + _mav_put_float(buf, 0, omegaIx); + _mav_put_float(buf, 4, omegaIy); + _mav_put_float(buf, 8, omegaIz); + _mav_put_float(buf, 12, accel_weight); + _mav_put_float(buf, 16, renorm_val); + _mav_put_float(buf, 20, error_rp); + _mav_put_float(buf, 24, error_yaw); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 28); +#else + mavlink_ahrs_t packet; + packet.omegaIx = omegaIx; + packet.omegaIy = omegaIy; + packet.omegaIz = omegaIz; + packet.accel_weight = accel_weight; + packet.renorm_val = renorm_val; + packet.error_rp = error_rp; + packet.error_yaw = error_yaw; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 28); +#endif + + msg->msgid = MAVLINK_MSG_ID_AHRS; + return mavlink_finalize_message(msg, system_id, component_id, 28, 127); +} + +/** + * @brief Pack a ahrs message on a channel + * @param system_id ID of this system + * @param component_id ID of this component (e.g. 200 for IMU) + * @param chan The MAVLink channel this message was sent over + * @param msg The MAVLink message to compress the data into + * @param omegaIx X gyro drift estimate rad/s + * @param omegaIy Y gyro drift estimate rad/s + * @param omegaIz Z gyro drift estimate rad/s + * @param accel_weight average accel_weight + * @param renorm_val average renormalisation value + * @param error_rp average error_roll_pitch value + * @param error_yaw average error_yaw value + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_ahrs_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, + mavlink_message_t* msg, + float omegaIx,float omegaIy,float omegaIz,float accel_weight,float renorm_val,float error_rp,float error_yaw) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[28]; + _mav_put_float(buf, 0, omegaIx); + _mav_put_float(buf, 4, omegaIy); + _mav_put_float(buf, 8, omegaIz); + _mav_put_float(buf, 12, accel_weight); + _mav_put_float(buf, 16, renorm_val); + _mav_put_float(buf, 20, error_rp); + _mav_put_float(buf, 24, error_yaw); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 28); +#else + mavlink_ahrs_t packet; + packet.omegaIx = omegaIx; + packet.omegaIy = omegaIy; + packet.omegaIz = omegaIz; + packet.accel_weight = accel_weight; + packet.renorm_val = renorm_val; + packet.error_rp = error_rp; + packet.error_yaw = error_yaw; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 28); +#endif + + msg->msgid = MAVLINK_MSG_ID_AHRS; + return mavlink_finalize_message_chan(msg, system_id, component_id, chan, 28, 127); +} + +/** + * @brief Encode a ahrs struct into a message + * + * @param system_id ID of this system + * @param component_id ID of this component (e.g. 200 for IMU) + * @param msg The MAVLink message to compress the data into + * @param ahrs C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_ahrs_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_ahrs_t* ahrs) +{ + return mavlink_msg_ahrs_pack(system_id, component_id, msg, ahrs->omegaIx, ahrs->omegaIy, ahrs->omegaIz, ahrs->accel_weight, ahrs->renorm_val, ahrs->error_rp, ahrs->error_yaw); +} + +/** + * @brief Send a ahrs message + * @param chan MAVLink channel to send the message + * + * @param omegaIx X gyro drift estimate rad/s + * @param omegaIy Y gyro drift estimate rad/s + * @param omegaIz Z gyro drift estimate rad/s + * @param accel_weight average accel_weight + * @param renorm_val average renormalisation value + * @param error_rp average error_roll_pitch value + * @param error_yaw average error_yaw value + */ +#ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS + +static inline void mavlink_msg_ahrs_send(mavlink_channel_t chan, float omegaIx, float omegaIy, float omegaIz, float accel_weight, float renorm_val, float error_rp, float error_yaw) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[28]; + _mav_put_float(buf, 0, omegaIx); + _mav_put_float(buf, 4, omegaIy); + _mav_put_float(buf, 8, omegaIz); + _mav_put_float(buf, 12, accel_weight); + _mav_put_float(buf, 16, renorm_val); + _mav_put_float(buf, 20, error_rp); + _mav_put_float(buf, 24, error_yaw); + + _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_AHRS, buf, 28, 127); +#else + mavlink_ahrs_t packet; + packet.omegaIx = omegaIx; + packet.omegaIy = omegaIy; + packet.omegaIz = omegaIz; + packet.accel_weight = accel_weight; + packet.renorm_val = renorm_val; + packet.error_rp = error_rp; + packet.error_yaw = error_yaw; + + _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_AHRS, (const char *)&packet, 28, 127); +#endif +} + +#endif + +// MESSAGE AHRS UNPACKING + + +/** + * @brief Get field omegaIx from ahrs message + * + * @return X gyro drift estimate rad/s + */ +static inline float mavlink_msg_ahrs_get_omegaIx(const mavlink_message_t* msg) +{ + return _MAV_RETURN_float(msg, 0); +} + +/** + * @brief Get field omegaIy from ahrs message + * + * @return Y gyro drift estimate rad/s + */ +static inline float mavlink_msg_ahrs_get_omegaIy(const mavlink_message_t* msg) +{ + return _MAV_RETURN_float(msg, 4); +} + +/** + * @brief Get field omegaIz from ahrs message + * + * @return Z gyro drift estimate rad/s + */ +static inline float mavlink_msg_ahrs_get_omegaIz(const mavlink_message_t* msg) +{ + return _MAV_RETURN_float(msg, 8); +} + +/** + * @brief Get field accel_weight from ahrs message + * + * @return average accel_weight + */ +static inline float mavlink_msg_ahrs_get_accel_weight(const mavlink_message_t* msg) +{ + return _MAV_RETURN_float(msg, 12); +} + +/** + * @brief Get field renorm_val from ahrs message + * + * @return average renormalisation value + */ +static inline float mavlink_msg_ahrs_get_renorm_val(const mavlink_message_t* msg) +{ + return _MAV_RETURN_float(msg, 16); +} + +/** + * @brief Get field error_rp from ahrs message + * + * @return average error_roll_pitch value + */ +static inline float mavlink_msg_ahrs_get_error_rp(const mavlink_message_t* msg) +{ + return _MAV_RETURN_float(msg, 20); +} + +/** + * @brief Get field error_yaw from ahrs message + * + * @return average error_yaw value + */ +static inline float mavlink_msg_ahrs_get_error_yaw(const mavlink_message_t* msg) +{ + return _MAV_RETURN_float(msg, 24); +} + +/** + * @brief Decode a ahrs message into a struct + * + * @param msg The message to decode + * @param ahrs C-struct to decode the message contents into + */ +static inline void mavlink_msg_ahrs_decode(const mavlink_message_t* msg, mavlink_ahrs_t* ahrs) +{ +#if MAVLINK_NEED_BYTE_SWAP + ahrs->omegaIx = mavlink_msg_ahrs_get_omegaIx(msg); + ahrs->omegaIy = mavlink_msg_ahrs_get_omegaIy(msg); + ahrs->omegaIz = mavlink_msg_ahrs_get_omegaIz(msg); + ahrs->accel_weight = mavlink_msg_ahrs_get_accel_weight(msg); + ahrs->renorm_val = mavlink_msg_ahrs_get_renorm_val(msg); + ahrs->error_rp = mavlink_msg_ahrs_get_error_rp(msg); + ahrs->error_yaw = mavlink_msg_ahrs_get_error_yaw(msg); +#else + memcpy(ahrs, _MAV_PAYLOAD(msg), 28); +#endif +} diff --git a/src/GCS_MAVLink/include_v1.0/ardupilotmega/mavlink_msg_ap_adc.h b/src/GCS_MAVLink/include_v1.0/ardupilotmega/mavlink_msg_ap_adc.h index dbe7f1937..ea640c4fb 100644 --- a/src/GCS_MAVLink/include_v1.0/ardupilotmega/mavlink_msg_ap_adc.h +++ b/src/GCS_MAVLink/include_v1.0/ardupilotmega/mavlink_msg_ap_adc.h @@ -56,7 +56,7 @@ static inline uint16_t mavlink_msg_ap_adc_pack(uint8_t system_id, uint8_t compon _mav_put_uint16_t(buf, 8, adc5); _mav_put_uint16_t(buf, 10, adc6); - memcpy(_MAV_PAYLOAD(msg), buf, 12); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 12); #else mavlink_ap_adc_t packet; packet.adc1 = adc1; @@ -66,7 +66,7 @@ static inline uint16_t mavlink_msg_ap_adc_pack(uint8_t system_id, uint8_t compon packet.adc5 = adc5; packet.adc6 = adc6; - memcpy(_MAV_PAYLOAD(msg), &packet, 12); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 12); #endif msg->msgid = MAVLINK_MSG_ID_AP_ADC; @@ -100,7 +100,7 @@ static inline uint16_t mavlink_msg_ap_adc_pack_chan(uint8_t system_id, uint8_t c _mav_put_uint16_t(buf, 8, adc5); _mav_put_uint16_t(buf, 10, adc6); - memcpy(_MAV_PAYLOAD(msg), buf, 12); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 12); #else mavlink_ap_adc_t packet; packet.adc1 = adc1; @@ -110,7 +110,7 @@ static inline uint16_t mavlink_msg_ap_adc_pack_chan(uint8_t system_id, uint8_t c packet.adc5 = adc5; packet.adc6 = adc6; - memcpy(_MAV_PAYLOAD(msg), &packet, 12); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 12); #endif msg->msgid = MAVLINK_MSG_ID_AP_ADC; diff --git a/src/GCS_MAVLink/include_v1.0/ardupilotmega/mavlink_msg_data16.h b/src/GCS_MAVLink/include_v1.0/ardupilotmega/mavlink_msg_data16.h new file mode 100644 index 000000000..359201c8c --- /dev/null +++ b/src/GCS_MAVLink/include_v1.0/ardupilotmega/mavlink_msg_data16.h @@ -0,0 +1,182 @@ +// MESSAGE DATA16 PACKING + +#define MAVLINK_MSG_ID_DATA16 169 + +typedef struct __mavlink_data16_t +{ + uint8_t type; ///< data type + uint8_t len; ///< data length + uint8_t data[16]; ///< raw data +} mavlink_data16_t; + +#define MAVLINK_MSG_ID_DATA16_LEN 18 +#define MAVLINK_MSG_ID_169_LEN 18 + +#define MAVLINK_MSG_DATA16_FIELD_DATA_LEN 16 + +#define MAVLINK_MESSAGE_INFO_DATA16 { \ + "DATA16", \ + 3, \ + { { "type", NULL, MAVLINK_TYPE_UINT8_T, 0, 0, offsetof(mavlink_data16_t, type) }, \ + { "len", NULL, MAVLINK_TYPE_UINT8_T, 0, 1, offsetof(mavlink_data16_t, len) }, \ + { "data", NULL, MAVLINK_TYPE_UINT8_T, 16, 2, offsetof(mavlink_data16_t, data) }, \ + } \ +} + + +/** + * @brief Pack a data16 message + * @param system_id ID of this system + * @param component_id ID of this component (e.g. 200 for IMU) + * @param msg The MAVLink message to compress the data into + * + * @param type data type + * @param len data length + * @param data raw data + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_data16_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, + uint8_t type, uint8_t len, const uint8_t *data) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[18]; + _mav_put_uint8_t(buf, 0, type); + _mav_put_uint8_t(buf, 1, len); + _mav_put_uint8_t_array(buf, 2, data, 16); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 18); +#else + mavlink_data16_t packet; + packet.type = type; + packet.len = len; + mav_array_memcpy(packet.data, data, sizeof(uint8_t)*16); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 18); +#endif + + msg->msgid = MAVLINK_MSG_ID_DATA16; + return mavlink_finalize_message(msg, system_id, component_id, 18, 234); +} + +/** + * @brief Pack a data16 message on a channel + * @param system_id ID of this system + * @param component_id ID of this component (e.g. 200 for IMU) + * @param chan The MAVLink channel this message was sent over + * @param msg The MAVLink message to compress the data into + * @param type data type + * @param len data length + * @param data raw data + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_data16_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, + mavlink_message_t* msg, + uint8_t type,uint8_t len,const uint8_t *data) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[18]; + _mav_put_uint8_t(buf, 0, type); + _mav_put_uint8_t(buf, 1, len); + _mav_put_uint8_t_array(buf, 2, data, 16); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 18); +#else + mavlink_data16_t packet; + packet.type = type; + packet.len = len; + mav_array_memcpy(packet.data, data, sizeof(uint8_t)*16); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 18); +#endif + + msg->msgid = MAVLINK_MSG_ID_DATA16; + return mavlink_finalize_message_chan(msg, system_id, component_id, chan, 18, 234); +} + +/** + * @brief Encode a data16 struct into a message + * + * @param system_id ID of this system + * @param component_id ID of this component (e.g. 200 for IMU) + * @param msg The MAVLink message to compress the data into + * @param data16 C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_data16_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_data16_t* data16) +{ + return mavlink_msg_data16_pack(system_id, component_id, msg, data16->type, data16->len, data16->data); +} + +/** + * @brief Send a data16 message + * @param chan MAVLink channel to send the message + * + * @param type data type + * @param len data length + * @param data raw data + */ +#ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS + +static inline void mavlink_msg_data16_send(mavlink_channel_t chan, uint8_t type, uint8_t len, const uint8_t *data) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[18]; + _mav_put_uint8_t(buf, 0, type); + _mav_put_uint8_t(buf, 1, len); + _mav_put_uint8_t_array(buf, 2, data, 16); + _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_DATA16, buf, 18, 234); +#else + mavlink_data16_t packet; + packet.type = type; + packet.len = len; + mav_array_memcpy(packet.data, data, sizeof(uint8_t)*16); + _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_DATA16, (const char *)&packet, 18, 234); +#endif +} + +#endif + +// MESSAGE DATA16 UNPACKING + + +/** + * @brief Get field type from data16 message + * + * @return data type + */ +static inline uint8_t mavlink_msg_data16_get_type(const mavlink_message_t* msg) +{ + return _MAV_RETURN_uint8_t(msg, 0); +} + +/** + * @brief Get field len from data16 message + * + * @return data length + */ +static inline uint8_t mavlink_msg_data16_get_len(const mavlink_message_t* msg) +{ + return _MAV_RETURN_uint8_t(msg, 1); +} + +/** + * @brief Get field data from data16 message + * + * @return raw data + */ +static inline uint16_t mavlink_msg_data16_get_data(const mavlink_message_t* msg, uint8_t *data) +{ + return _MAV_RETURN_uint8_t_array(msg, data, 16, 2); +} + +/** + * @brief Decode a data16 message into a struct + * + * @param msg The message to decode + * @param data16 C-struct to decode the message contents into + */ +static inline void mavlink_msg_data16_decode(const mavlink_message_t* msg, mavlink_data16_t* data16) +{ +#if MAVLINK_NEED_BYTE_SWAP + data16->type = mavlink_msg_data16_get_type(msg); + data16->len = mavlink_msg_data16_get_len(msg); + mavlink_msg_data16_get_data(msg, data16->data); +#else + memcpy(data16, _MAV_PAYLOAD(msg), 18); +#endif +} diff --git a/src/GCS_MAVLink/include_v1.0/ardupilotmega/mavlink_msg_data32.h b/src/GCS_MAVLink/include_v1.0/ardupilotmega/mavlink_msg_data32.h new file mode 100644 index 000000000..a9b3fe28d --- /dev/null +++ b/src/GCS_MAVLink/include_v1.0/ardupilotmega/mavlink_msg_data32.h @@ -0,0 +1,182 @@ +// MESSAGE DATA32 PACKING + +#define MAVLINK_MSG_ID_DATA32 170 + +typedef struct __mavlink_data32_t +{ + uint8_t type; ///< data type + uint8_t len; ///< data length + uint8_t data[32]; ///< raw data +} mavlink_data32_t; + +#define MAVLINK_MSG_ID_DATA32_LEN 34 +#define MAVLINK_MSG_ID_170_LEN 34 + +#define MAVLINK_MSG_DATA32_FIELD_DATA_LEN 32 + +#define MAVLINK_MESSAGE_INFO_DATA32 { \ + "DATA32", \ + 3, \ + { { "type", NULL, MAVLINK_TYPE_UINT8_T, 0, 0, offsetof(mavlink_data32_t, type) }, \ + { "len", NULL, MAVLINK_TYPE_UINT8_T, 0, 1, offsetof(mavlink_data32_t, len) }, \ + { "data", NULL, MAVLINK_TYPE_UINT8_T, 32, 2, offsetof(mavlink_data32_t, data) }, \ + } \ +} + + +/** + * @brief Pack a data32 message + * @param system_id ID of this system + * @param component_id ID of this component (e.g. 200 for IMU) + * @param msg The MAVLink message to compress the data into + * + * @param type data type + * @param len data length + * @param data raw data + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_data32_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, + uint8_t type, uint8_t len, const uint8_t *data) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[34]; + _mav_put_uint8_t(buf, 0, type); + _mav_put_uint8_t(buf, 1, len); + _mav_put_uint8_t_array(buf, 2, data, 32); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 34); +#else + mavlink_data32_t packet; + packet.type = type; + packet.len = len; + mav_array_memcpy(packet.data, data, sizeof(uint8_t)*32); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 34); +#endif + + msg->msgid = MAVLINK_MSG_ID_DATA32; + return mavlink_finalize_message(msg, system_id, component_id, 34, 73); +} + +/** + * @brief Pack a data32 message on a channel + * @param system_id ID of this system + * @param component_id ID of this component (e.g. 200 for IMU) + * @param chan The MAVLink channel this message was sent over + * @param msg The MAVLink message to compress the data into + * @param type data type + * @param len data length + * @param data raw data + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_data32_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, + mavlink_message_t* msg, + uint8_t type,uint8_t len,const uint8_t *data) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[34]; + _mav_put_uint8_t(buf, 0, type); + _mav_put_uint8_t(buf, 1, len); + _mav_put_uint8_t_array(buf, 2, data, 32); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 34); +#else + mavlink_data32_t packet; + packet.type = type; + packet.len = len; + mav_array_memcpy(packet.data, data, sizeof(uint8_t)*32); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 34); +#endif + + msg->msgid = MAVLINK_MSG_ID_DATA32; + return mavlink_finalize_message_chan(msg, system_id, component_id, chan, 34, 73); +} + +/** + * @brief Encode a data32 struct into a message + * + * @param system_id ID of this system + * @param component_id ID of this component (e.g. 200 for IMU) + * @param msg The MAVLink message to compress the data into + * @param data32 C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_data32_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_data32_t* data32) +{ + return mavlink_msg_data32_pack(system_id, component_id, msg, data32->type, data32->len, data32->data); +} + +/** + * @brief Send a data32 message + * @param chan MAVLink channel to send the message + * + * @param type data type + * @param len data length + * @param data raw data + */ +#ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS + +static inline void mavlink_msg_data32_send(mavlink_channel_t chan, uint8_t type, uint8_t len, const uint8_t *data) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[34]; + _mav_put_uint8_t(buf, 0, type); + _mav_put_uint8_t(buf, 1, len); + _mav_put_uint8_t_array(buf, 2, data, 32); + _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_DATA32, buf, 34, 73); +#else + mavlink_data32_t packet; + packet.type = type; + packet.len = len; + mav_array_memcpy(packet.data, data, sizeof(uint8_t)*32); + _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_DATA32, (const char *)&packet, 34, 73); +#endif +} + +#endif + +// MESSAGE DATA32 UNPACKING + + +/** + * @brief Get field type from data32 message + * + * @return data type + */ +static inline uint8_t mavlink_msg_data32_get_type(const mavlink_message_t* msg) +{ + return _MAV_RETURN_uint8_t(msg, 0); +} + +/** + * @brief Get field len from data32 message + * + * @return data length + */ +static inline uint8_t mavlink_msg_data32_get_len(const mavlink_message_t* msg) +{ + return _MAV_RETURN_uint8_t(msg, 1); +} + +/** + * @brief Get field data from data32 message + * + * @return raw data + */ +static inline uint16_t mavlink_msg_data32_get_data(const mavlink_message_t* msg, uint8_t *data) +{ + return _MAV_RETURN_uint8_t_array(msg, data, 32, 2); +} + +/** + * @brief Decode a data32 message into a struct + * + * @param msg The message to decode + * @param data32 C-struct to decode the message contents into + */ +static inline void mavlink_msg_data32_decode(const mavlink_message_t* msg, mavlink_data32_t* data32) +{ +#if MAVLINK_NEED_BYTE_SWAP + data32->type = mavlink_msg_data32_get_type(msg); + data32->len = mavlink_msg_data32_get_len(msg); + mavlink_msg_data32_get_data(msg, data32->data); +#else + memcpy(data32, _MAV_PAYLOAD(msg), 34); +#endif +} diff --git a/src/GCS_MAVLink/include_v1.0/ardupilotmega/mavlink_msg_data64.h b/src/GCS_MAVLink/include_v1.0/ardupilotmega/mavlink_msg_data64.h new file mode 100644 index 000000000..29dcaa6d8 --- /dev/null +++ b/src/GCS_MAVLink/include_v1.0/ardupilotmega/mavlink_msg_data64.h @@ -0,0 +1,182 @@ +// MESSAGE DATA64 PACKING + +#define MAVLINK_MSG_ID_DATA64 171 + +typedef struct __mavlink_data64_t +{ + uint8_t type; ///< data type + uint8_t len; ///< data length + uint8_t data[64]; ///< raw data +} mavlink_data64_t; + +#define MAVLINK_MSG_ID_DATA64_LEN 66 +#define MAVLINK_MSG_ID_171_LEN 66 + +#define MAVLINK_MSG_DATA64_FIELD_DATA_LEN 64 + +#define MAVLINK_MESSAGE_INFO_DATA64 { \ + "DATA64", \ + 3, \ + { { "type", NULL, MAVLINK_TYPE_UINT8_T, 0, 0, offsetof(mavlink_data64_t, type) }, \ + { "len", NULL, MAVLINK_TYPE_UINT8_T, 0, 1, offsetof(mavlink_data64_t, len) }, \ + { "data", NULL, MAVLINK_TYPE_UINT8_T, 64, 2, offsetof(mavlink_data64_t, data) }, \ + } \ +} + + +/** + * @brief Pack a data64 message + * @param system_id ID of this system + * @param component_id ID of this component (e.g. 200 for IMU) + * @param msg The MAVLink message to compress the data into + * + * @param type data type + * @param len data length + * @param data raw data + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_data64_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, + uint8_t type, uint8_t len, const uint8_t *data) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[66]; + _mav_put_uint8_t(buf, 0, type); + _mav_put_uint8_t(buf, 1, len); + _mav_put_uint8_t_array(buf, 2, data, 64); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 66); +#else + mavlink_data64_t packet; + packet.type = type; + packet.len = len; + mav_array_memcpy(packet.data, data, sizeof(uint8_t)*64); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 66); +#endif + + msg->msgid = MAVLINK_MSG_ID_DATA64; + return mavlink_finalize_message(msg, system_id, component_id, 66, 181); +} + +/** + * @brief Pack a data64 message on a channel + * @param system_id ID of this system + * @param component_id ID of this component (e.g. 200 for IMU) + * @param chan The MAVLink channel this message was sent over + * @param msg The MAVLink message to compress the data into + * @param type data type + * @param len data length + * @param data raw data + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_data64_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, + mavlink_message_t* msg, + uint8_t type,uint8_t len,const uint8_t *data) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[66]; + _mav_put_uint8_t(buf, 0, type); + _mav_put_uint8_t(buf, 1, len); + _mav_put_uint8_t_array(buf, 2, data, 64); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 66); +#else + mavlink_data64_t packet; + packet.type = type; + packet.len = len; + mav_array_memcpy(packet.data, data, sizeof(uint8_t)*64); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 66); +#endif + + msg->msgid = MAVLINK_MSG_ID_DATA64; + return mavlink_finalize_message_chan(msg, system_id, component_id, chan, 66, 181); +} + +/** + * @brief Encode a data64 struct into a message + * + * @param system_id ID of this system + * @param component_id ID of this component (e.g. 200 for IMU) + * @param msg The MAVLink message to compress the data into + * @param data64 C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_data64_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_data64_t* data64) +{ + return mavlink_msg_data64_pack(system_id, component_id, msg, data64->type, data64->len, data64->data); +} + +/** + * @brief Send a data64 message + * @param chan MAVLink channel to send the message + * + * @param type data type + * @param len data length + * @param data raw data + */ +#ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS + +static inline void mavlink_msg_data64_send(mavlink_channel_t chan, uint8_t type, uint8_t len, const uint8_t *data) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[66]; + _mav_put_uint8_t(buf, 0, type); + _mav_put_uint8_t(buf, 1, len); + _mav_put_uint8_t_array(buf, 2, data, 64); + _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_DATA64, buf, 66, 181); +#else + mavlink_data64_t packet; + packet.type = type; + packet.len = len; + mav_array_memcpy(packet.data, data, sizeof(uint8_t)*64); + _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_DATA64, (const char *)&packet, 66, 181); +#endif +} + +#endif + +// MESSAGE DATA64 UNPACKING + + +/** + * @brief Get field type from data64 message + * + * @return data type + */ +static inline uint8_t mavlink_msg_data64_get_type(const mavlink_message_t* msg) +{ + return _MAV_RETURN_uint8_t(msg, 0); +} + +/** + * @brief Get field len from data64 message + * + * @return data length + */ +static inline uint8_t mavlink_msg_data64_get_len(const mavlink_message_t* msg) +{ + return _MAV_RETURN_uint8_t(msg, 1); +} + +/** + * @brief Get field data from data64 message + * + * @return raw data + */ +static inline uint16_t mavlink_msg_data64_get_data(const mavlink_message_t* msg, uint8_t *data) +{ + return _MAV_RETURN_uint8_t_array(msg, data, 64, 2); +} + +/** + * @brief Decode a data64 message into a struct + * + * @param msg The message to decode + * @param data64 C-struct to decode the message contents into + */ +static inline void mavlink_msg_data64_decode(const mavlink_message_t* msg, mavlink_data64_t* data64) +{ +#if MAVLINK_NEED_BYTE_SWAP + data64->type = mavlink_msg_data64_get_type(msg); + data64->len = mavlink_msg_data64_get_len(msg); + mavlink_msg_data64_get_data(msg, data64->data); +#else + memcpy(data64, _MAV_PAYLOAD(msg), 66); +#endif +} diff --git a/src/GCS_MAVLink/include_v1.0/ardupilotmega/mavlink_msg_data96.h b/src/GCS_MAVLink/include_v1.0/ardupilotmega/mavlink_msg_data96.h new file mode 100644 index 000000000..df0821c87 --- /dev/null +++ b/src/GCS_MAVLink/include_v1.0/ardupilotmega/mavlink_msg_data96.h @@ -0,0 +1,182 @@ +// MESSAGE DATA96 PACKING + +#define MAVLINK_MSG_ID_DATA96 172 + +typedef struct __mavlink_data96_t +{ + uint8_t type; ///< data type + uint8_t len; ///< data length + uint8_t data[96]; ///< raw data +} mavlink_data96_t; + +#define MAVLINK_MSG_ID_DATA96_LEN 98 +#define MAVLINK_MSG_ID_172_LEN 98 + +#define MAVLINK_MSG_DATA96_FIELD_DATA_LEN 96 + +#define MAVLINK_MESSAGE_INFO_DATA96 { \ + "DATA96", \ + 3, \ + { { "type", NULL, MAVLINK_TYPE_UINT8_T, 0, 0, offsetof(mavlink_data96_t, type) }, \ + { "len", NULL, MAVLINK_TYPE_UINT8_T, 0, 1, offsetof(mavlink_data96_t, len) }, \ + { "data", NULL, MAVLINK_TYPE_UINT8_T, 96, 2, offsetof(mavlink_data96_t, data) }, \ + } \ +} + + +/** + * @brief Pack a data96 message + * @param system_id ID of this system + * @param component_id ID of this component (e.g. 200 for IMU) + * @param msg The MAVLink message to compress the data into + * + * @param type data type + * @param len data length + * @param data raw data + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_data96_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, + uint8_t type, uint8_t len, const uint8_t *data) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[98]; + _mav_put_uint8_t(buf, 0, type); + _mav_put_uint8_t(buf, 1, len); + _mav_put_uint8_t_array(buf, 2, data, 96); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 98); +#else + mavlink_data96_t packet; + packet.type = type; + packet.len = len; + mav_array_memcpy(packet.data, data, sizeof(uint8_t)*96); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 98); +#endif + + msg->msgid = MAVLINK_MSG_ID_DATA96; + return mavlink_finalize_message(msg, system_id, component_id, 98, 22); +} + +/** + * @brief Pack a data96 message on a channel + * @param system_id ID of this system + * @param component_id ID of this component (e.g. 200 for IMU) + * @param chan The MAVLink channel this message was sent over + * @param msg The MAVLink message to compress the data into + * @param type data type + * @param len data length + * @param data raw data + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_data96_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, + mavlink_message_t* msg, + uint8_t type,uint8_t len,const uint8_t *data) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[98]; + _mav_put_uint8_t(buf, 0, type); + _mav_put_uint8_t(buf, 1, len); + _mav_put_uint8_t_array(buf, 2, data, 96); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 98); +#else + mavlink_data96_t packet; + packet.type = type; + packet.len = len; + mav_array_memcpy(packet.data, data, sizeof(uint8_t)*96); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 98); +#endif + + msg->msgid = MAVLINK_MSG_ID_DATA96; + return mavlink_finalize_message_chan(msg, system_id, component_id, chan, 98, 22); +} + +/** + * @brief Encode a data96 struct into a message + * + * @param system_id ID of this system + * @param component_id ID of this component (e.g. 200 for IMU) + * @param msg The MAVLink message to compress the data into + * @param data96 C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_data96_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_data96_t* data96) +{ + return mavlink_msg_data96_pack(system_id, component_id, msg, data96->type, data96->len, data96->data); +} + +/** + * @brief Send a data96 message + * @param chan MAVLink channel to send the message + * + * @param type data type + * @param len data length + * @param data raw data + */ +#ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS + +static inline void mavlink_msg_data96_send(mavlink_channel_t chan, uint8_t type, uint8_t len, const uint8_t *data) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[98]; + _mav_put_uint8_t(buf, 0, type); + _mav_put_uint8_t(buf, 1, len); + _mav_put_uint8_t_array(buf, 2, data, 96); + _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_DATA96, buf, 98, 22); +#else + mavlink_data96_t packet; + packet.type = type; + packet.len = len; + mav_array_memcpy(packet.data, data, sizeof(uint8_t)*96); + _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_DATA96, (const char *)&packet, 98, 22); +#endif +} + +#endif + +// MESSAGE DATA96 UNPACKING + + +/** + * @brief Get field type from data96 message + * + * @return data type + */ +static inline uint8_t mavlink_msg_data96_get_type(const mavlink_message_t* msg) +{ + return _MAV_RETURN_uint8_t(msg, 0); +} + +/** + * @brief Get field len from data96 message + * + * @return data length + */ +static inline uint8_t mavlink_msg_data96_get_len(const mavlink_message_t* msg) +{ + return _MAV_RETURN_uint8_t(msg, 1); +} + +/** + * @brief Get field data from data96 message + * + * @return raw data + */ +static inline uint16_t mavlink_msg_data96_get_data(const mavlink_message_t* msg, uint8_t *data) +{ + return _MAV_RETURN_uint8_t_array(msg, data, 96, 2); +} + +/** + * @brief Decode a data96 message into a struct + * + * @param msg The message to decode + * @param data96 C-struct to decode the message contents into + */ +static inline void mavlink_msg_data96_decode(const mavlink_message_t* msg, mavlink_data96_t* data96) +{ +#if MAVLINK_NEED_BYTE_SWAP + data96->type = mavlink_msg_data96_get_type(msg); + data96->len = mavlink_msg_data96_get_len(msg); + mavlink_msg_data96_get_data(msg, data96->data); +#else + memcpy(data96, _MAV_PAYLOAD(msg), 98); +#endif +} diff --git a/src/GCS_MAVLink/include_v1.0/ardupilotmega/mavlink_msg_digicam_configure.h b/src/GCS_MAVLink/include_v1.0/ardupilotmega/mavlink_msg_digicam_configure.h index 89df0d9a4..cc49c5025 100644 --- a/src/GCS_MAVLink/include_v1.0/ardupilotmega/mavlink_msg_digicam_configure.h +++ b/src/GCS_MAVLink/include_v1.0/ardupilotmega/mavlink_msg_digicam_configure.h @@ -76,7 +76,7 @@ static inline uint16_t mavlink_msg_digicam_configure_pack(uint8_t system_id, uin _mav_put_uint8_t(buf, 13, engine_cut_off); _mav_put_uint8_t(buf, 14, extra_param); - memcpy(_MAV_PAYLOAD(msg), buf, 15); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 15); #else mavlink_digicam_configure_t packet; packet.extra_value = extra_value; @@ -91,7 +91,7 @@ static inline uint16_t mavlink_msg_digicam_configure_pack(uint8_t system_id, uin packet.engine_cut_off = engine_cut_off; packet.extra_param = extra_param; - memcpy(_MAV_PAYLOAD(msg), &packet, 15); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 15); #endif msg->msgid = MAVLINK_MSG_ID_DIGICAM_CONFIGURE; @@ -135,7 +135,7 @@ static inline uint16_t mavlink_msg_digicam_configure_pack_chan(uint8_t system_id _mav_put_uint8_t(buf, 13, engine_cut_off); _mav_put_uint8_t(buf, 14, extra_param); - memcpy(_MAV_PAYLOAD(msg), buf, 15); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 15); #else mavlink_digicam_configure_t packet; packet.extra_value = extra_value; @@ -150,7 +150,7 @@ static inline uint16_t mavlink_msg_digicam_configure_pack_chan(uint8_t system_id packet.engine_cut_off = engine_cut_off; packet.extra_param = extra_param; - memcpy(_MAV_PAYLOAD(msg), &packet, 15); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 15); #endif msg->msgid = MAVLINK_MSG_ID_DIGICAM_CONFIGURE; diff --git a/src/GCS_MAVLink/include_v1.0/ardupilotmega/mavlink_msg_digicam_control.h b/src/GCS_MAVLink/include_v1.0/ardupilotmega/mavlink_msg_digicam_control.h index baf63d6c7..a3b4878c4 100644 --- a/src/GCS_MAVLink/include_v1.0/ardupilotmega/mavlink_msg_digicam_control.h +++ b/src/GCS_MAVLink/include_v1.0/ardupilotmega/mavlink_msg_digicam_control.h @@ -72,7 +72,7 @@ static inline uint16_t mavlink_msg_digicam_control_pack(uint8_t system_id, uint8 _mav_put_uint8_t(buf, 11, command_id); _mav_put_uint8_t(buf, 12, extra_param); - memcpy(_MAV_PAYLOAD(msg), buf, 13); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 13); #else mavlink_digicam_control_t packet; packet.extra_value = extra_value; @@ -86,7 +86,7 @@ static inline uint16_t mavlink_msg_digicam_control_pack(uint8_t system_id, uint8 packet.command_id = command_id; packet.extra_param = extra_param; - memcpy(_MAV_PAYLOAD(msg), &packet, 13); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 13); #endif msg->msgid = MAVLINK_MSG_ID_DIGICAM_CONTROL; @@ -128,7 +128,7 @@ static inline uint16_t mavlink_msg_digicam_control_pack_chan(uint8_t system_id, _mav_put_uint8_t(buf, 11, command_id); _mav_put_uint8_t(buf, 12, extra_param); - memcpy(_MAV_PAYLOAD(msg), buf, 13); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 13); #else mavlink_digicam_control_t packet; packet.extra_value = extra_value; @@ -142,7 +142,7 @@ static inline uint16_t mavlink_msg_digicam_control_pack_chan(uint8_t system_id, packet.command_id = command_id; packet.extra_param = extra_param; - memcpy(_MAV_PAYLOAD(msg), &packet, 13); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 13); #endif msg->msgid = MAVLINK_MSG_ID_DIGICAM_CONTROL; diff --git a/src/GCS_MAVLink/include_v1.0/ardupilotmega/mavlink_msg_fence_fetch_point.h b/src/GCS_MAVLink/include_v1.0/ardupilotmega/mavlink_msg_fence_fetch_point.h index e79ebeca3..c1e405b0a 100644 --- a/src/GCS_MAVLink/include_v1.0/ardupilotmega/mavlink_msg_fence_fetch_point.h +++ b/src/GCS_MAVLink/include_v1.0/ardupilotmega/mavlink_msg_fence_fetch_point.h @@ -44,14 +44,14 @@ static inline uint16_t mavlink_msg_fence_fetch_point_pack(uint8_t system_id, uin _mav_put_uint8_t(buf, 1, target_component); _mav_put_uint8_t(buf, 2, idx); - memcpy(_MAV_PAYLOAD(msg), buf, 3); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 3); #else mavlink_fence_fetch_point_t packet; packet.target_system = target_system; packet.target_component = target_component; packet.idx = idx; - memcpy(_MAV_PAYLOAD(msg), &packet, 3); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 3); #endif msg->msgid = MAVLINK_MSG_ID_FENCE_FETCH_POINT; @@ -79,14 +79,14 @@ static inline uint16_t mavlink_msg_fence_fetch_point_pack_chan(uint8_t system_id _mav_put_uint8_t(buf, 1, target_component); _mav_put_uint8_t(buf, 2, idx); - memcpy(_MAV_PAYLOAD(msg), buf, 3); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 3); #else mavlink_fence_fetch_point_t packet; packet.target_system = target_system; packet.target_component = target_component; packet.idx = idx; - memcpy(_MAV_PAYLOAD(msg), &packet, 3); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 3); #endif msg->msgid = MAVLINK_MSG_ID_FENCE_FETCH_POINT; diff --git a/src/GCS_MAVLink/include_v1.0/ardupilotmega/mavlink_msg_fence_point.h b/src/GCS_MAVLink/include_v1.0/ardupilotmega/mavlink_msg_fence_point.h index 8890a1e0b..b31319c74 100644 --- a/src/GCS_MAVLink/include_v1.0/ardupilotmega/mavlink_msg_fence_point.h +++ b/src/GCS_MAVLink/include_v1.0/ardupilotmega/mavlink_msg_fence_point.h @@ -56,7 +56,7 @@ static inline uint16_t mavlink_msg_fence_point_pack(uint8_t system_id, uint8_t c _mav_put_uint8_t(buf, 10, idx); _mav_put_uint8_t(buf, 11, count); - memcpy(_MAV_PAYLOAD(msg), buf, 12); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 12); #else mavlink_fence_point_t packet; packet.lat = lat; @@ -66,7 +66,7 @@ static inline uint16_t mavlink_msg_fence_point_pack(uint8_t system_id, uint8_t c packet.idx = idx; packet.count = count; - memcpy(_MAV_PAYLOAD(msg), &packet, 12); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 12); #endif msg->msgid = MAVLINK_MSG_ID_FENCE_POINT; @@ -100,7 +100,7 @@ static inline uint16_t mavlink_msg_fence_point_pack_chan(uint8_t system_id, uint _mav_put_uint8_t(buf, 10, idx); _mav_put_uint8_t(buf, 11, count); - memcpy(_MAV_PAYLOAD(msg), buf, 12); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 12); #else mavlink_fence_point_t packet; packet.lat = lat; @@ -110,7 +110,7 @@ static inline uint16_t mavlink_msg_fence_point_pack_chan(uint8_t system_id, uint packet.idx = idx; packet.count = count; - memcpy(_MAV_PAYLOAD(msg), &packet, 12); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 12); #endif msg->msgid = MAVLINK_MSG_ID_FENCE_POINT; diff --git a/src/GCS_MAVLink/include_v1.0/ardupilotmega/mavlink_msg_fence_status.h b/src/GCS_MAVLink/include_v1.0/ardupilotmega/mavlink_msg_fence_status.h index 56a6cf6c0..ce3e7ee67 100644 --- a/src/GCS_MAVLink/include_v1.0/ardupilotmega/mavlink_msg_fence_status.h +++ b/src/GCS_MAVLink/include_v1.0/ardupilotmega/mavlink_msg_fence_status.h @@ -48,7 +48,7 @@ static inline uint16_t mavlink_msg_fence_status_pack(uint8_t system_id, uint8_t _mav_put_uint8_t(buf, 6, breach_status); _mav_put_uint8_t(buf, 7, breach_type); - memcpy(_MAV_PAYLOAD(msg), buf, 8); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 8); #else mavlink_fence_status_t packet; packet.breach_time = breach_time; @@ -56,7 +56,7 @@ static inline uint16_t mavlink_msg_fence_status_pack(uint8_t system_id, uint8_t packet.breach_status = breach_status; packet.breach_type = breach_type; - memcpy(_MAV_PAYLOAD(msg), &packet, 8); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 8); #endif msg->msgid = MAVLINK_MSG_ID_FENCE_STATUS; @@ -86,7 +86,7 @@ static inline uint16_t mavlink_msg_fence_status_pack_chan(uint8_t system_id, uin _mav_put_uint8_t(buf, 6, breach_status); _mav_put_uint8_t(buf, 7, breach_type); - memcpy(_MAV_PAYLOAD(msg), buf, 8); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 8); #else mavlink_fence_status_t packet; packet.breach_time = breach_time; @@ -94,7 +94,7 @@ static inline uint16_t mavlink_msg_fence_status_pack_chan(uint8_t system_id, uin packet.breach_status = breach_status; packet.breach_type = breach_type; - memcpy(_MAV_PAYLOAD(msg), &packet, 8); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 8); #endif msg->msgid = MAVLINK_MSG_ID_FENCE_STATUS; diff --git a/src/GCS_MAVLink/include_v1.0/ardupilotmega/mavlink_msg_hwstatus.h b/src/GCS_MAVLink/include_v1.0/ardupilotmega/mavlink_msg_hwstatus.h new file mode 100644 index 000000000..952e65951 --- /dev/null +++ b/src/GCS_MAVLink/include_v1.0/ardupilotmega/mavlink_msg_hwstatus.h @@ -0,0 +1,166 @@ +// MESSAGE HWSTATUS PACKING + +#define MAVLINK_MSG_ID_HWSTATUS 165 + +typedef struct __mavlink_hwstatus_t +{ + uint16_t Vcc; ///< board voltage (mV) + uint8_t I2Cerr; ///< I2C error count +} mavlink_hwstatus_t; + +#define MAVLINK_MSG_ID_HWSTATUS_LEN 3 +#define MAVLINK_MSG_ID_165_LEN 3 + + + +#define MAVLINK_MESSAGE_INFO_HWSTATUS { \ + "HWSTATUS", \ + 2, \ + { { "Vcc", NULL, MAVLINK_TYPE_UINT16_T, 0, 0, offsetof(mavlink_hwstatus_t, Vcc) }, \ + { "I2Cerr", NULL, MAVLINK_TYPE_UINT8_T, 0, 2, offsetof(mavlink_hwstatus_t, I2Cerr) }, \ + } \ +} + + +/** + * @brief Pack a hwstatus message + * @param system_id ID of this system + * @param component_id ID of this component (e.g. 200 for IMU) + * @param msg The MAVLink message to compress the data into + * + * @param Vcc board voltage (mV) + * @param I2Cerr I2C error count + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_hwstatus_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, + uint16_t Vcc, uint8_t I2Cerr) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[3]; + _mav_put_uint16_t(buf, 0, Vcc); + _mav_put_uint8_t(buf, 2, I2Cerr); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 3); +#else + mavlink_hwstatus_t packet; + packet.Vcc = Vcc; + packet.I2Cerr = I2Cerr; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 3); +#endif + + msg->msgid = MAVLINK_MSG_ID_HWSTATUS; + return mavlink_finalize_message(msg, system_id, component_id, 3, 21); +} + +/** + * @brief Pack a hwstatus message on a channel + * @param system_id ID of this system + * @param component_id ID of this component (e.g. 200 for IMU) + * @param chan The MAVLink channel this message was sent over + * @param msg The MAVLink message to compress the data into + * @param Vcc board voltage (mV) + * @param I2Cerr I2C error count + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_hwstatus_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, + mavlink_message_t* msg, + uint16_t Vcc,uint8_t I2Cerr) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[3]; + _mav_put_uint16_t(buf, 0, Vcc); + _mav_put_uint8_t(buf, 2, I2Cerr); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 3); +#else + mavlink_hwstatus_t packet; + packet.Vcc = Vcc; + packet.I2Cerr = I2Cerr; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 3); +#endif + + msg->msgid = MAVLINK_MSG_ID_HWSTATUS; + return mavlink_finalize_message_chan(msg, system_id, component_id, chan, 3, 21); +} + +/** + * @brief Encode a hwstatus struct into a message + * + * @param system_id ID of this system + * @param component_id ID of this component (e.g. 200 for IMU) + * @param msg The MAVLink message to compress the data into + * @param hwstatus C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_hwstatus_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_hwstatus_t* hwstatus) +{ + return mavlink_msg_hwstatus_pack(system_id, component_id, msg, hwstatus->Vcc, hwstatus->I2Cerr); +} + +/** + * @brief Send a hwstatus message + * @param chan MAVLink channel to send the message + * + * @param Vcc board voltage (mV) + * @param I2Cerr I2C error count + */ +#ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS + +static inline void mavlink_msg_hwstatus_send(mavlink_channel_t chan, uint16_t Vcc, uint8_t I2Cerr) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[3]; + _mav_put_uint16_t(buf, 0, Vcc); + _mav_put_uint8_t(buf, 2, I2Cerr); + + _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_HWSTATUS, buf, 3, 21); +#else + mavlink_hwstatus_t packet; + packet.Vcc = Vcc; + packet.I2Cerr = I2Cerr; + + _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_HWSTATUS, (const char *)&packet, 3, 21); +#endif +} + +#endif + +// MESSAGE HWSTATUS UNPACKING + + +/** + * @brief Get field Vcc from hwstatus message + * + * @return board voltage (mV) + */ +static inline uint16_t mavlink_msg_hwstatus_get_Vcc(const mavlink_message_t* msg) +{ + return _MAV_RETURN_uint16_t(msg, 0); +} + +/** + * @brief Get field I2Cerr from hwstatus message + * + * @return I2C error count + */ +static inline uint8_t mavlink_msg_hwstatus_get_I2Cerr(const mavlink_message_t* msg) +{ + return _MAV_RETURN_uint8_t(msg, 2); +} + +/** + * @brief Decode a hwstatus message into a struct + * + * @param msg The message to decode + * @param hwstatus C-struct to decode the message contents into + */ +static inline void mavlink_msg_hwstatus_decode(const mavlink_message_t* msg, mavlink_hwstatus_t* hwstatus) +{ +#if MAVLINK_NEED_BYTE_SWAP + hwstatus->Vcc = mavlink_msg_hwstatus_get_Vcc(msg); + hwstatus->I2Cerr = mavlink_msg_hwstatus_get_I2Cerr(msg); +#else + memcpy(hwstatus, _MAV_PAYLOAD(msg), 3); +#endif +} diff --git a/src/GCS_MAVLink/include_v1.0/ardupilotmega/mavlink_msg_limits_status.h b/src/GCS_MAVLink/include_v1.0/ardupilotmega/mavlink_msg_limits_status.h new file mode 100644 index 000000000..7caac1c5a --- /dev/null +++ b/src/GCS_MAVLink/include_v1.0/ardupilotmega/mavlink_msg_limits_status.h @@ -0,0 +1,320 @@ +// MESSAGE LIMITS_STATUS PACKING + +#define MAVLINK_MSG_ID_LIMITS_STATUS 167 + +typedef struct __mavlink_limits_status_t +{ + uint32_t last_trigger; ///< time of last breach in milliseconds since boot + uint32_t last_action; ///< time of last recovery action in milliseconds since boot + uint32_t last_recovery; ///< time of last successful recovery in milliseconds since boot + uint32_t last_clear; ///< time of last all-clear in milliseconds since boot + uint16_t breach_count; ///< number of fence breaches + uint8_t limits_state; ///< state of AP_Limits, (see enum LimitState, LIMITS_STATE) + uint8_t mods_enabled; ///< AP_Limit_Module bitfield of enabled modules, (see enum moduleid or LIMIT_MODULE) + uint8_t mods_required; ///< AP_Limit_Module bitfield of required modules, (see enum moduleid or LIMIT_MODULE) + uint8_t mods_triggered; ///< AP_Limit_Module bitfield of triggered modules, (see enum moduleid or LIMIT_MODULE) +} mavlink_limits_status_t; + +#define MAVLINK_MSG_ID_LIMITS_STATUS_LEN 22 +#define MAVLINK_MSG_ID_167_LEN 22 + + + +#define MAVLINK_MESSAGE_INFO_LIMITS_STATUS { \ + "LIMITS_STATUS", \ + 9, \ + { { "last_trigger", NULL, MAVLINK_TYPE_UINT32_T, 0, 0, offsetof(mavlink_limits_status_t, last_trigger) }, \ + { "last_action", NULL, MAVLINK_TYPE_UINT32_T, 0, 4, offsetof(mavlink_limits_status_t, last_action) }, \ + { "last_recovery", NULL, MAVLINK_TYPE_UINT32_T, 0, 8, offsetof(mavlink_limits_status_t, last_recovery) }, \ + { "last_clear", NULL, MAVLINK_TYPE_UINT32_T, 0, 12, offsetof(mavlink_limits_status_t, last_clear) }, \ + { "breach_count", NULL, MAVLINK_TYPE_UINT16_T, 0, 16, offsetof(mavlink_limits_status_t, breach_count) }, \ + { "limits_state", NULL, MAVLINK_TYPE_UINT8_T, 0, 18, offsetof(mavlink_limits_status_t, limits_state) }, \ + { "mods_enabled", NULL, MAVLINK_TYPE_UINT8_T, 0, 19, offsetof(mavlink_limits_status_t, mods_enabled) }, \ + { "mods_required", NULL, MAVLINK_TYPE_UINT8_T, 0, 20, offsetof(mavlink_limits_status_t, mods_required) }, \ + { "mods_triggered", NULL, MAVLINK_TYPE_UINT8_T, 0, 21, offsetof(mavlink_limits_status_t, mods_triggered) }, \ + } \ +} + + +/** + * @brief Pack a limits_status message + * @param system_id ID of this system + * @param component_id ID of this component (e.g. 200 for IMU) + * @param msg The MAVLink message to compress the data into + * + * @param limits_state state of AP_Limits, (see enum LimitState, LIMITS_STATE) + * @param last_trigger time of last breach in milliseconds since boot + * @param last_action time of last recovery action in milliseconds since boot + * @param last_recovery time of last successful recovery in milliseconds since boot + * @param last_clear time of last all-clear in milliseconds since boot + * @param breach_count number of fence breaches + * @param mods_enabled AP_Limit_Module bitfield of enabled modules, (see enum moduleid or LIMIT_MODULE) + * @param mods_required AP_Limit_Module bitfield of required modules, (see enum moduleid or LIMIT_MODULE) + * @param mods_triggered AP_Limit_Module bitfield of triggered modules, (see enum moduleid or LIMIT_MODULE) + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_limits_status_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, + uint8_t limits_state, uint32_t last_trigger, uint32_t last_action, uint32_t last_recovery, uint32_t last_clear, uint16_t breach_count, uint8_t mods_enabled, uint8_t mods_required, uint8_t mods_triggered) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[22]; + _mav_put_uint32_t(buf, 0, last_trigger); + _mav_put_uint32_t(buf, 4, last_action); + _mav_put_uint32_t(buf, 8, last_recovery); + _mav_put_uint32_t(buf, 12, last_clear); + _mav_put_uint16_t(buf, 16, breach_count); + _mav_put_uint8_t(buf, 18, limits_state); + _mav_put_uint8_t(buf, 19, mods_enabled); + _mav_put_uint8_t(buf, 20, mods_required); + _mav_put_uint8_t(buf, 21, mods_triggered); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 22); +#else + mavlink_limits_status_t packet; + packet.last_trigger = last_trigger; + packet.last_action = last_action; + packet.last_recovery = last_recovery; + packet.last_clear = last_clear; + packet.breach_count = breach_count; + packet.limits_state = limits_state; + packet.mods_enabled = mods_enabled; + packet.mods_required = mods_required; + packet.mods_triggered = mods_triggered; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 22); +#endif + + msg->msgid = MAVLINK_MSG_ID_LIMITS_STATUS; + return mavlink_finalize_message(msg, system_id, component_id, 22, 144); +} + +/** + * @brief Pack a limits_status message on a channel + * @param system_id ID of this system + * @param component_id ID of this component (e.g. 200 for IMU) + * @param chan The MAVLink channel this message was sent over + * @param msg The MAVLink message to compress the data into + * @param limits_state state of AP_Limits, (see enum LimitState, LIMITS_STATE) + * @param last_trigger time of last breach in milliseconds since boot + * @param last_action time of last recovery action in milliseconds since boot + * @param last_recovery time of last successful recovery in milliseconds since boot + * @param last_clear time of last all-clear in milliseconds since boot + * @param breach_count number of fence breaches + * @param mods_enabled AP_Limit_Module bitfield of enabled modules, (see enum moduleid or LIMIT_MODULE) + * @param mods_required AP_Limit_Module bitfield of required modules, (see enum moduleid or LIMIT_MODULE) + * @param mods_triggered AP_Limit_Module bitfield of triggered modules, (see enum moduleid or LIMIT_MODULE) + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_limits_status_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, + mavlink_message_t* msg, + uint8_t limits_state,uint32_t last_trigger,uint32_t last_action,uint32_t last_recovery,uint32_t last_clear,uint16_t breach_count,uint8_t mods_enabled,uint8_t mods_required,uint8_t mods_triggered) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[22]; + _mav_put_uint32_t(buf, 0, last_trigger); + _mav_put_uint32_t(buf, 4, last_action); + _mav_put_uint32_t(buf, 8, last_recovery); + _mav_put_uint32_t(buf, 12, last_clear); + _mav_put_uint16_t(buf, 16, breach_count); + _mav_put_uint8_t(buf, 18, limits_state); + _mav_put_uint8_t(buf, 19, mods_enabled); + _mav_put_uint8_t(buf, 20, mods_required); + _mav_put_uint8_t(buf, 21, mods_triggered); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 22); +#else + mavlink_limits_status_t packet; + packet.last_trigger = last_trigger; + packet.last_action = last_action; + packet.last_recovery = last_recovery; + packet.last_clear = last_clear; + packet.breach_count = breach_count; + packet.limits_state = limits_state; + packet.mods_enabled = mods_enabled; + packet.mods_required = mods_required; + packet.mods_triggered = mods_triggered; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 22); +#endif + + msg->msgid = MAVLINK_MSG_ID_LIMITS_STATUS; + return mavlink_finalize_message_chan(msg, system_id, component_id, chan, 22, 144); +} + +/** + * @brief Encode a limits_status struct into a message + * + * @param system_id ID of this system + * @param component_id ID of this component (e.g. 200 for IMU) + * @param msg The MAVLink message to compress the data into + * @param limits_status C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_limits_status_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_limits_status_t* limits_status) +{ + return mavlink_msg_limits_status_pack(system_id, component_id, msg, limits_status->limits_state, limits_status->last_trigger, limits_status->last_action, limits_status->last_recovery, limits_status->last_clear, limits_status->breach_count, limits_status->mods_enabled, limits_status->mods_required, limits_status->mods_triggered); +} + +/** + * @brief Send a limits_status message + * @param chan MAVLink channel to send the message + * + * @param limits_state state of AP_Limits, (see enum LimitState, LIMITS_STATE) + * @param last_trigger time of last breach in milliseconds since boot + * @param last_action time of last recovery action in milliseconds since boot + * @param last_recovery time of last successful recovery in milliseconds since boot + * @param last_clear time of last all-clear in milliseconds since boot + * @param breach_count number of fence breaches + * @param mods_enabled AP_Limit_Module bitfield of enabled modules, (see enum moduleid or LIMIT_MODULE) + * @param mods_required AP_Limit_Module bitfield of required modules, (see enum moduleid or LIMIT_MODULE) + * @param mods_triggered AP_Limit_Module bitfield of triggered modules, (see enum moduleid or LIMIT_MODULE) + */ +#ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS + +static inline void mavlink_msg_limits_status_send(mavlink_channel_t chan, uint8_t limits_state, uint32_t last_trigger, uint32_t last_action, uint32_t last_recovery, uint32_t last_clear, uint16_t breach_count, uint8_t mods_enabled, uint8_t mods_required, uint8_t mods_triggered) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[22]; + _mav_put_uint32_t(buf, 0, last_trigger); + _mav_put_uint32_t(buf, 4, last_action); + _mav_put_uint32_t(buf, 8, last_recovery); + _mav_put_uint32_t(buf, 12, last_clear); + _mav_put_uint16_t(buf, 16, breach_count); + _mav_put_uint8_t(buf, 18, limits_state); + _mav_put_uint8_t(buf, 19, mods_enabled); + _mav_put_uint8_t(buf, 20, mods_required); + _mav_put_uint8_t(buf, 21, mods_triggered); + + _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_LIMITS_STATUS, buf, 22, 144); +#else + mavlink_limits_status_t packet; + packet.last_trigger = last_trigger; + packet.last_action = last_action; + packet.last_recovery = last_recovery; + packet.last_clear = last_clear; + packet.breach_count = breach_count; + packet.limits_state = limits_state; + packet.mods_enabled = mods_enabled; + packet.mods_required = mods_required; + packet.mods_triggered = mods_triggered; + + _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_LIMITS_STATUS, (const char *)&packet, 22, 144); +#endif +} + +#endif + +// MESSAGE LIMITS_STATUS UNPACKING + + +/** + * @brief Get field limits_state from limits_status message + * + * @return state of AP_Limits, (see enum LimitState, LIMITS_STATE) + */ +static inline uint8_t mavlink_msg_limits_status_get_limits_state(const mavlink_message_t* msg) +{ + return _MAV_RETURN_uint8_t(msg, 18); +} + +/** + * @brief Get field last_trigger from limits_status message + * + * @return time of last breach in milliseconds since boot + */ +static inline uint32_t mavlink_msg_limits_status_get_last_trigger(const mavlink_message_t* msg) +{ + return _MAV_RETURN_uint32_t(msg, 0); +} + +/** + * @brief Get field last_action from limits_status message + * + * @return time of last recovery action in milliseconds since boot + */ +static inline uint32_t mavlink_msg_limits_status_get_last_action(const mavlink_message_t* msg) +{ + return _MAV_RETURN_uint32_t(msg, 4); +} + +/** + * @brief Get field last_recovery from limits_status message + * + * @return time of last successful recovery in milliseconds since boot + */ +static inline uint32_t mavlink_msg_limits_status_get_last_recovery(const mavlink_message_t* msg) +{ + return _MAV_RETURN_uint32_t(msg, 8); +} + +/** + * @brief Get field last_clear from limits_status message + * + * @return time of last all-clear in milliseconds since boot + */ +static inline uint32_t mavlink_msg_limits_status_get_last_clear(const mavlink_message_t* msg) +{ + return _MAV_RETURN_uint32_t(msg, 12); +} + +/** + * @brief Get field breach_count from limits_status message + * + * @return number of fence breaches + */ +static inline uint16_t mavlink_msg_limits_status_get_breach_count(const mavlink_message_t* msg) +{ + return _MAV_RETURN_uint16_t(msg, 16); +} + +/** + * @brief Get field mods_enabled from limits_status message + * + * @return AP_Limit_Module bitfield of enabled modules, (see enum moduleid or LIMIT_MODULE) + */ +static inline uint8_t mavlink_msg_limits_status_get_mods_enabled(const mavlink_message_t* msg) +{ + return _MAV_RETURN_uint8_t(msg, 19); +} + +/** + * @brief Get field mods_required from limits_status message + * + * @return AP_Limit_Module bitfield of required modules, (see enum moduleid or LIMIT_MODULE) + */ +static inline uint8_t mavlink_msg_limits_status_get_mods_required(const mavlink_message_t* msg) +{ + return _MAV_RETURN_uint8_t(msg, 20); +} + +/** + * @brief Get field mods_triggered from limits_status message + * + * @return AP_Limit_Module bitfield of triggered modules, (see enum moduleid or LIMIT_MODULE) + */ +static inline uint8_t mavlink_msg_limits_status_get_mods_triggered(const mavlink_message_t* msg) +{ + return _MAV_RETURN_uint8_t(msg, 21); +} + +/** + * @brief Decode a limits_status message into a struct + * + * @param msg The message to decode + * @param limits_status C-struct to decode the message contents into + */ +static inline void mavlink_msg_limits_status_decode(const mavlink_message_t* msg, mavlink_limits_status_t* limits_status) +{ +#if MAVLINK_NEED_BYTE_SWAP + limits_status->last_trigger = mavlink_msg_limits_status_get_last_trigger(msg); + limits_status->last_action = mavlink_msg_limits_status_get_last_action(msg); + limits_status->last_recovery = mavlink_msg_limits_status_get_last_recovery(msg); + limits_status->last_clear = mavlink_msg_limits_status_get_last_clear(msg); + limits_status->breach_count = mavlink_msg_limits_status_get_breach_count(msg); + limits_status->limits_state = mavlink_msg_limits_status_get_limits_state(msg); + limits_status->mods_enabled = mavlink_msg_limits_status_get_mods_enabled(msg); + limits_status->mods_required = mavlink_msg_limits_status_get_mods_required(msg); + limits_status->mods_triggered = mavlink_msg_limits_status_get_mods_triggered(msg); +#else + memcpy(limits_status, _MAV_PAYLOAD(msg), 22); +#endif +} diff --git a/src/GCS_MAVLink/include_v1.0/ardupilotmega/mavlink_msg_meminfo.h b/src/GCS_MAVLink/include_v1.0/ardupilotmega/mavlink_msg_meminfo.h index 85b7d96fc..a095a804f 100644 --- a/src/GCS_MAVLink/include_v1.0/ardupilotmega/mavlink_msg_meminfo.h +++ b/src/GCS_MAVLink/include_v1.0/ardupilotmega/mavlink_msg_meminfo.h @@ -40,13 +40,13 @@ static inline uint16_t mavlink_msg_meminfo_pack(uint8_t system_id, uint8_t compo _mav_put_uint16_t(buf, 0, brkval); _mav_put_uint16_t(buf, 2, freemem); - memcpy(_MAV_PAYLOAD(msg), buf, 4); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 4); #else mavlink_meminfo_t packet; packet.brkval = brkval; packet.freemem = freemem; - memcpy(_MAV_PAYLOAD(msg), &packet, 4); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 4); #endif msg->msgid = MAVLINK_MSG_ID_MEMINFO; @@ -72,13 +72,13 @@ static inline uint16_t mavlink_msg_meminfo_pack_chan(uint8_t system_id, uint8_t _mav_put_uint16_t(buf, 0, brkval); _mav_put_uint16_t(buf, 2, freemem); - memcpy(_MAV_PAYLOAD(msg), buf, 4); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 4); #else mavlink_meminfo_t packet; packet.brkval = brkval; packet.freemem = freemem; - memcpy(_MAV_PAYLOAD(msg), &packet, 4); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 4); #endif msg->msgid = MAVLINK_MSG_ID_MEMINFO; diff --git a/src/GCS_MAVLink/include_v1.0/ardupilotmega/mavlink_msg_mount_configure.h b/src/GCS_MAVLink/include_v1.0/ardupilotmega/mavlink_msg_mount_configure.h index 84979b3e4..051a71837 100644 --- a/src/GCS_MAVLink/include_v1.0/ardupilotmega/mavlink_msg_mount_configure.h +++ b/src/GCS_MAVLink/include_v1.0/ardupilotmega/mavlink_msg_mount_configure.h @@ -56,7 +56,7 @@ static inline uint16_t mavlink_msg_mount_configure_pack(uint8_t system_id, uint8 _mav_put_uint8_t(buf, 4, stab_pitch); _mav_put_uint8_t(buf, 5, stab_yaw); - memcpy(_MAV_PAYLOAD(msg), buf, 6); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 6); #else mavlink_mount_configure_t packet; packet.target_system = target_system; @@ -66,7 +66,7 @@ static inline uint16_t mavlink_msg_mount_configure_pack(uint8_t system_id, uint8 packet.stab_pitch = stab_pitch; packet.stab_yaw = stab_yaw; - memcpy(_MAV_PAYLOAD(msg), &packet, 6); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 6); #endif msg->msgid = MAVLINK_MSG_ID_MOUNT_CONFIGURE; @@ -100,7 +100,7 @@ static inline uint16_t mavlink_msg_mount_configure_pack_chan(uint8_t system_id, _mav_put_uint8_t(buf, 4, stab_pitch); _mav_put_uint8_t(buf, 5, stab_yaw); - memcpy(_MAV_PAYLOAD(msg), buf, 6); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 6); #else mavlink_mount_configure_t packet; packet.target_system = target_system; @@ -110,7 +110,7 @@ static inline uint16_t mavlink_msg_mount_configure_pack_chan(uint8_t system_id, packet.stab_pitch = stab_pitch; packet.stab_yaw = stab_yaw; - memcpy(_MAV_PAYLOAD(msg), &packet, 6); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 6); #endif msg->msgid = MAVLINK_MSG_ID_MOUNT_CONFIGURE; diff --git a/src/GCS_MAVLink/include_v1.0/ardupilotmega/mavlink_msg_mount_control.h b/src/GCS_MAVLink/include_v1.0/ardupilotmega/mavlink_msg_mount_control.h index 37f87fd7a..a51992299 100644 --- a/src/GCS_MAVLink/include_v1.0/ardupilotmega/mavlink_msg_mount_control.h +++ b/src/GCS_MAVLink/include_v1.0/ardupilotmega/mavlink_msg_mount_control.h @@ -56,7 +56,7 @@ static inline uint16_t mavlink_msg_mount_control_pack(uint8_t system_id, uint8_t _mav_put_uint8_t(buf, 13, target_component); _mav_put_uint8_t(buf, 14, save_position); - memcpy(_MAV_PAYLOAD(msg), buf, 15); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 15); #else mavlink_mount_control_t packet; packet.input_a = input_a; @@ -66,7 +66,7 @@ static inline uint16_t mavlink_msg_mount_control_pack(uint8_t system_id, uint8_t packet.target_component = target_component; packet.save_position = save_position; - memcpy(_MAV_PAYLOAD(msg), &packet, 15); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 15); #endif msg->msgid = MAVLINK_MSG_ID_MOUNT_CONTROL; @@ -100,7 +100,7 @@ static inline uint16_t mavlink_msg_mount_control_pack_chan(uint8_t system_id, ui _mav_put_uint8_t(buf, 13, target_component); _mav_put_uint8_t(buf, 14, save_position); - memcpy(_MAV_PAYLOAD(msg), buf, 15); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 15); #else mavlink_mount_control_t packet; packet.input_a = input_a; @@ -110,7 +110,7 @@ static inline uint16_t mavlink_msg_mount_control_pack_chan(uint8_t system_id, ui packet.target_component = target_component; packet.save_position = save_position; - memcpy(_MAV_PAYLOAD(msg), &packet, 15); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 15); #endif msg->msgid = MAVLINK_MSG_ID_MOUNT_CONTROL; diff --git a/src/GCS_MAVLink/include_v1.0/ardupilotmega/mavlink_msg_mount_status.h b/src/GCS_MAVLink/include_v1.0/ardupilotmega/mavlink_msg_mount_status.h index f43709ba7..edc188ebd 100644 --- a/src/GCS_MAVLink/include_v1.0/ardupilotmega/mavlink_msg_mount_status.h +++ b/src/GCS_MAVLink/include_v1.0/ardupilotmega/mavlink_msg_mount_status.h @@ -52,7 +52,7 @@ static inline uint16_t mavlink_msg_mount_status_pack(uint8_t system_id, uint8_t _mav_put_uint8_t(buf, 12, target_system); _mav_put_uint8_t(buf, 13, target_component); - memcpy(_MAV_PAYLOAD(msg), buf, 14); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 14); #else mavlink_mount_status_t packet; packet.pointing_a = pointing_a; @@ -61,7 +61,7 @@ static inline uint16_t mavlink_msg_mount_status_pack(uint8_t system_id, uint8_t packet.target_system = target_system; packet.target_component = target_component; - memcpy(_MAV_PAYLOAD(msg), &packet, 14); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 14); #endif msg->msgid = MAVLINK_MSG_ID_MOUNT_STATUS; @@ -93,7 +93,7 @@ static inline uint16_t mavlink_msg_mount_status_pack_chan(uint8_t system_id, uin _mav_put_uint8_t(buf, 12, target_system); _mav_put_uint8_t(buf, 13, target_component); - memcpy(_MAV_PAYLOAD(msg), buf, 14); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 14); #else mavlink_mount_status_t packet; packet.pointing_a = pointing_a; @@ -102,7 +102,7 @@ static inline uint16_t mavlink_msg_mount_status_pack_chan(uint8_t system_id, uin packet.target_system = target_system; packet.target_component = target_component; - memcpy(_MAV_PAYLOAD(msg), &packet, 14); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 14); #endif msg->msgid = MAVLINK_MSG_ID_MOUNT_STATUS; diff --git a/src/GCS_MAVLink/include_v1.0/ardupilotmega/mavlink_msg_radio.h b/src/GCS_MAVLink/include_v1.0/ardupilotmega/mavlink_msg_radio.h new file mode 100644 index 000000000..0f3d03c0a --- /dev/null +++ b/src/GCS_MAVLink/include_v1.0/ardupilotmega/mavlink_msg_radio.h @@ -0,0 +1,276 @@ +// MESSAGE RADIO PACKING + +#define MAVLINK_MSG_ID_RADIO 166 + +typedef struct __mavlink_radio_t +{ + uint16_t rxerrors; ///< receive errors + uint16_t fixed; ///< count of error corrected packets + uint8_t rssi; ///< local signal strength + uint8_t remrssi; ///< remote signal strength + uint8_t txbuf; ///< how full the tx buffer is as a percentage + uint8_t noise; ///< background noise level + uint8_t remnoise; ///< remote background noise level +} mavlink_radio_t; + +#define MAVLINK_MSG_ID_RADIO_LEN 9 +#define MAVLINK_MSG_ID_166_LEN 9 + + + +#define MAVLINK_MESSAGE_INFO_RADIO { \ + "RADIO", \ + 7, \ + { { "rxerrors", NULL, MAVLINK_TYPE_UINT16_T, 0, 0, offsetof(mavlink_radio_t, rxerrors) }, \ + { "fixed", NULL, MAVLINK_TYPE_UINT16_T, 0, 2, offsetof(mavlink_radio_t, fixed) }, \ + { "rssi", NULL, MAVLINK_TYPE_UINT8_T, 0, 4, offsetof(mavlink_radio_t, rssi) }, \ + { "remrssi", NULL, MAVLINK_TYPE_UINT8_T, 0, 5, offsetof(mavlink_radio_t, remrssi) }, \ + { "txbuf", NULL, MAVLINK_TYPE_UINT8_T, 0, 6, offsetof(mavlink_radio_t, txbuf) }, \ + { "noise", NULL, MAVLINK_TYPE_UINT8_T, 0, 7, offsetof(mavlink_radio_t, noise) }, \ + { "remnoise", NULL, MAVLINK_TYPE_UINT8_T, 0, 8, offsetof(mavlink_radio_t, remnoise) }, \ + } \ +} + + +/** + * @brief Pack a radio message + * @param system_id ID of this system + * @param component_id ID of this component (e.g. 200 for IMU) + * @param msg The MAVLink message to compress the data into + * + * @param rssi local signal strength + * @param remrssi remote signal strength + * @param txbuf how full the tx buffer is as a percentage + * @param noise background noise level + * @param remnoise remote background noise level + * @param rxerrors receive errors + * @param fixed count of error corrected packets + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_radio_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, + uint8_t rssi, uint8_t remrssi, uint8_t txbuf, uint8_t noise, uint8_t remnoise, uint16_t rxerrors, uint16_t fixed) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[9]; + _mav_put_uint16_t(buf, 0, rxerrors); + _mav_put_uint16_t(buf, 2, fixed); + _mav_put_uint8_t(buf, 4, rssi); + _mav_put_uint8_t(buf, 5, remrssi); + _mav_put_uint8_t(buf, 6, txbuf); + _mav_put_uint8_t(buf, 7, noise); + _mav_put_uint8_t(buf, 8, remnoise); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 9); +#else + mavlink_radio_t packet; + packet.rxerrors = rxerrors; + packet.fixed = fixed; + packet.rssi = rssi; + packet.remrssi = remrssi; + packet.txbuf = txbuf; + packet.noise = noise; + packet.remnoise = remnoise; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 9); +#endif + + msg->msgid = MAVLINK_MSG_ID_RADIO; + return mavlink_finalize_message(msg, system_id, component_id, 9, 21); +} + +/** + * @brief Pack a radio message on a channel + * @param system_id ID of this system + * @param component_id ID of this component (e.g. 200 for IMU) + * @param chan The MAVLink channel this message was sent over + * @param msg The MAVLink message to compress the data into + * @param rssi local signal strength + * @param remrssi remote signal strength + * @param txbuf how full the tx buffer is as a percentage + * @param noise background noise level + * @param remnoise remote background noise level + * @param rxerrors receive errors + * @param fixed count of error corrected packets + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_radio_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, + mavlink_message_t* msg, + uint8_t rssi,uint8_t remrssi,uint8_t txbuf,uint8_t noise,uint8_t remnoise,uint16_t rxerrors,uint16_t fixed) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[9]; + _mav_put_uint16_t(buf, 0, rxerrors); + _mav_put_uint16_t(buf, 2, fixed); + _mav_put_uint8_t(buf, 4, rssi); + _mav_put_uint8_t(buf, 5, remrssi); + _mav_put_uint8_t(buf, 6, txbuf); + _mav_put_uint8_t(buf, 7, noise); + _mav_put_uint8_t(buf, 8, remnoise); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 9); +#else + mavlink_radio_t packet; + packet.rxerrors = rxerrors; + packet.fixed = fixed; + packet.rssi = rssi; + packet.remrssi = remrssi; + packet.txbuf = txbuf; + packet.noise = noise; + packet.remnoise = remnoise; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 9); +#endif + + msg->msgid = MAVLINK_MSG_ID_RADIO; + return mavlink_finalize_message_chan(msg, system_id, component_id, chan, 9, 21); +} + +/** + * @brief Encode a radio struct into a message + * + * @param system_id ID of this system + * @param component_id ID of this component (e.g. 200 for IMU) + * @param msg The MAVLink message to compress the data into + * @param radio C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_radio_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_radio_t* radio) +{ + return mavlink_msg_radio_pack(system_id, component_id, msg, radio->rssi, radio->remrssi, radio->txbuf, radio->noise, radio->remnoise, radio->rxerrors, radio->fixed); +} + +/** + * @brief Send a radio message + * @param chan MAVLink channel to send the message + * + * @param rssi local signal strength + * @param remrssi remote signal strength + * @param txbuf how full the tx buffer is as a percentage + * @param noise background noise level + * @param remnoise remote background noise level + * @param rxerrors receive errors + * @param fixed count of error corrected packets + */ +#ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS + +static inline void mavlink_msg_radio_send(mavlink_channel_t chan, uint8_t rssi, uint8_t remrssi, uint8_t txbuf, uint8_t noise, uint8_t remnoise, uint16_t rxerrors, uint16_t fixed) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[9]; + _mav_put_uint16_t(buf, 0, rxerrors); + _mav_put_uint16_t(buf, 2, fixed); + _mav_put_uint8_t(buf, 4, rssi); + _mav_put_uint8_t(buf, 5, remrssi); + _mav_put_uint8_t(buf, 6, txbuf); + _mav_put_uint8_t(buf, 7, noise); + _mav_put_uint8_t(buf, 8, remnoise); + + _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_RADIO, buf, 9, 21); +#else + mavlink_radio_t packet; + packet.rxerrors = rxerrors; + packet.fixed = fixed; + packet.rssi = rssi; + packet.remrssi = remrssi; + packet.txbuf = txbuf; + packet.noise = noise; + packet.remnoise = remnoise; + + _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_RADIO, (const char *)&packet, 9, 21); +#endif +} + +#endif + +// MESSAGE RADIO UNPACKING + + +/** + * @brief Get field rssi from radio message + * + * @return local signal strength + */ +static inline uint8_t mavlink_msg_radio_get_rssi(const mavlink_message_t* msg) +{ + return _MAV_RETURN_uint8_t(msg, 4); +} + +/** + * @brief Get field remrssi from radio message + * + * @return remote signal strength + */ +static inline uint8_t mavlink_msg_radio_get_remrssi(const mavlink_message_t* msg) +{ + return _MAV_RETURN_uint8_t(msg, 5); +} + +/** + * @brief Get field txbuf from radio message + * + * @return how full the tx buffer is as a percentage + */ +static inline uint8_t mavlink_msg_radio_get_txbuf(const mavlink_message_t* msg) +{ + return _MAV_RETURN_uint8_t(msg, 6); +} + +/** + * @brief Get field noise from radio message + * + * @return background noise level + */ +static inline uint8_t mavlink_msg_radio_get_noise(const mavlink_message_t* msg) +{ + return _MAV_RETURN_uint8_t(msg, 7); +} + +/** + * @brief Get field remnoise from radio message + * + * @return remote background noise level + */ +static inline uint8_t mavlink_msg_radio_get_remnoise(const mavlink_message_t* msg) +{ + return _MAV_RETURN_uint8_t(msg, 8); +} + +/** + * @brief Get field rxerrors from radio message + * + * @return receive errors + */ +static inline uint16_t mavlink_msg_radio_get_rxerrors(const mavlink_message_t* msg) +{ + return _MAV_RETURN_uint16_t(msg, 0); +} + +/** + * @brief Get field fixed from radio message + * + * @return count of error corrected packets + */ +static inline uint16_t mavlink_msg_radio_get_fixed(const mavlink_message_t* msg) +{ + return _MAV_RETURN_uint16_t(msg, 2); +} + +/** + * @brief Decode a radio message into a struct + * + * @param msg The message to decode + * @param radio C-struct to decode the message contents into + */ +static inline void mavlink_msg_radio_decode(const mavlink_message_t* msg, mavlink_radio_t* radio) +{ +#if MAVLINK_NEED_BYTE_SWAP + radio->rxerrors = mavlink_msg_radio_get_rxerrors(msg); + radio->fixed = mavlink_msg_radio_get_fixed(msg); + radio->rssi = mavlink_msg_radio_get_rssi(msg); + radio->remrssi = mavlink_msg_radio_get_remrssi(msg); + radio->txbuf = mavlink_msg_radio_get_txbuf(msg); + radio->noise = mavlink_msg_radio_get_noise(msg); + radio->remnoise = mavlink_msg_radio_get_remnoise(msg); +#else + memcpy(radio, _MAV_PAYLOAD(msg), 9); +#endif +} diff --git a/src/GCS_MAVLink/include_v1.0/ardupilotmega/mavlink_msg_rangefinder.h b/src/GCS_MAVLink/include_v1.0/ardupilotmega/mavlink_msg_rangefinder.h new file mode 100644 index 000000000..2eeeddd59 --- /dev/null +++ b/src/GCS_MAVLink/include_v1.0/ardupilotmega/mavlink_msg_rangefinder.h @@ -0,0 +1,166 @@ +// MESSAGE RANGEFINDER PACKING + +#define MAVLINK_MSG_ID_RANGEFINDER 173 + +typedef struct __mavlink_rangefinder_t +{ + float distance; ///< distance in meters + float voltage; ///< raw voltage if available, zero otherwise +} mavlink_rangefinder_t; + +#define MAVLINK_MSG_ID_RANGEFINDER_LEN 8 +#define MAVLINK_MSG_ID_173_LEN 8 + + + +#define MAVLINK_MESSAGE_INFO_RANGEFINDER { \ + "RANGEFINDER", \ + 2, \ + { { "distance", NULL, MAVLINK_TYPE_FLOAT, 0, 0, offsetof(mavlink_rangefinder_t, distance) }, \ + { "voltage", NULL, MAVLINK_TYPE_FLOAT, 0, 4, offsetof(mavlink_rangefinder_t, voltage) }, \ + } \ +} + + +/** + * @brief Pack a rangefinder message + * @param system_id ID of this system + * @param component_id ID of this component (e.g. 200 for IMU) + * @param msg The MAVLink message to compress the data into + * + * @param distance distance in meters + * @param voltage raw voltage if available, zero otherwise + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_rangefinder_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, + float distance, float voltage) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[8]; + _mav_put_float(buf, 0, distance); + _mav_put_float(buf, 4, voltage); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 8); +#else + mavlink_rangefinder_t packet; + packet.distance = distance; + packet.voltage = voltage; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 8); +#endif + + msg->msgid = MAVLINK_MSG_ID_RANGEFINDER; + return mavlink_finalize_message(msg, system_id, component_id, 8, 83); +} + +/** + * @brief Pack a rangefinder message on a channel + * @param system_id ID of this system + * @param component_id ID of this component (e.g. 200 for IMU) + * @param chan The MAVLink channel this message was sent over + * @param msg The MAVLink message to compress the data into + * @param distance distance in meters + * @param voltage raw voltage if available, zero otherwise + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_rangefinder_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, + mavlink_message_t* msg, + float distance,float voltage) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[8]; + _mav_put_float(buf, 0, distance); + _mav_put_float(buf, 4, voltage); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 8); +#else + mavlink_rangefinder_t packet; + packet.distance = distance; + packet.voltage = voltage; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 8); +#endif + + msg->msgid = MAVLINK_MSG_ID_RANGEFINDER; + return mavlink_finalize_message_chan(msg, system_id, component_id, chan, 8, 83); +} + +/** + * @brief Encode a rangefinder struct into a message + * + * @param system_id ID of this system + * @param component_id ID of this component (e.g. 200 for IMU) + * @param msg The MAVLink message to compress the data into + * @param rangefinder C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_rangefinder_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_rangefinder_t* rangefinder) +{ + return mavlink_msg_rangefinder_pack(system_id, component_id, msg, rangefinder->distance, rangefinder->voltage); +} + +/** + * @brief Send a rangefinder message + * @param chan MAVLink channel to send the message + * + * @param distance distance in meters + * @param voltage raw voltage if available, zero otherwise + */ +#ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS + +static inline void mavlink_msg_rangefinder_send(mavlink_channel_t chan, float distance, float voltage) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[8]; + _mav_put_float(buf, 0, distance); + _mav_put_float(buf, 4, voltage); + + _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_RANGEFINDER, buf, 8, 83); +#else + mavlink_rangefinder_t packet; + packet.distance = distance; + packet.voltage = voltage; + + _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_RANGEFINDER, (const char *)&packet, 8, 83); +#endif +} + +#endif + +// MESSAGE RANGEFINDER UNPACKING + + +/** + * @brief Get field distance from rangefinder message + * + * @return distance in meters + */ +static inline float mavlink_msg_rangefinder_get_distance(const mavlink_message_t* msg) +{ + return _MAV_RETURN_float(msg, 0); +} + +/** + * @brief Get field voltage from rangefinder message + * + * @return raw voltage if available, zero otherwise + */ +static inline float mavlink_msg_rangefinder_get_voltage(const mavlink_message_t* msg) +{ + return _MAV_RETURN_float(msg, 4); +} + +/** + * @brief Decode a rangefinder message into a struct + * + * @param msg The message to decode + * @param rangefinder C-struct to decode the message contents into + */ +static inline void mavlink_msg_rangefinder_decode(const mavlink_message_t* msg, mavlink_rangefinder_t* rangefinder) +{ +#if MAVLINK_NEED_BYTE_SWAP + rangefinder->distance = mavlink_msg_rangefinder_get_distance(msg); + rangefinder->voltage = mavlink_msg_rangefinder_get_voltage(msg); +#else + memcpy(rangefinder, _MAV_PAYLOAD(msg), 8); +#endif +} diff --git a/src/GCS_MAVLink/include_v1.0/ardupilotmega/mavlink_msg_sensor_offsets.h b/src/GCS_MAVLink/include_v1.0/ardupilotmega/mavlink_msg_sensor_offsets.h index b3b38e6df..56fb52d96 100644 --- a/src/GCS_MAVLink/include_v1.0/ardupilotmega/mavlink_msg_sensor_offsets.h +++ b/src/GCS_MAVLink/include_v1.0/ardupilotmega/mavlink_msg_sensor_offsets.h @@ -80,7 +80,7 @@ static inline uint16_t mavlink_msg_sensor_offsets_pack(uint8_t system_id, uint8_ _mav_put_int16_t(buf, 38, mag_ofs_y); _mav_put_int16_t(buf, 40, mag_ofs_z); - memcpy(_MAV_PAYLOAD(msg), buf, 42); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 42); #else mavlink_sensor_offsets_t packet; packet.mag_declination = mag_declination; @@ -96,7 +96,7 @@ static inline uint16_t mavlink_msg_sensor_offsets_pack(uint8_t system_id, uint8_ packet.mag_ofs_y = mag_ofs_y; packet.mag_ofs_z = mag_ofs_z; - memcpy(_MAV_PAYLOAD(msg), &packet, 42); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 42); #endif msg->msgid = MAVLINK_MSG_ID_SENSOR_OFFSETS; @@ -142,7 +142,7 @@ static inline uint16_t mavlink_msg_sensor_offsets_pack_chan(uint8_t system_id, u _mav_put_int16_t(buf, 38, mag_ofs_y); _mav_put_int16_t(buf, 40, mag_ofs_z); - memcpy(_MAV_PAYLOAD(msg), buf, 42); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 42); #else mavlink_sensor_offsets_t packet; packet.mag_declination = mag_declination; @@ -158,7 +158,7 @@ static inline uint16_t mavlink_msg_sensor_offsets_pack_chan(uint8_t system_id, u packet.mag_ofs_y = mag_ofs_y; packet.mag_ofs_z = mag_ofs_z; - memcpy(_MAV_PAYLOAD(msg), &packet, 42); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 42); #endif msg->msgid = MAVLINK_MSG_ID_SENSOR_OFFSETS; diff --git a/src/GCS_MAVLink/include_v1.0/ardupilotmega/mavlink_msg_set_mag_offsets.h b/src/GCS_MAVLink/include_v1.0/ardupilotmega/mavlink_msg_set_mag_offsets.h index 015116190..4c13fd186 100644 --- a/src/GCS_MAVLink/include_v1.0/ardupilotmega/mavlink_msg_set_mag_offsets.h +++ b/src/GCS_MAVLink/include_v1.0/ardupilotmega/mavlink_msg_set_mag_offsets.h @@ -52,7 +52,7 @@ static inline uint16_t mavlink_msg_set_mag_offsets_pack(uint8_t system_id, uint8 _mav_put_uint8_t(buf, 6, target_system); _mav_put_uint8_t(buf, 7, target_component); - memcpy(_MAV_PAYLOAD(msg), buf, 8); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 8); #else mavlink_set_mag_offsets_t packet; packet.mag_ofs_x = mag_ofs_x; @@ -61,7 +61,7 @@ static inline uint16_t mavlink_msg_set_mag_offsets_pack(uint8_t system_id, uint8 packet.target_system = target_system; packet.target_component = target_component; - memcpy(_MAV_PAYLOAD(msg), &packet, 8); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 8); #endif msg->msgid = MAVLINK_MSG_ID_SET_MAG_OFFSETS; @@ -93,7 +93,7 @@ static inline uint16_t mavlink_msg_set_mag_offsets_pack_chan(uint8_t system_id, _mav_put_uint8_t(buf, 6, target_system); _mav_put_uint8_t(buf, 7, target_component); - memcpy(_MAV_PAYLOAD(msg), buf, 8); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 8); #else mavlink_set_mag_offsets_t packet; packet.mag_ofs_x = mag_ofs_x; @@ -102,7 +102,7 @@ static inline uint16_t mavlink_msg_set_mag_offsets_pack_chan(uint8_t system_id, packet.target_system = target_system; packet.target_component = target_component; - memcpy(_MAV_PAYLOAD(msg), &packet, 8); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 8); #endif msg->msgid = MAVLINK_MSG_ID_SET_MAG_OFFSETS; diff --git a/src/GCS_MAVLink/include_v1.0/ardupilotmega/mavlink_msg_simstate.h b/src/GCS_MAVLink/include_v1.0/ardupilotmega/mavlink_msg_simstate.h new file mode 100644 index 000000000..8ee447c77 --- /dev/null +++ b/src/GCS_MAVLink/include_v1.0/ardupilotmega/mavlink_msg_simstate.h @@ -0,0 +1,364 @@ +// MESSAGE SIMSTATE PACKING + +#define MAVLINK_MSG_ID_SIMSTATE 164 + +typedef struct __mavlink_simstate_t +{ + float roll; ///< Roll angle (rad) + float pitch; ///< Pitch angle (rad) + float yaw; ///< Yaw angle (rad) + float xacc; ///< X acceleration m/s/s + float yacc; ///< Y acceleration m/s/s + float zacc; ///< Z acceleration m/s/s + float xgyro; ///< Angular speed around X axis rad/s + float ygyro; ///< Angular speed around Y axis rad/s + float zgyro; ///< Angular speed around Z axis rad/s + float lat; ///< Latitude in degrees + float lng; ///< Longitude in degrees +} mavlink_simstate_t; + +#define MAVLINK_MSG_ID_SIMSTATE_LEN 44 +#define MAVLINK_MSG_ID_164_LEN 44 + + + +#define MAVLINK_MESSAGE_INFO_SIMSTATE { \ + "SIMSTATE", \ + 11, \ + { { "roll", NULL, MAVLINK_TYPE_FLOAT, 0, 0, offsetof(mavlink_simstate_t, roll) }, \ + { "pitch", NULL, MAVLINK_TYPE_FLOAT, 0, 4, offsetof(mavlink_simstate_t, pitch) }, \ + { "yaw", NULL, MAVLINK_TYPE_FLOAT, 0, 8, offsetof(mavlink_simstate_t, yaw) }, \ + { "xacc", NULL, MAVLINK_TYPE_FLOAT, 0, 12, offsetof(mavlink_simstate_t, xacc) }, \ + { "yacc", NULL, MAVLINK_TYPE_FLOAT, 0, 16, offsetof(mavlink_simstate_t, yacc) }, \ + { "zacc", NULL, MAVLINK_TYPE_FLOAT, 0, 20, offsetof(mavlink_simstate_t, zacc) }, \ + { "xgyro", NULL, MAVLINK_TYPE_FLOAT, 0, 24, offsetof(mavlink_simstate_t, xgyro) }, \ + { "ygyro", NULL, MAVLINK_TYPE_FLOAT, 0, 28, offsetof(mavlink_simstate_t, ygyro) }, \ + { "zgyro", NULL, MAVLINK_TYPE_FLOAT, 0, 32, offsetof(mavlink_simstate_t, zgyro) }, \ + { "lat", NULL, MAVLINK_TYPE_FLOAT, 0, 36, offsetof(mavlink_simstate_t, lat) }, \ + { "lng", NULL, MAVLINK_TYPE_FLOAT, 0, 40, offsetof(mavlink_simstate_t, lng) }, \ + } \ +} + + +/** + * @brief Pack a simstate message + * @param system_id ID of this system + * @param component_id ID of this component (e.g. 200 for IMU) + * @param msg The MAVLink message to compress the data into + * + * @param roll Roll angle (rad) + * @param pitch Pitch angle (rad) + * @param yaw Yaw angle (rad) + * @param xacc X acceleration m/s/s + * @param yacc Y acceleration m/s/s + * @param zacc Z acceleration m/s/s + * @param xgyro Angular speed around X axis rad/s + * @param ygyro Angular speed around Y axis rad/s + * @param zgyro Angular speed around Z axis rad/s + * @param lat Latitude in degrees + * @param lng Longitude in degrees + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_simstate_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, + float roll, float pitch, float yaw, float xacc, float yacc, float zacc, float xgyro, float ygyro, float zgyro, float lat, float lng) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[44]; + _mav_put_float(buf, 0, roll); + _mav_put_float(buf, 4, pitch); + _mav_put_float(buf, 8, yaw); + _mav_put_float(buf, 12, xacc); + _mav_put_float(buf, 16, yacc); + _mav_put_float(buf, 20, zacc); + _mav_put_float(buf, 24, xgyro); + _mav_put_float(buf, 28, ygyro); + _mav_put_float(buf, 32, zgyro); + _mav_put_float(buf, 36, lat); + _mav_put_float(buf, 40, lng); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 44); +#else + mavlink_simstate_t packet; + packet.roll = roll; + packet.pitch = pitch; + packet.yaw = yaw; + packet.xacc = xacc; + packet.yacc = yacc; + packet.zacc = zacc; + packet.xgyro = xgyro; + packet.ygyro = ygyro; + packet.zgyro = zgyro; + packet.lat = lat; + packet.lng = lng; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 44); +#endif + + msg->msgid = MAVLINK_MSG_ID_SIMSTATE; + return mavlink_finalize_message(msg, system_id, component_id, 44, 111); +} + +/** + * @brief Pack a simstate message on a channel + * @param system_id ID of this system + * @param component_id ID of this component (e.g. 200 for IMU) + * @param chan The MAVLink channel this message was sent over + * @param msg The MAVLink message to compress the data into + * @param roll Roll angle (rad) + * @param pitch Pitch angle (rad) + * @param yaw Yaw angle (rad) + * @param xacc X acceleration m/s/s + * @param yacc Y acceleration m/s/s + * @param zacc Z acceleration m/s/s + * @param xgyro Angular speed around X axis rad/s + * @param ygyro Angular speed around Y axis rad/s + * @param zgyro Angular speed around Z axis rad/s + * @param lat Latitude in degrees + * @param lng Longitude in degrees + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_simstate_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, + mavlink_message_t* msg, + float roll,float pitch,float yaw,float xacc,float yacc,float zacc,float xgyro,float ygyro,float zgyro,float lat,float lng) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[44]; + _mav_put_float(buf, 0, roll); + _mav_put_float(buf, 4, pitch); + _mav_put_float(buf, 8, yaw); + _mav_put_float(buf, 12, xacc); + _mav_put_float(buf, 16, yacc); + _mav_put_float(buf, 20, zacc); + _mav_put_float(buf, 24, xgyro); + _mav_put_float(buf, 28, ygyro); + _mav_put_float(buf, 32, zgyro); + _mav_put_float(buf, 36, lat); + _mav_put_float(buf, 40, lng); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 44); +#else + mavlink_simstate_t packet; + packet.roll = roll; + packet.pitch = pitch; + packet.yaw = yaw; + packet.xacc = xacc; + packet.yacc = yacc; + packet.zacc = zacc; + packet.xgyro = xgyro; + packet.ygyro = ygyro; + packet.zgyro = zgyro; + packet.lat = lat; + packet.lng = lng; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 44); +#endif + + msg->msgid = MAVLINK_MSG_ID_SIMSTATE; + return mavlink_finalize_message_chan(msg, system_id, component_id, chan, 44, 111); +} + +/** + * @brief Encode a simstate struct into a message + * + * @param system_id ID of this system + * @param component_id ID of this component (e.g. 200 for IMU) + * @param msg The MAVLink message to compress the data into + * @param simstate C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_simstate_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_simstate_t* simstate) +{ + return mavlink_msg_simstate_pack(system_id, component_id, msg, simstate->roll, simstate->pitch, simstate->yaw, simstate->xacc, simstate->yacc, simstate->zacc, simstate->xgyro, simstate->ygyro, simstate->zgyro, simstate->lat, simstate->lng); +} + +/** + * @brief Send a simstate message + * @param chan MAVLink channel to send the message + * + * @param roll Roll angle (rad) + * @param pitch Pitch angle (rad) + * @param yaw Yaw angle (rad) + * @param xacc X acceleration m/s/s + * @param yacc Y acceleration m/s/s + * @param zacc Z acceleration m/s/s + * @param xgyro Angular speed around X axis rad/s + * @param ygyro Angular speed around Y axis rad/s + * @param zgyro Angular speed around Z axis rad/s + * @param lat Latitude in degrees + * @param lng Longitude in degrees + */ +#ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS + +static inline void mavlink_msg_simstate_send(mavlink_channel_t chan, float roll, float pitch, float yaw, float xacc, float yacc, float zacc, float xgyro, float ygyro, float zgyro, float lat, float lng) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[44]; + _mav_put_float(buf, 0, roll); + _mav_put_float(buf, 4, pitch); + _mav_put_float(buf, 8, yaw); + _mav_put_float(buf, 12, xacc); + _mav_put_float(buf, 16, yacc); + _mav_put_float(buf, 20, zacc); + _mav_put_float(buf, 24, xgyro); + _mav_put_float(buf, 28, ygyro); + _mav_put_float(buf, 32, zgyro); + _mav_put_float(buf, 36, lat); + _mav_put_float(buf, 40, lng); + + _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_SIMSTATE, buf, 44, 111); +#else + mavlink_simstate_t packet; + packet.roll = roll; + packet.pitch = pitch; + packet.yaw = yaw; + packet.xacc = xacc; + packet.yacc = yacc; + packet.zacc = zacc; + packet.xgyro = xgyro; + packet.ygyro = ygyro; + packet.zgyro = zgyro; + packet.lat = lat; + packet.lng = lng; + + _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_SIMSTATE, (const char *)&packet, 44, 111); +#endif +} + +#endif + +// MESSAGE SIMSTATE UNPACKING + + +/** + * @brief Get field roll from simstate message + * + * @return Roll angle (rad) + */ +static inline float mavlink_msg_simstate_get_roll(const mavlink_message_t* msg) +{ + return _MAV_RETURN_float(msg, 0); +} + +/** + * @brief Get field pitch from simstate message + * + * @return Pitch angle (rad) + */ +static inline float mavlink_msg_simstate_get_pitch(const mavlink_message_t* msg) +{ + return _MAV_RETURN_float(msg, 4); +} + +/** + * @brief Get field yaw from simstate message + * + * @return Yaw angle (rad) + */ +static inline float mavlink_msg_simstate_get_yaw(const mavlink_message_t* msg) +{ + return _MAV_RETURN_float(msg, 8); +} + +/** + * @brief Get field xacc from simstate message + * + * @return X acceleration m/s/s + */ +static inline float mavlink_msg_simstate_get_xacc(const mavlink_message_t* msg) +{ + return _MAV_RETURN_float(msg, 12); +} + +/** + * @brief Get field yacc from simstate message + * + * @return Y acceleration m/s/s + */ +static inline float mavlink_msg_simstate_get_yacc(const mavlink_message_t* msg) +{ + return _MAV_RETURN_float(msg, 16); +} + +/** + * @brief Get field zacc from simstate message + * + * @return Z acceleration m/s/s + */ +static inline float mavlink_msg_simstate_get_zacc(const mavlink_message_t* msg) +{ + return _MAV_RETURN_float(msg, 20); +} + +/** + * @brief Get field xgyro from simstate message + * + * @return Angular speed around X axis rad/s + */ +static inline float mavlink_msg_simstate_get_xgyro(const mavlink_message_t* msg) +{ + return _MAV_RETURN_float(msg, 24); +} + +/** + * @brief Get field ygyro from simstate message + * + * @return Angular speed around Y axis rad/s + */ +static inline float mavlink_msg_simstate_get_ygyro(const mavlink_message_t* msg) +{ + return _MAV_RETURN_float(msg, 28); +} + +/** + * @brief Get field zgyro from simstate message + * + * @return Angular speed around Z axis rad/s + */ +static inline float mavlink_msg_simstate_get_zgyro(const mavlink_message_t* msg) +{ + return _MAV_RETURN_float(msg, 32); +} + +/** + * @brief Get field lat from simstate message + * + * @return Latitude in degrees + */ +static inline float mavlink_msg_simstate_get_lat(const mavlink_message_t* msg) +{ + return _MAV_RETURN_float(msg, 36); +} + +/** + * @brief Get field lng from simstate message + * + * @return Longitude in degrees + */ +static inline float mavlink_msg_simstate_get_lng(const mavlink_message_t* msg) +{ + return _MAV_RETURN_float(msg, 40); +} + +/** + * @brief Decode a simstate message into a struct + * + * @param msg The message to decode + * @param simstate C-struct to decode the message contents into + */ +static inline void mavlink_msg_simstate_decode(const mavlink_message_t* msg, mavlink_simstate_t* simstate) +{ +#if MAVLINK_NEED_BYTE_SWAP + simstate->roll = mavlink_msg_simstate_get_roll(msg); + simstate->pitch = mavlink_msg_simstate_get_pitch(msg); + simstate->yaw = mavlink_msg_simstate_get_yaw(msg); + simstate->xacc = mavlink_msg_simstate_get_xacc(msg); + simstate->yacc = mavlink_msg_simstate_get_yacc(msg); + simstate->zacc = mavlink_msg_simstate_get_zacc(msg); + simstate->xgyro = mavlink_msg_simstate_get_xgyro(msg); + simstate->ygyro = mavlink_msg_simstate_get_ygyro(msg); + simstate->zgyro = mavlink_msg_simstate_get_zgyro(msg); + simstate->lat = mavlink_msg_simstate_get_lat(msg); + simstate->lng = mavlink_msg_simstate_get_lng(msg); +#else + memcpy(simstate, _MAV_PAYLOAD(msg), 44); +#endif +} diff --git a/src/GCS_MAVLink/include_v1.0/ardupilotmega/mavlink_msg_wind.h b/src/GCS_MAVLink/include_v1.0/ardupilotmega/mavlink_msg_wind.h new file mode 100644 index 000000000..e7fa7d1ea --- /dev/null +++ b/src/GCS_MAVLink/include_v1.0/ardupilotmega/mavlink_msg_wind.h @@ -0,0 +1,188 @@ +// MESSAGE WIND PACKING + +#define MAVLINK_MSG_ID_WIND 168 + +typedef struct __mavlink_wind_t +{ + float direction; ///< wind direction that wind is coming from (degrees) + float speed; ///< wind speed in ground plane (m/s) + float speed_z; ///< vertical wind speed (m/s) +} mavlink_wind_t; + +#define MAVLINK_MSG_ID_WIND_LEN 12 +#define MAVLINK_MSG_ID_168_LEN 12 + + + +#define MAVLINK_MESSAGE_INFO_WIND { \ + "WIND", \ + 3, \ + { { "direction", NULL, MAVLINK_TYPE_FLOAT, 0, 0, offsetof(mavlink_wind_t, direction) }, \ + { "speed", NULL, MAVLINK_TYPE_FLOAT, 0, 4, offsetof(mavlink_wind_t, speed) }, \ + { "speed_z", NULL, MAVLINK_TYPE_FLOAT, 0, 8, offsetof(mavlink_wind_t, speed_z) }, \ + } \ +} + + +/** + * @brief Pack a wind message + * @param system_id ID of this system + * @param component_id ID of this component (e.g. 200 for IMU) + * @param msg The MAVLink message to compress the data into + * + * @param direction wind direction that wind is coming from (degrees) + * @param speed wind speed in ground plane (m/s) + * @param speed_z vertical wind speed (m/s) + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_wind_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, + float direction, float speed, float speed_z) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[12]; + _mav_put_float(buf, 0, direction); + _mav_put_float(buf, 4, speed); + _mav_put_float(buf, 8, speed_z); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 12); +#else + mavlink_wind_t packet; + packet.direction = direction; + packet.speed = speed; + packet.speed_z = speed_z; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 12); +#endif + + msg->msgid = MAVLINK_MSG_ID_WIND; + return mavlink_finalize_message(msg, system_id, component_id, 12, 1); +} + +/** + * @brief Pack a wind message on a channel + * @param system_id ID of this system + * @param component_id ID of this component (e.g. 200 for IMU) + * @param chan The MAVLink channel this message was sent over + * @param msg The MAVLink message to compress the data into + * @param direction wind direction that wind is coming from (degrees) + * @param speed wind speed in ground plane (m/s) + * @param speed_z vertical wind speed (m/s) + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_wind_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, + mavlink_message_t* msg, + float direction,float speed,float speed_z) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[12]; + _mav_put_float(buf, 0, direction); + _mav_put_float(buf, 4, speed); + _mav_put_float(buf, 8, speed_z); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 12); +#else + mavlink_wind_t packet; + packet.direction = direction; + packet.speed = speed; + packet.speed_z = speed_z; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 12); +#endif + + msg->msgid = MAVLINK_MSG_ID_WIND; + return mavlink_finalize_message_chan(msg, system_id, component_id, chan, 12, 1); +} + +/** + * @brief Encode a wind struct into a message + * + * @param system_id ID of this system + * @param component_id ID of this component (e.g. 200 for IMU) + * @param msg The MAVLink message to compress the data into + * @param wind C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_wind_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_wind_t* wind) +{ + return mavlink_msg_wind_pack(system_id, component_id, msg, wind->direction, wind->speed, wind->speed_z); +} + +/** + * @brief Send a wind message + * @param chan MAVLink channel to send the message + * + * @param direction wind direction that wind is coming from (degrees) + * @param speed wind speed in ground plane (m/s) + * @param speed_z vertical wind speed (m/s) + */ +#ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS + +static inline void mavlink_msg_wind_send(mavlink_channel_t chan, float direction, float speed, float speed_z) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[12]; + _mav_put_float(buf, 0, direction); + _mav_put_float(buf, 4, speed); + _mav_put_float(buf, 8, speed_z); + + _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_WIND, buf, 12, 1); +#else + mavlink_wind_t packet; + packet.direction = direction; + packet.speed = speed; + packet.speed_z = speed_z; + + _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_WIND, (const char *)&packet, 12, 1); +#endif +} + +#endif + +// MESSAGE WIND UNPACKING + + +/** + * @brief Get field direction from wind message + * + * @return wind direction that wind is coming from (degrees) + */ +static inline float mavlink_msg_wind_get_direction(const mavlink_message_t* msg) +{ + return _MAV_RETURN_float(msg, 0); +} + +/** + * @brief Get field speed from wind message + * + * @return wind speed in ground plane (m/s) + */ +static inline float mavlink_msg_wind_get_speed(const mavlink_message_t* msg) +{ + return _MAV_RETURN_float(msg, 4); +} + +/** + * @brief Get field speed_z from wind message + * + * @return vertical wind speed (m/s) + */ +static inline float mavlink_msg_wind_get_speed_z(const mavlink_message_t* msg) +{ + return _MAV_RETURN_float(msg, 8); +} + +/** + * @brief Decode a wind message into a struct + * + * @param msg The message to decode + * @param wind C-struct to decode the message contents into + */ +static inline void mavlink_msg_wind_decode(const mavlink_message_t* msg, mavlink_wind_t* wind) +{ +#if MAVLINK_NEED_BYTE_SWAP + wind->direction = mavlink_msg_wind_get_direction(msg); + wind->speed = mavlink_msg_wind_get_speed(msg); + wind->speed_z = mavlink_msg_wind_get_speed_z(msg); +#else + memcpy(wind, _MAV_PAYLOAD(msg), 12); +#endif +} diff --git a/src/GCS_MAVLink/include_v1.0/ardupilotmega/testsuite.h b/src/GCS_MAVLink/include_v1.0/ardupilotmega/testsuite.h index c372c91a1..07bf19ee0 100644 --- a/src/GCS_MAVLink/include_v1.0/ardupilotmega/testsuite.h +++ b/src/GCS_MAVLink/include_v1.0/ardupilotmega/testsuite.h @@ -534,14 +534,14 @@ static void mavlink_test_fence_point(uint8_t system_id, uint8_t component_id, ma }; mavlink_fence_point_t packet1, packet2; memset(&packet1, 0, sizeof(packet1)); - packet1.lat = packet_in.lat; - packet1.lng = packet_in.lng; - packet1.target_system = packet_in.target_system; - packet1.target_component = packet_in.target_component; - packet1.idx = packet_in.idx; - packet1.count = packet_in.count; - - + packet1.lat = packet_in.lat; + packet1.lng = packet_in.lng; + packet1.target_system = packet_in.target_system; + packet1.target_component = packet_in.target_component; + packet1.idx = packet_in.idx; + packet1.count = packet_in.count; + + memset(&packet2, 0, sizeof(packet2)); mavlink_msg_fence_point_encode(system_id, component_id, &msg, &packet1); @@ -561,11 +561,11 @@ static void mavlink_test_fence_point(uint8_t system_id, uint8_t component_id, ma memset(&packet2, 0, sizeof(packet2)); mavlink_msg_to_send_buffer(buffer, &msg); for (i=0; i>8) ^ (tmp<<8) ^ (tmp <<3) ^ (tmp>>4); } +#endif /** * @brief Initiliaze the buffer for the X.25 CRC @@ -52,7 +54,7 @@ static inline void crc_init(uint16_t* crcAccum) * @param length length of the byte array * @return the checksum over the buffer bytes **/ -static inline uint16_t crc_calculate(uint8_t* pBuffer, uint16_t length) +static inline uint16_t crc_calculate(const uint8_t* pBuffer, uint16_t length) { uint16_t crcTmp; crc_init(&crcTmp); diff --git a/src/GCS_MAVLink/include_v1.0/common/common.h b/src/GCS_MAVLink/include_v1.0/common/common.h index e4b681c56..c07e127a3 100644 --- a/src/GCS_MAVLink/include_v1.0/common/common.h +++ b/src/GCS_MAVLink/include_v1.0/common/common.h @@ -12,34 +12,21 @@ extern "C" { // MESSAGE LENGTHS AND CRCS #ifndef MAVLINK_MESSAGE_LENGTHS -#define MAVLINK_MESSAGE_LENGTHS {9, 31, 12, 0, 14, 28, 3, 32, 0, 0, 0, 6, 0, 0, 0, 0, 0, 0, 0, 0, 20, 2, 25, 23, 30, 101, 22, 26, 16, 14, 28, 32, 28, 28, 22, 22, 21, 6, 6, 37, 4, 4, 2, 2, 4, 2, 2, 3, 13, 12, 19, 17, 15, 15, 27, 25, 18, 18, 20, 20, 0, 0, 26, 0, 36, 0, 6, 4, 0, 21, 18, 0, 0, 0, 20, 0, 33, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 56, 42, 33, 0, 0, 0, 0, 0, 0, 0, 18, 32, 32, 20, 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, 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, 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, 36, 30, 18, 18, 51, 9, 3} +#define MAVLINK_MESSAGE_LENGTHS {9, 31, 12, 0, 14, 28, 3, 32, 0, 0, 0, 6, 0, 0, 0, 0, 0, 0, 0, 0, 20, 2, 25, 23, 30, 101, 22, 26, 16, 14, 28, 32, 28, 28, 22, 22, 21, 6, 6, 37, 4, 4, 2, 2, 4, 2, 2, 3, 13, 12, 19, 17, 15, 15, 27, 25, 18, 18, 20, 20, 9, 34, 26, 46, 36, 0, 6, 4, 0, 11, 18, 0, 0, 0, 20, 0, 33, 3, 0, 0, 20, 22, 0, 0, 0, 0, 0, 0, 0, 28, 56, 42, 33, 0, 0, 0, 0, 0, 0, 0, 26, 32, 32, 20, 32, 62, 54, 0, 0, 0, 254, 249, 9, 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, 33, 25, 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, 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, 36, 30, 18, 18, 51, 9, 0} #endif #ifndef MAVLINK_MESSAGE_CRCS -#define MAVLINK_MESSAGE_CRCS {50, 124, 137, 0, 237, 217, 104, 119, 0, 0, 0, 89, 0, 0, 0, 0, 0, 0, 0, 0, 214, 159, 220, 168, 24, 23, 170, 144, 67, 115, 39, 246, 185, 104, 237, 244, 222, 212, 9, 254, 230, 28, 28, 132, 221, 232, 11, 153, 41, 39, 214, 223, 141, 33, 15, 3, 100, 24, 239, 238, 0, 0, 183, 0, 130, 0, 148, 21, 0, 52, 124, 0, 0, 0, 20, 0, 152, 143, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 183, 63, 54, 0, 0, 0, 0, 0, 0, 0, 19, 102, 158, 208, 56, 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, 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, 0, 0, 0, 0, 0, 0, 0, 0, 204, 49, 170, 44, 83, 46, 247} +#define MAVLINK_MESSAGE_CRCS {50, 124, 137, 0, 237, 217, 104, 119, 0, 0, 0, 89, 0, 0, 0, 0, 0, 0, 0, 0, 214, 159, 220, 168, 24, 23, 170, 144, 67, 115, 39, 246, 185, 104, 237, 244, 222, 212, 9, 254, 230, 28, 28, 132, 221, 232, 11, 153, 41, 39, 214, 223, 141, 33, 15, 3, 100, 24, 239, 238, 30, 240, 183, 130, 130, 0, 148, 21, 0, 243, 124, 0, 0, 0, 20, 0, 152, 143, 0, 0, 127, 106, 0, 0, 0, 0, 0, 0, 0, 231, 183, 63, 54, 0, 0, 0, 0, 0, 0, 0, 175, 102, 158, 208, 56, 93, 211, 0, 0, 0, 235, 93, 124, 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, 42, 241, 15, 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, 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, 204, 49, 170, 44, 83, 46, 0} #endif #ifndef MAVLINK_MESSAGE_INFO -#define MAVLINK_MESSAGE_INFO {MAVLINK_MESSAGE_INFO_HEARTBEAT, MAVLINK_MESSAGE_INFO_SYS_STATUS, MAVLINK_MESSAGE_INFO_SYSTEM_TIME, {NULL}, MAVLINK_MESSAGE_INFO_PING, MAVLINK_MESSAGE_INFO_CHANGE_OPERATOR_CONTROL, MAVLINK_MESSAGE_INFO_CHANGE_OPERATOR_CONTROL_ACK, MAVLINK_MESSAGE_INFO_AUTH_KEY, {NULL}, {NULL}, {NULL}, MAVLINK_MESSAGE_INFO_SET_MODE, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, MAVLINK_MESSAGE_INFO_PARAM_REQUEST_READ, MAVLINK_MESSAGE_INFO_PARAM_REQUEST_LIST, MAVLINK_MESSAGE_INFO_PARAM_VALUE, MAVLINK_MESSAGE_INFO_PARAM_SET, MAVLINK_MESSAGE_INFO_GPS_RAW_INT, MAVLINK_MESSAGE_INFO_GPS_STATUS, MAVLINK_MESSAGE_INFO_SCALED_IMU, MAVLINK_MESSAGE_INFO_RAW_IMU, MAVLINK_MESSAGE_INFO_RAW_PRESSURE, MAVLINK_MESSAGE_INFO_SCALED_PRESSURE, MAVLINK_MESSAGE_INFO_ATTITUDE, MAVLINK_MESSAGE_INFO_ATTITUDE_QUATERNION, MAVLINK_MESSAGE_INFO_LOCAL_POSITION_NED, MAVLINK_MESSAGE_INFO_GLOBAL_POSITION_INT, MAVLINK_MESSAGE_INFO_RC_CHANNELS_SCALED, MAVLINK_MESSAGE_INFO_RC_CHANNELS_RAW, MAVLINK_MESSAGE_INFO_SERVO_OUTPUT_RAW, MAVLINK_MESSAGE_INFO_MISSION_REQUEST_PARTIAL_LIST, MAVLINK_MESSAGE_INFO_MISSION_WRITE_PARTIAL_LIST, MAVLINK_MESSAGE_INFO_MISSION_ITEM, MAVLINK_MESSAGE_INFO_MISSION_REQUEST, MAVLINK_MESSAGE_INFO_MISSION_SET_CURRENT, MAVLINK_MESSAGE_INFO_MISSION_CURRENT, MAVLINK_MESSAGE_INFO_MISSION_REQUEST_LIST, MAVLINK_MESSAGE_INFO_MISSION_COUNT, MAVLINK_MESSAGE_INFO_MISSION_CLEAR_ALL, MAVLINK_MESSAGE_INFO_MISSION_ITEM_REACHED, MAVLINK_MESSAGE_INFO_MISSION_ACK, MAVLINK_MESSAGE_INFO_SET_GPS_GLOBAL_ORIGIN, MAVLINK_MESSAGE_INFO_GPS_GLOBAL_ORIGIN, MAVLINK_MESSAGE_INFO_SET_LOCAL_POSITION_SETPOINT, MAVLINK_MESSAGE_INFO_LOCAL_POSITION_SETPOINT, MAVLINK_MESSAGE_INFO_GLOBAL_POSITION_SETPOINT_INT, MAVLINK_MESSAGE_INFO_SET_GLOBAL_POSITION_SETPOINT_INT, MAVLINK_MESSAGE_INFO_SAFETY_SET_ALLOWED_AREA, MAVLINK_MESSAGE_INFO_SAFETY_ALLOWED_AREA, MAVLINK_MESSAGE_INFO_SET_ROLL_PITCH_YAW_THRUST, MAVLINK_MESSAGE_INFO_SET_ROLL_PITCH_YAW_SPEED_THRUST, MAVLINK_MESSAGE_INFO_ROLL_PITCH_YAW_THRUST_SETPOINT, MAVLINK_MESSAGE_INFO_ROLL_PITCH_YAW_SPEED_THRUST_SETPOINT, {NULL}, {NULL}, MAVLINK_MESSAGE_INFO_NAV_CONTROLLER_OUTPUT, {NULL}, MAVLINK_MESSAGE_INFO_STATE_CORRECTION, {NULL}, MAVLINK_MESSAGE_INFO_REQUEST_DATA_STREAM, MAVLINK_MESSAGE_INFO_DATA_STREAM, {NULL}, MAVLINK_MESSAGE_INFO_MANUAL_CONTROL, MAVLINK_MESSAGE_INFO_RC_CHANNELS_OVERRIDE, {NULL}, {NULL}, {NULL}, MAVLINK_MESSAGE_INFO_VFR_HUD, {NULL}, MAVLINK_MESSAGE_INFO_COMMAND_LONG, MAVLINK_MESSAGE_INFO_COMMAND_ACK, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, MAVLINK_MESSAGE_INFO_HIL_STATE, MAVLINK_MESSAGE_INFO_HIL_CONTROLS, MAVLINK_MESSAGE_INFO_HIL_RC_INPUTS_RAW, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, MAVLINK_MESSAGE_INFO_OPTICAL_FLOW, MAVLINK_MESSAGE_INFO_GLOBAL_VISION_POSITION_ESTIMATE, MAVLINK_MESSAGE_INFO_VISION_POSITION_ESTIMATE, MAVLINK_MESSAGE_INFO_VISION_SPEED_ESTIMATE, MAVLINK_MESSAGE_INFO_VICON_POSITION_ESTIMATE, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, MAVLINK_MESSAGE_INFO_MEMORY_VECT, MAVLINK_MESSAGE_INFO_DEBUG_VECT, MAVLINK_MESSAGE_INFO_NAMED_VALUE_FLOAT, MAVLINK_MESSAGE_INFO_NAMED_VALUE_INT, MAVLINK_MESSAGE_INFO_STATUSTEXT, MAVLINK_MESSAGE_INFO_DEBUG, MAVLINK_MESSAGE_INFO_EXTENDED_MESSAGE} +#define MAVLINK_MESSAGE_INFO {MAVLINK_MESSAGE_INFO_HEARTBEAT, MAVLINK_MESSAGE_INFO_SYS_STATUS, MAVLINK_MESSAGE_INFO_SYSTEM_TIME, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, MAVLINK_MESSAGE_INFO_PING, MAVLINK_MESSAGE_INFO_CHANGE_OPERATOR_CONTROL, MAVLINK_MESSAGE_INFO_CHANGE_OPERATOR_CONTROL_ACK, MAVLINK_MESSAGE_INFO_AUTH_KEY, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, MAVLINK_MESSAGE_INFO_SET_MODE, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, MAVLINK_MESSAGE_INFO_PARAM_REQUEST_READ, MAVLINK_MESSAGE_INFO_PARAM_REQUEST_LIST, MAVLINK_MESSAGE_INFO_PARAM_VALUE, MAVLINK_MESSAGE_INFO_PARAM_SET, MAVLINK_MESSAGE_INFO_GPS_RAW_INT, MAVLINK_MESSAGE_INFO_GPS_STATUS, MAVLINK_MESSAGE_INFO_SCALED_IMU, MAVLINK_MESSAGE_INFO_RAW_IMU, MAVLINK_MESSAGE_INFO_RAW_PRESSURE, MAVLINK_MESSAGE_INFO_SCALED_PRESSURE, MAVLINK_MESSAGE_INFO_ATTITUDE, MAVLINK_MESSAGE_INFO_ATTITUDE_QUATERNION, MAVLINK_MESSAGE_INFO_LOCAL_POSITION_NED, MAVLINK_MESSAGE_INFO_GLOBAL_POSITION_INT, MAVLINK_MESSAGE_INFO_RC_CHANNELS_SCALED, MAVLINK_MESSAGE_INFO_RC_CHANNELS_RAW, MAVLINK_MESSAGE_INFO_SERVO_OUTPUT_RAW, MAVLINK_MESSAGE_INFO_MISSION_REQUEST_PARTIAL_LIST, MAVLINK_MESSAGE_INFO_MISSION_WRITE_PARTIAL_LIST, MAVLINK_MESSAGE_INFO_MISSION_ITEM, MAVLINK_MESSAGE_INFO_MISSION_REQUEST, MAVLINK_MESSAGE_INFO_MISSION_SET_CURRENT, MAVLINK_MESSAGE_INFO_MISSION_CURRENT, MAVLINK_MESSAGE_INFO_MISSION_REQUEST_LIST, MAVLINK_MESSAGE_INFO_MISSION_COUNT, MAVLINK_MESSAGE_INFO_MISSION_CLEAR_ALL, MAVLINK_MESSAGE_INFO_MISSION_ITEM_REACHED, MAVLINK_MESSAGE_INFO_MISSION_ACK, MAVLINK_MESSAGE_INFO_SET_GPS_GLOBAL_ORIGIN, MAVLINK_MESSAGE_INFO_GPS_GLOBAL_ORIGIN, MAVLINK_MESSAGE_INFO_SET_LOCAL_POSITION_SETPOINT, MAVLINK_MESSAGE_INFO_LOCAL_POSITION_SETPOINT, MAVLINK_MESSAGE_INFO_GLOBAL_POSITION_SETPOINT_INT, MAVLINK_MESSAGE_INFO_SET_GLOBAL_POSITION_SETPOINT_INT, MAVLINK_MESSAGE_INFO_SAFETY_SET_ALLOWED_AREA, MAVLINK_MESSAGE_INFO_SAFETY_ALLOWED_AREA, MAVLINK_MESSAGE_INFO_SET_ROLL_PITCH_YAW_THRUST, MAVLINK_MESSAGE_INFO_SET_ROLL_PITCH_YAW_SPEED_THRUST, MAVLINK_MESSAGE_INFO_ROLL_PITCH_YAW_THRUST_SETPOINT, MAVLINK_MESSAGE_INFO_ROLL_PITCH_YAW_SPEED_THRUST_SETPOINT, MAVLINK_MESSAGE_INFO_SET_QUAD_MOTORS_SETPOINT, MAVLINK_MESSAGE_INFO_SET_QUAD_SWARM_ROLL_PITCH_YAW_THRUST, MAVLINK_MESSAGE_INFO_NAV_CONTROLLER_OUTPUT, MAVLINK_MESSAGE_INFO_SET_QUAD_SWARM_LED_ROLL_PITCH_YAW_THRUST, MAVLINK_MESSAGE_INFO_STATE_CORRECTION, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, MAVLINK_MESSAGE_INFO_REQUEST_DATA_STREAM, MAVLINK_MESSAGE_INFO_DATA_STREAM, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, MAVLINK_MESSAGE_INFO_MANUAL_CONTROL, MAVLINK_MESSAGE_INFO_RC_CHANNELS_OVERRIDE, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, MAVLINK_MESSAGE_INFO_VFR_HUD, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, MAVLINK_MESSAGE_INFO_COMMAND_LONG, MAVLINK_MESSAGE_INFO_COMMAND_ACK, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, MAVLINK_MESSAGE_INFO_ROLL_PITCH_YAW_RATES_THRUST_SETPOINT, MAVLINK_MESSAGE_INFO_MANUAL_SETPOINT, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, MAVLINK_MESSAGE_INFO_LOCAL_POSITION_NED_SYSTEM_GLOBAL_OFFSET, MAVLINK_MESSAGE_INFO_HIL_STATE, MAVLINK_MESSAGE_INFO_HIL_CONTROLS, MAVLINK_MESSAGE_INFO_HIL_RC_INPUTS_RAW, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, MAVLINK_MESSAGE_INFO_OPTICAL_FLOW, MAVLINK_MESSAGE_INFO_GLOBAL_VISION_POSITION_ESTIMATE, MAVLINK_MESSAGE_INFO_VISION_POSITION_ESTIMATE, MAVLINK_MESSAGE_INFO_VISION_SPEED_ESTIMATE, MAVLINK_MESSAGE_INFO_VICON_POSITION_ESTIMATE, MAVLINK_MESSAGE_INFO_HIGHRES_IMU, MAVLINK_MESSAGE_INFO_OMNIDIRECTIONAL_FLOW, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, MAVLINK_MESSAGE_INFO_FILE_TRANSFER_START, MAVLINK_MESSAGE_INFO_FILE_TRANSFER_DIR_LIST, MAVLINK_MESSAGE_INFO_FILE_TRANSFER_RES, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, MAVLINK_MESSAGE_INFO_BATTERY_STATUS, MAVLINK_MESSAGE_INFO_SETPOINT_8DOF, MAVLINK_MESSAGE_INFO_SETPOINT_6DOF, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, MAVLINK_MESSAGE_INFO_MEMORY_VECT, MAVLINK_MESSAGE_INFO_DEBUG_VECT, MAVLINK_MESSAGE_INFO_NAMED_VALUE_FLOAT, MAVLINK_MESSAGE_INFO_NAMED_VALUE_INT, MAVLINK_MESSAGE_INFO_STATUSTEXT, MAVLINK_MESSAGE_INFO_DEBUG, {"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}} #endif #include "../protocol.h" #define MAVLINK_ENABLED_COMMON - - -// MAVLINK VERSION - -#ifndef MAVLINK_VERSION -#define MAVLINK_VERSION 3 -#endif - -#if (MAVLINK_VERSION == 0) -#undef MAVLINK_VERSION -#define MAVLINK_VERSION 3 -#endif - // ENUM DEFINITIONS @@ -60,7 +47,36 @@ enum MAV_AUTOPILOT MAV_AUTOPILOT_PPZ=9, /* PPZ UAV - http://nongnu.org/paparazzi | */ MAV_AUTOPILOT_UDB=10, /* UAV Dev Board | */ MAV_AUTOPILOT_FP=11, /* FlexiPilot | */ - MAV_AUTOPILOT_ENUM_END=12, /* | */ + MAV_AUTOPILOT_PX4=12, /* PX4 Autopilot - http://pixhawk.ethz.ch/px4/ | */ + MAV_AUTOPILOT_SMACCMPILOT=13, /* SMACCMPilot - http://smaccmpilot.org | */ + MAV_AUTOPILOT_ENUM_END=14, /* | */ +}; +#endif + +/** @brief */ +#ifndef HAVE_ENUM_MAV_TYPE +#define HAVE_ENUM_MAV_TYPE +enum MAV_TYPE +{ + MAV_TYPE_GENERIC=0, /* Generic micro air vehicle. | */ + MAV_TYPE_FIXED_WING=1, /* Fixed wing aircraft. | */ + MAV_TYPE_QUADROTOR=2, /* Quadrotor | */ + MAV_TYPE_COAXIAL=3, /* Coaxial helicopter | */ + MAV_TYPE_HELICOPTER=4, /* Normal helicopter with tail rotor. | */ + MAV_TYPE_ANTENNA_TRACKER=5, /* Ground installation | */ + MAV_TYPE_GCS=6, /* Operator control unit / ground control station | */ + MAV_TYPE_AIRSHIP=7, /* Airship, controlled | */ + MAV_TYPE_FREE_BALLOON=8, /* Free balloon, uncontrolled | */ + MAV_TYPE_ROCKET=9, /* Rocket | */ + MAV_TYPE_GROUND_ROVER=10, /* Ground rover | */ + MAV_TYPE_SURFACE_BOAT=11, /* Surface vessel, boat, ship | */ + MAV_TYPE_SUBMARINE=12, /* Submarine | */ + MAV_TYPE_HEXAROTOR=13, /* Hexarotor | */ + MAV_TYPE_OCTOROTOR=14, /* Octorotor | */ + MAV_TYPE_TRICOPTER=15, /* Octorotor | */ + MAV_TYPE_FLAPPING_WING=16, /* Flapping wing | */ + MAV_TYPE_KITE=17, /* Flapping wing | */ + MAV_TYPE_ENUM_END=18, /* | */ }; #endif @@ -149,32 +165,6 @@ enum MAV_STATE }; #endif -/** @brief */ -#ifndef HAVE_ENUM_MAV_TYPE -#define HAVE_ENUM_MAV_TYPE -enum MAV_TYPE -{ - MAV_TYPE_GENERIC=0, /* Generic micro air vehicle. | */ - MAV_TYPE_FIXED_WING=1, /* Fixed wing aircraft. | */ - MAV_TYPE_QUADROTOR=2, /* Quadrotor | */ - MAV_TYPE_COAXIAL=3, /* Coaxial helicopter | */ - MAV_TYPE_HELICOPTER=4, /* Normal helicopter with tail rotor. | */ - MAV_TYPE_ANTENNA_TRACKER=5, /* Ground installation | */ - MAV_TYPE_GCS=6, /* Operator control unit / ground control station | */ - MAV_TYPE_AIRSHIP=7, /* Airship, controlled | */ - MAV_TYPE_FREE_BALLOON=8, /* Free balloon, uncontrolled | */ - MAV_TYPE_ROCKET=9, /* Rocket | */ - MAV_TYPE_GROUND_ROVER=10, /* Ground rover | */ - MAV_TYPE_SURFACE_BOAT=11, /* Surface vessel, boat, ship | */ - MAV_TYPE_SUBMARINE=12, /* Submarine | */ - MAV_TYPE_HEXAROTOR=13, /* Hexarotor | */ - MAV_TYPE_OCTOROTOR=14, /* Octorotor | */ - MAV_TYPE_TRICOPTER=15, /* Octorotor | */ - MAV_TYPE_FLAPPING_WING=16, /* Flapping wing | */ - MAV_TYPE_ENUM_END=17, /* | */ -}; -#endif - /** @brief */ #ifndef HAVE_ENUM_MAV_COMPONENT #define HAVE_ENUM_MAV_COMPONENT @@ -241,8 +231,7 @@ enum MAVLINK_DATA_STREAM_TYPE /** @brief Data stream IDs. A data stream is not a fixed set of messages, but rather a recommendation to the autopilot software. Individual autopilots may or may not obey - the recommended messages. - */ + the recommended messages. */ #ifndef HAVE_ENUM_MAV_DATA_STREAM #define HAVE_ENUM_MAV_DATA_STREAM enum MAV_DATA_STREAM @@ -262,8 +251,7 @@ enum MAV_DATA_STREAM /** @brief The ROI (region of interest) for the vehicle. This can be be used by the vehicle for camera/vehicle attitude alignment (see - MAV_CMD_NAV_ROI). - */ + MAV_CMD_NAV_ROI). */ #ifndef HAVE_ENUM_MAV_ROI #define HAVE_ENUM_MAV_ROI enum MAV_ROI @@ -295,19 +283,22 @@ enum MAV_CMD_ACK }; #endif -/** @brief type of a mavlink parameter */ -#ifndef HAVE_ENUM_MAV_VAR -#define HAVE_ENUM_MAV_VAR -enum MAV_VAR +/** @brief Specifies the datatype of a MAVLink parameter. */ +#ifndef HAVE_ENUM_MAV_PARAM_TYPE +#define HAVE_ENUM_MAV_PARAM_TYPE +enum MAV_PARAM_TYPE { - MAV_VAR_FLOAT=0, /* 32 bit float | */ - MAV_VAR_UINT8=1, /* 8 bit unsigned integer | */ - MAV_VAR_INT8=2, /* 8 bit signed integer | */ - MAV_VAR_UINT16=3, /* 16 bit unsigned integer | */ - MAV_VAR_INT16=4, /* 16 bit signed integer | */ - MAV_VAR_UINT32=5, /* 32 bit unsigned integer | */ - MAV_VAR_INT32=6, /* 32 bit signed integer | */ - MAV_VAR_ENUM_END=7, /* | */ + MAV_PARAM_TYPE_UINT8=1, /* 8-bit unsigned integer | */ + MAV_PARAM_TYPE_INT8=2, /* 8-bit signed integer | */ + MAV_PARAM_TYPE_UINT16=3, /* 16-bit unsigned integer | */ + MAV_PARAM_TYPE_INT16=4, /* 16-bit signed integer | */ + MAV_PARAM_TYPE_UINT32=5, /* 32-bit unsigned integer | */ + MAV_PARAM_TYPE_INT32=6, /* 32-bit signed integer | */ + MAV_PARAM_TYPE_UINT64=7, /* 64-bit unsigned integer | */ + MAV_PARAM_TYPE_INT64=8, /* 64-bit signed integer | */ + MAV_PARAM_TYPE_REAL32=9, /* 32-bit floating-point | */ + MAV_PARAM_TYPE_REAL64=10, /* 64-bit floating-point | */ + MAV_PARAM_TYPE_ENUM_END=11, /* | */ }; #endif @@ -349,6 +340,36 @@ enum MAV_MISSION_RESULT }; #endif +/** @brief Indicates the severity level, generally used for status messages to indicate their relative urgency. Based on RFC-5424 using expanded definitions at: http://www.kiwisyslog.com/kb/info:-syslog-message-levels/. */ +#ifndef HAVE_ENUM_MAV_SEVERITY +#define HAVE_ENUM_MAV_SEVERITY +enum MAV_SEVERITY +{ + MAV_SEVERITY_EMERGENCY=0, /* System is unusable. This is a "panic" condition. | */ + MAV_SEVERITY_ALERT=1, /* Action should be taken immediately. Indicates error in non-critical systems. | */ + MAV_SEVERITY_CRITICAL=2, /* Action must be taken immediately. Indicates failure in a primary system. | */ + MAV_SEVERITY_ERROR=3, /* Indicates an error in secondary/redundant systems. | */ + MAV_SEVERITY_WARNING=4, /* Indicates about a possible future error if this is not resolved within a given timeframe. Example would be a low battery warning. | */ + MAV_SEVERITY_NOTICE=5, /* An unusual event has occured, though not an error condition. This should be investigated for the root cause. | */ + MAV_SEVERITY_INFO=6, /* Normal operational messages. Useful for logging. No action is required for these messages. | */ + MAV_SEVERITY_DEBUG=7, /* Useful non-operational messages that can assist in debugging. These should not occur during normal operation. | */ + MAV_SEVERITY_ENUM_END=8, /* | */ +}; +#endif + + + +// MAVLINK VERSION + +#ifndef MAVLINK_VERSION +#define MAVLINK_VERSION 3 +#endif + +#if (MAVLINK_VERSION == 0) +#undef MAVLINK_VERSION +#define MAVLINK_VERSION 3 +#endif + // MESSAGE DEFINITIONS #include "./mavlink_msg_heartbeat.h" #include "./mavlink_msg_sys_status.h" @@ -398,7 +419,10 @@ enum MAV_MISSION_RESULT #include "./mavlink_msg_set_roll_pitch_yaw_speed_thrust.h" #include "./mavlink_msg_roll_pitch_yaw_thrust_setpoint.h" #include "./mavlink_msg_roll_pitch_yaw_speed_thrust_setpoint.h" +#include "./mavlink_msg_set_quad_motors_setpoint.h" +#include "./mavlink_msg_set_quad_swarm_roll_pitch_yaw_thrust.h" #include "./mavlink_msg_nav_controller_output.h" +#include "./mavlink_msg_set_quad_swarm_led_roll_pitch_yaw_thrust.h" #include "./mavlink_msg_state_correction.h" #include "./mavlink_msg_request_data_stream.h" #include "./mavlink_msg_data_stream.h" @@ -407,6 +431,9 @@ enum MAV_MISSION_RESULT #include "./mavlink_msg_vfr_hud.h" #include "./mavlink_msg_command_long.h" #include "./mavlink_msg_command_ack.h" +#include "./mavlink_msg_roll_pitch_yaw_rates_thrust_setpoint.h" +#include "./mavlink_msg_manual_setpoint.h" +#include "./mavlink_msg_local_position_ned_system_global_offset.h" #include "./mavlink_msg_hil_state.h" #include "./mavlink_msg_hil_controls.h" #include "./mavlink_msg_hil_rc_inputs_raw.h" @@ -415,13 +442,20 @@ enum MAV_MISSION_RESULT #include "./mavlink_msg_vision_position_estimate.h" #include "./mavlink_msg_vision_speed_estimate.h" #include "./mavlink_msg_vicon_position_estimate.h" +#include "./mavlink_msg_highres_imu.h" +#include "./mavlink_msg_omnidirectional_flow.h" +#include "./mavlink_msg_file_transfer_start.h" +#include "./mavlink_msg_file_transfer_dir_list.h" +#include "./mavlink_msg_file_transfer_res.h" +#include "./mavlink_msg_battery_status.h" +#include "./mavlink_msg_setpoint_8dof.h" +#include "./mavlink_msg_setpoint_6dof.h" #include "./mavlink_msg_memory_vect.h" #include "./mavlink_msg_debug_vect.h" #include "./mavlink_msg_named_value_float.h" #include "./mavlink_msg_named_value_int.h" #include "./mavlink_msg_statustext.h" #include "./mavlink_msg_debug.h" -#include "./mavlink_msg_extended_message.h" #ifdef __cplusplus } diff --git a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_attitude.h b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_attitude.h index 16045b974..6db0592f2 100644 --- a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_attitude.h +++ b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_attitude.h @@ -5,9 +5,9 @@ typedef struct __mavlink_attitude_t { uint32_t time_boot_ms; ///< Timestamp (milliseconds since system boot) - float roll; ///< Roll angle (rad) - float pitch; ///< Pitch angle (rad) - float yaw; ///< Yaw angle (rad) + float roll; ///< Roll angle (rad, -pi..+pi) + float pitch; ///< Pitch angle (rad, -pi..+pi) + float yaw; ///< Yaw angle (rad, -pi..+pi) float rollspeed; ///< Roll angular speed (rad/s) float pitchspeed; ///< Pitch angular speed (rad/s) float yawspeed; ///< Yaw angular speed (rad/s) @@ -39,9 +39,9 @@ typedef struct __mavlink_attitude_t * @param msg The MAVLink message to compress the data into * * @param time_boot_ms Timestamp (milliseconds since system boot) - * @param roll Roll angle (rad) - * @param pitch Pitch angle (rad) - * @param yaw Yaw angle (rad) + * @param roll Roll angle (rad, -pi..+pi) + * @param pitch Pitch angle (rad, -pi..+pi) + * @param yaw Yaw angle (rad, -pi..+pi) * @param rollspeed Roll angular speed (rad/s) * @param pitchspeed Pitch angular speed (rad/s) * @param yawspeed Yaw angular speed (rad/s) @@ -60,7 +60,7 @@ static inline uint16_t mavlink_msg_attitude_pack(uint8_t system_id, uint8_t comp _mav_put_float(buf, 20, pitchspeed); _mav_put_float(buf, 24, yawspeed); - memcpy(_MAV_PAYLOAD(msg), buf, 28); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 28); #else mavlink_attitude_t packet; packet.time_boot_ms = time_boot_ms; @@ -71,7 +71,7 @@ static inline uint16_t mavlink_msg_attitude_pack(uint8_t system_id, uint8_t comp packet.pitchspeed = pitchspeed; packet.yawspeed = yawspeed; - memcpy(_MAV_PAYLOAD(msg), &packet, 28); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 28); #endif msg->msgid = MAVLINK_MSG_ID_ATTITUDE; @@ -85,9 +85,9 @@ static inline uint16_t mavlink_msg_attitude_pack(uint8_t system_id, uint8_t comp * @param chan The MAVLink channel this message was sent over * @param msg The MAVLink message to compress the data into * @param time_boot_ms Timestamp (milliseconds since system boot) - * @param roll Roll angle (rad) - * @param pitch Pitch angle (rad) - * @param yaw Yaw angle (rad) + * @param roll Roll angle (rad, -pi..+pi) + * @param pitch Pitch angle (rad, -pi..+pi) + * @param yaw Yaw angle (rad, -pi..+pi) * @param rollspeed Roll angular speed (rad/s) * @param pitchspeed Pitch angular speed (rad/s) * @param yawspeed Yaw angular speed (rad/s) @@ -107,7 +107,7 @@ static inline uint16_t mavlink_msg_attitude_pack_chan(uint8_t system_id, uint8_t _mav_put_float(buf, 20, pitchspeed); _mav_put_float(buf, 24, yawspeed); - memcpy(_MAV_PAYLOAD(msg), buf, 28); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 28); #else mavlink_attitude_t packet; packet.time_boot_ms = time_boot_ms; @@ -118,7 +118,7 @@ static inline uint16_t mavlink_msg_attitude_pack_chan(uint8_t system_id, uint8_t packet.pitchspeed = pitchspeed; packet.yawspeed = yawspeed; - memcpy(_MAV_PAYLOAD(msg), &packet, 28); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 28); #endif msg->msgid = MAVLINK_MSG_ID_ATTITUDE; @@ -143,9 +143,9 @@ static inline uint16_t mavlink_msg_attitude_encode(uint8_t system_id, uint8_t co * @param chan MAVLink channel to send the message * * @param time_boot_ms Timestamp (milliseconds since system boot) - * @param roll Roll angle (rad) - * @param pitch Pitch angle (rad) - * @param yaw Yaw angle (rad) + * @param roll Roll angle (rad, -pi..+pi) + * @param pitch Pitch angle (rad, -pi..+pi) + * @param yaw Yaw angle (rad, -pi..+pi) * @param rollspeed Roll angular speed (rad/s) * @param pitchspeed Pitch angular speed (rad/s) * @param yawspeed Yaw angular speed (rad/s) @@ -197,7 +197,7 @@ static inline uint32_t mavlink_msg_attitude_get_time_boot_ms(const mavlink_messa /** * @brief Get field roll from attitude message * - * @return Roll angle (rad) + * @return Roll angle (rad, -pi..+pi) */ static inline float mavlink_msg_attitude_get_roll(const mavlink_message_t* msg) { @@ -207,7 +207,7 @@ static inline float mavlink_msg_attitude_get_roll(const mavlink_message_t* msg) /** * @brief Get field pitch from attitude message * - * @return Pitch angle (rad) + * @return Pitch angle (rad, -pi..+pi) */ static inline float mavlink_msg_attitude_get_pitch(const mavlink_message_t* msg) { @@ -217,7 +217,7 @@ static inline float mavlink_msg_attitude_get_pitch(const mavlink_message_t* msg) /** * @brief Get field yaw from attitude message * - * @return Yaw angle (rad) + * @return Yaw angle (rad, -pi..+pi) */ static inline float mavlink_msg_attitude_get_yaw(const mavlink_message_t* msg) { diff --git a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_attitude_quaternion.h b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_attitude_quaternion.h index 215aff6d0..556048865 100644 --- a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_attitude_quaternion.h +++ b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_attitude_quaternion.h @@ -64,7 +64,7 @@ static inline uint16_t mavlink_msg_attitude_quaternion_pack(uint8_t system_id, u _mav_put_float(buf, 24, pitchspeed); _mav_put_float(buf, 28, yawspeed); - memcpy(_MAV_PAYLOAD(msg), buf, 32); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 32); #else mavlink_attitude_quaternion_t packet; packet.time_boot_ms = time_boot_ms; @@ -76,7 +76,7 @@ static inline uint16_t mavlink_msg_attitude_quaternion_pack(uint8_t system_id, u packet.pitchspeed = pitchspeed; packet.yawspeed = yawspeed; - memcpy(_MAV_PAYLOAD(msg), &packet, 32); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 32); #endif msg->msgid = MAVLINK_MSG_ID_ATTITUDE_QUATERNION; @@ -114,7 +114,7 @@ static inline uint16_t mavlink_msg_attitude_quaternion_pack_chan(uint8_t system_ _mav_put_float(buf, 24, pitchspeed); _mav_put_float(buf, 28, yawspeed); - memcpy(_MAV_PAYLOAD(msg), buf, 32); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 32); #else mavlink_attitude_quaternion_t packet; packet.time_boot_ms = time_boot_ms; @@ -126,7 +126,7 @@ static inline uint16_t mavlink_msg_attitude_quaternion_pack_chan(uint8_t system_ packet.pitchspeed = pitchspeed; packet.yawspeed = yawspeed; - memcpy(_MAV_PAYLOAD(msg), &packet, 32); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 32); #endif msg->msgid = MAVLINK_MSG_ID_ATTITUDE_QUATERNION; diff --git a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_auth_key.h b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_auth_key.h index cc77e4e54..baa119fde 100644 --- a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_auth_key.h +++ b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_auth_key.h @@ -36,12 +36,12 @@ static inline uint16_t mavlink_msg_auth_key_pack(uint8_t system_id, uint8_t comp char buf[32]; _mav_put_char_array(buf, 0, key, 32); - memcpy(_MAV_PAYLOAD(msg), buf, 32); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 32); #else mavlink_auth_key_t packet; mav_array_memcpy(packet.key, key, sizeof(char)*32); - memcpy(_MAV_PAYLOAD(msg), &packet, 32); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 32); #endif msg->msgid = MAVLINK_MSG_ID_AUTH_KEY; @@ -65,12 +65,12 @@ static inline uint16_t mavlink_msg_auth_key_pack_chan(uint8_t system_id, uint8_t char buf[32]; _mav_put_char_array(buf, 0, key, 32); - memcpy(_MAV_PAYLOAD(msg), buf, 32); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 32); #else mavlink_auth_key_t packet; mav_array_memcpy(packet.key, key, sizeof(char)*32); - memcpy(_MAV_PAYLOAD(msg), &packet, 32); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 32); #endif msg->msgid = MAVLINK_MSG_ID_AUTH_KEY; diff --git a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_battery_status.h b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_battery_status.h new file mode 100644 index 000000000..c78fb4f31 --- /dev/null +++ b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_battery_status.h @@ -0,0 +1,320 @@ +// MESSAGE BATTERY_STATUS PACKING + +#define MAVLINK_MSG_ID_BATTERY_STATUS 147 + +typedef struct __mavlink_battery_status_t +{ + uint16_t voltage_cell_1; ///< Battery voltage of cell 1, in millivolts (1 = 1 millivolt) + uint16_t voltage_cell_2; ///< Battery voltage of cell 2, in millivolts (1 = 1 millivolt), -1: no cell + uint16_t voltage_cell_3; ///< Battery voltage of cell 3, in millivolts (1 = 1 millivolt), -1: no cell + uint16_t voltage_cell_4; ///< Battery voltage of cell 4, in millivolts (1 = 1 millivolt), -1: no cell + uint16_t voltage_cell_5; ///< Battery voltage of cell 5, in millivolts (1 = 1 millivolt), -1: no cell + uint16_t voltage_cell_6; ///< Battery voltage of cell 6, in millivolts (1 = 1 millivolt), -1: no cell + int16_t current_battery; ///< Battery current, in 10*milliamperes (1 = 10 milliampere), -1: autopilot does not measure the current + uint8_t accu_id; ///< Accupack ID + int8_t battery_remaining; ///< Remaining battery energy: (0%: 0, 100%: 100), -1: autopilot does not estimate the remaining battery +} mavlink_battery_status_t; + +#define MAVLINK_MSG_ID_BATTERY_STATUS_LEN 16 +#define MAVLINK_MSG_ID_147_LEN 16 + + + +#define MAVLINK_MESSAGE_INFO_BATTERY_STATUS { \ + "BATTERY_STATUS", \ + 9, \ + { { "voltage_cell_1", NULL, MAVLINK_TYPE_UINT16_T, 0, 0, offsetof(mavlink_battery_status_t, voltage_cell_1) }, \ + { "voltage_cell_2", NULL, MAVLINK_TYPE_UINT16_T, 0, 2, offsetof(mavlink_battery_status_t, voltage_cell_2) }, \ + { "voltage_cell_3", NULL, MAVLINK_TYPE_UINT16_T, 0, 4, offsetof(mavlink_battery_status_t, voltage_cell_3) }, \ + { "voltage_cell_4", NULL, MAVLINK_TYPE_UINT16_T, 0, 6, offsetof(mavlink_battery_status_t, voltage_cell_4) }, \ + { "voltage_cell_5", NULL, MAVLINK_TYPE_UINT16_T, 0, 8, offsetof(mavlink_battery_status_t, voltage_cell_5) }, \ + { "voltage_cell_6", NULL, MAVLINK_TYPE_UINT16_T, 0, 10, offsetof(mavlink_battery_status_t, voltage_cell_6) }, \ + { "current_battery", NULL, MAVLINK_TYPE_INT16_T, 0, 12, offsetof(mavlink_battery_status_t, current_battery) }, \ + { "accu_id", NULL, MAVLINK_TYPE_UINT8_T, 0, 14, offsetof(mavlink_battery_status_t, accu_id) }, \ + { "battery_remaining", NULL, MAVLINK_TYPE_INT8_T, 0, 15, offsetof(mavlink_battery_status_t, battery_remaining) }, \ + } \ +} + + +/** + * @brief Pack a battery_status message + * @param system_id ID of this system + * @param component_id ID of this component (e.g. 200 for IMU) + * @param msg The MAVLink message to compress the data into + * + * @param accu_id Accupack ID + * @param voltage_cell_1 Battery voltage of cell 1, in millivolts (1 = 1 millivolt) + * @param voltage_cell_2 Battery voltage of cell 2, in millivolts (1 = 1 millivolt), -1: no cell + * @param voltage_cell_3 Battery voltage of cell 3, in millivolts (1 = 1 millivolt), -1: no cell + * @param voltage_cell_4 Battery voltage of cell 4, in millivolts (1 = 1 millivolt), -1: no cell + * @param voltage_cell_5 Battery voltage of cell 5, in millivolts (1 = 1 millivolt), -1: no cell + * @param voltage_cell_6 Battery voltage of cell 6, in millivolts (1 = 1 millivolt), -1: no cell + * @param current_battery Battery current, in 10*milliamperes (1 = 10 milliampere), -1: autopilot does not measure the current + * @param battery_remaining Remaining battery energy: (0%: 0, 100%: 100), -1: autopilot does not estimate the remaining battery + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_battery_status_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, + uint8_t accu_id, uint16_t voltage_cell_1, uint16_t voltage_cell_2, uint16_t voltage_cell_3, uint16_t voltage_cell_4, uint16_t voltage_cell_5, uint16_t voltage_cell_6, int16_t current_battery, int8_t battery_remaining) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[16]; + _mav_put_uint16_t(buf, 0, voltage_cell_1); + _mav_put_uint16_t(buf, 2, voltage_cell_2); + _mav_put_uint16_t(buf, 4, voltage_cell_3); + _mav_put_uint16_t(buf, 6, voltage_cell_4); + _mav_put_uint16_t(buf, 8, voltage_cell_5); + _mav_put_uint16_t(buf, 10, voltage_cell_6); + _mav_put_int16_t(buf, 12, current_battery); + _mav_put_uint8_t(buf, 14, accu_id); + _mav_put_int8_t(buf, 15, battery_remaining); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 16); +#else + mavlink_battery_status_t packet; + packet.voltage_cell_1 = voltage_cell_1; + packet.voltage_cell_2 = voltage_cell_2; + packet.voltage_cell_3 = voltage_cell_3; + packet.voltage_cell_4 = voltage_cell_4; + packet.voltage_cell_5 = voltage_cell_5; + packet.voltage_cell_6 = voltage_cell_6; + packet.current_battery = current_battery; + packet.accu_id = accu_id; + packet.battery_remaining = battery_remaining; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 16); +#endif + + msg->msgid = MAVLINK_MSG_ID_BATTERY_STATUS; + return mavlink_finalize_message(msg, system_id, component_id, 16, 42); +} + +/** + * @brief Pack a battery_status message on a channel + * @param system_id ID of this system + * @param component_id ID of this component (e.g. 200 for IMU) + * @param chan The MAVLink channel this message was sent over + * @param msg The MAVLink message to compress the data into + * @param accu_id Accupack ID + * @param voltage_cell_1 Battery voltage of cell 1, in millivolts (1 = 1 millivolt) + * @param voltage_cell_2 Battery voltage of cell 2, in millivolts (1 = 1 millivolt), -1: no cell + * @param voltage_cell_3 Battery voltage of cell 3, in millivolts (1 = 1 millivolt), -1: no cell + * @param voltage_cell_4 Battery voltage of cell 4, in millivolts (1 = 1 millivolt), -1: no cell + * @param voltage_cell_5 Battery voltage of cell 5, in millivolts (1 = 1 millivolt), -1: no cell + * @param voltage_cell_6 Battery voltage of cell 6, in millivolts (1 = 1 millivolt), -1: no cell + * @param current_battery Battery current, in 10*milliamperes (1 = 10 milliampere), -1: autopilot does not measure the current + * @param battery_remaining Remaining battery energy: (0%: 0, 100%: 100), -1: autopilot does not estimate the remaining battery + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_battery_status_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, + mavlink_message_t* msg, + uint8_t accu_id,uint16_t voltage_cell_1,uint16_t voltage_cell_2,uint16_t voltage_cell_3,uint16_t voltage_cell_4,uint16_t voltage_cell_5,uint16_t voltage_cell_6,int16_t current_battery,int8_t battery_remaining) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[16]; + _mav_put_uint16_t(buf, 0, voltage_cell_1); + _mav_put_uint16_t(buf, 2, voltage_cell_2); + _mav_put_uint16_t(buf, 4, voltage_cell_3); + _mav_put_uint16_t(buf, 6, voltage_cell_4); + _mav_put_uint16_t(buf, 8, voltage_cell_5); + _mav_put_uint16_t(buf, 10, voltage_cell_6); + _mav_put_int16_t(buf, 12, current_battery); + _mav_put_uint8_t(buf, 14, accu_id); + _mav_put_int8_t(buf, 15, battery_remaining); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 16); +#else + mavlink_battery_status_t packet; + packet.voltage_cell_1 = voltage_cell_1; + packet.voltage_cell_2 = voltage_cell_2; + packet.voltage_cell_3 = voltage_cell_3; + packet.voltage_cell_4 = voltage_cell_4; + packet.voltage_cell_5 = voltage_cell_5; + packet.voltage_cell_6 = voltage_cell_6; + packet.current_battery = current_battery; + packet.accu_id = accu_id; + packet.battery_remaining = battery_remaining; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 16); +#endif + + msg->msgid = MAVLINK_MSG_ID_BATTERY_STATUS; + return mavlink_finalize_message_chan(msg, system_id, component_id, chan, 16, 42); +} + +/** + * @brief Encode a battery_status struct into a message + * + * @param system_id ID of this system + * @param component_id ID of this component (e.g. 200 for IMU) + * @param msg The MAVLink message to compress the data into + * @param battery_status C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_battery_status_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_battery_status_t* battery_status) +{ + return mavlink_msg_battery_status_pack(system_id, component_id, msg, battery_status->accu_id, battery_status->voltage_cell_1, battery_status->voltage_cell_2, battery_status->voltage_cell_3, battery_status->voltage_cell_4, battery_status->voltage_cell_5, battery_status->voltage_cell_6, battery_status->current_battery, battery_status->battery_remaining); +} + +/** + * @brief Send a battery_status message + * @param chan MAVLink channel to send the message + * + * @param accu_id Accupack ID + * @param voltage_cell_1 Battery voltage of cell 1, in millivolts (1 = 1 millivolt) + * @param voltage_cell_2 Battery voltage of cell 2, in millivolts (1 = 1 millivolt), -1: no cell + * @param voltage_cell_3 Battery voltage of cell 3, in millivolts (1 = 1 millivolt), -1: no cell + * @param voltage_cell_4 Battery voltage of cell 4, in millivolts (1 = 1 millivolt), -1: no cell + * @param voltage_cell_5 Battery voltage of cell 5, in millivolts (1 = 1 millivolt), -1: no cell + * @param voltage_cell_6 Battery voltage of cell 6, in millivolts (1 = 1 millivolt), -1: no cell + * @param current_battery Battery current, in 10*milliamperes (1 = 10 milliampere), -1: autopilot does not measure the current + * @param battery_remaining Remaining battery energy: (0%: 0, 100%: 100), -1: autopilot does not estimate the remaining battery + */ +#ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS + +static inline void mavlink_msg_battery_status_send(mavlink_channel_t chan, uint8_t accu_id, uint16_t voltage_cell_1, uint16_t voltage_cell_2, uint16_t voltage_cell_3, uint16_t voltage_cell_4, uint16_t voltage_cell_5, uint16_t voltage_cell_6, int16_t current_battery, int8_t battery_remaining) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[16]; + _mav_put_uint16_t(buf, 0, voltage_cell_1); + _mav_put_uint16_t(buf, 2, voltage_cell_2); + _mav_put_uint16_t(buf, 4, voltage_cell_3); + _mav_put_uint16_t(buf, 6, voltage_cell_4); + _mav_put_uint16_t(buf, 8, voltage_cell_5); + _mav_put_uint16_t(buf, 10, voltage_cell_6); + _mav_put_int16_t(buf, 12, current_battery); + _mav_put_uint8_t(buf, 14, accu_id); + _mav_put_int8_t(buf, 15, battery_remaining); + + _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_BATTERY_STATUS, buf, 16, 42); +#else + mavlink_battery_status_t packet; + packet.voltage_cell_1 = voltage_cell_1; + packet.voltage_cell_2 = voltage_cell_2; + packet.voltage_cell_3 = voltage_cell_3; + packet.voltage_cell_4 = voltage_cell_4; + packet.voltage_cell_5 = voltage_cell_5; + packet.voltage_cell_6 = voltage_cell_6; + packet.current_battery = current_battery; + packet.accu_id = accu_id; + packet.battery_remaining = battery_remaining; + + _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_BATTERY_STATUS, (const char *)&packet, 16, 42); +#endif +} + +#endif + +// MESSAGE BATTERY_STATUS UNPACKING + + +/** + * @brief Get field accu_id from battery_status message + * + * @return Accupack ID + */ +static inline uint8_t mavlink_msg_battery_status_get_accu_id(const mavlink_message_t* msg) +{ + return _MAV_RETURN_uint8_t(msg, 14); +} + +/** + * @brief Get field voltage_cell_1 from battery_status message + * + * @return Battery voltage of cell 1, in millivolts (1 = 1 millivolt) + */ +static inline uint16_t mavlink_msg_battery_status_get_voltage_cell_1(const mavlink_message_t* msg) +{ + return _MAV_RETURN_uint16_t(msg, 0); +} + +/** + * @brief Get field voltage_cell_2 from battery_status message + * + * @return Battery voltage of cell 2, in millivolts (1 = 1 millivolt), -1: no cell + */ +static inline uint16_t mavlink_msg_battery_status_get_voltage_cell_2(const mavlink_message_t* msg) +{ + return _MAV_RETURN_uint16_t(msg, 2); +} + +/** + * @brief Get field voltage_cell_3 from battery_status message + * + * @return Battery voltage of cell 3, in millivolts (1 = 1 millivolt), -1: no cell + */ +static inline uint16_t mavlink_msg_battery_status_get_voltage_cell_3(const mavlink_message_t* msg) +{ + return _MAV_RETURN_uint16_t(msg, 4); +} + +/** + * @brief Get field voltage_cell_4 from battery_status message + * + * @return Battery voltage of cell 4, in millivolts (1 = 1 millivolt), -1: no cell + */ +static inline uint16_t mavlink_msg_battery_status_get_voltage_cell_4(const mavlink_message_t* msg) +{ + return _MAV_RETURN_uint16_t(msg, 6); +} + +/** + * @brief Get field voltage_cell_5 from battery_status message + * + * @return Battery voltage of cell 5, in millivolts (1 = 1 millivolt), -1: no cell + */ +static inline uint16_t mavlink_msg_battery_status_get_voltage_cell_5(const mavlink_message_t* msg) +{ + return _MAV_RETURN_uint16_t(msg, 8); +} + +/** + * @brief Get field voltage_cell_6 from battery_status message + * + * @return Battery voltage of cell 6, in millivolts (1 = 1 millivolt), -1: no cell + */ +static inline uint16_t mavlink_msg_battery_status_get_voltage_cell_6(const mavlink_message_t* msg) +{ + return _MAV_RETURN_uint16_t(msg, 10); +} + +/** + * @brief Get field current_battery from battery_status message + * + * @return Battery current, in 10*milliamperes (1 = 10 milliampere), -1: autopilot does not measure the current + */ +static inline int16_t mavlink_msg_battery_status_get_current_battery(const mavlink_message_t* msg) +{ + return _MAV_RETURN_int16_t(msg, 12); +} + +/** + * @brief Get field battery_remaining from battery_status message + * + * @return Remaining battery energy: (0%: 0, 100%: 100), -1: autopilot does not estimate the remaining battery + */ +static inline int8_t mavlink_msg_battery_status_get_battery_remaining(const mavlink_message_t* msg) +{ + return _MAV_RETURN_int8_t(msg, 15); +} + +/** + * @brief Decode a battery_status message into a struct + * + * @param msg The message to decode + * @param battery_status C-struct to decode the message contents into + */ +static inline void mavlink_msg_battery_status_decode(const mavlink_message_t* msg, mavlink_battery_status_t* battery_status) +{ +#if MAVLINK_NEED_BYTE_SWAP + battery_status->voltage_cell_1 = mavlink_msg_battery_status_get_voltage_cell_1(msg); + battery_status->voltage_cell_2 = mavlink_msg_battery_status_get_voltage_cell_2(msg); + battery_status->voltage_cell_3 = mavlink_msg_battery_status_get_voltage_cell_3(msg); + battery_status->voltage_cell_4 = mavlink_msg_battery_status_get_voltage_cell_4(msg); + battery_status->voltage_cell_5 = mavlink_msg_battery_status_get_voltage_cell_5(msg); + battery_status->voltage_cell_6 = mavlink_msg_battery_status_get_voltage_cell_6(msg); + battery_status->current_battery = mavlink_msg_battery_status_get_current_battery(msg); + battery_status->accu_id = mavlink_msg_battery_status_get_accu_id(msg); + battery_status->battery_remaining = mavlink_msg_battery_status_get_battery_remaining(msg); +#else + memcpy(battery_status, _MAV_PAYLOAD(msg), 16); +#endif +} diff --git a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_change_operator_control.h b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_change_operator_control.h index d18194e2d..a55851008 100644 --- a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_change_operator_control.h +++ b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_change_operator_control.h @@ -47,14 +47,14 @@ static inline uint16_t mavlink_msg_change_operator_control_pack(uint8_t system_i _mav_put_uint8_t(buf, 1, control_request); _mav_put_uint8_t(buf, 2, version); _mav_put_char_array(buf, 3, passkey, 25); - memcpy(_MAV_PAYLOAD(msg), buf, 28); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 28); #else mavlink_change_operator_control_t packet; packet.target_system = target_system; packet.control_request = control_request; packet.version = version; mav_array_memcpy(packet.passkey, passkey, sizeof(char)*25); - memcpy(_MAV_PAYLOAD(msg), &packet, 28); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 28); #endif msg->msgid = MAVLINK_MSG_ID_CHANGE_OPERATOR_CONTROL; @@ -83,14 +83,14 @@ static inline uint16_t mavlink_msg_change_operator_control_pack_chan(uint8_t sys _mav_put_uint8_t(buf, 1, control_request); _mav_put_uint8_t(buf, 2, version); _mav_put_char_array(buf, 3, passkey, 25); - memcpy(_MAV_PAYLOAD(msg), buf, 28); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 28); #else mavlink_change_operator_control_t packet; packet.target_system = target_system; packet.control_request = control_request; packet.version = version; mav_array_memcpy(packet.passkey, passkey, sizeof(char)*25); - memcpy(_MAV_PAYLOAD(msg), &packet, 28); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 28); #endif msg->msgid = MAVLINK_MSG_ID_CHANGE_OPERATOR_CONTROL; diff --git a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_change_operator_control_ack.h b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_change_operator_control_ack.h index 25e6a6d83..1d89a0f78 100644 --- a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_change_operator_control_ack.h +++ b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_change_operator_control_ack.h @@ -44,14 +44,14 @@ static inline uint16_t mavlink_msg_change_operator_control_ack_pack(uint8_t syst _mav_put_uint8_t(buf, 1, control_request); _mav_put_uint8_t(buf, 2, ack); - memcpy(_MAV_PAYLOAD(msg), buf, 3); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 3); #else mavlink_change_operator_control_ack_t packet; packet.gcs_system_id = gcs_system_id; packet.control_request = control_request; packet.ack = ack; - memcpy(_MAV_PAYLOAD(msg), &packet, 3); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 3); #endif msg->msgid = MAVLINK_MSG_ID_CHANGE_OPERATOR_CONTROL_ACK; @@ -79,14 +79,14 @@ static inline uint16_t mavlink_msg_change_operator_control_ack_pack_chan(uint8_t _mav_put_uint8_t(buf, 1, control_request); _mav_put_uint8_t(buf, 2, ack); - memcpy(_MAV_PAYLOAD(msg), buf, 3); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 3); #else mavlink_change_operator_control_ack_t packet; packet.gcs_system_id = gcs_system_id; packet.control_request = control_request; packet.ack = ack; - memcpy(_MAV_PAYLOAD(msg), &packet, 3); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 3); #endif msg->msgid = MAVLINK_MSG_ID_CHANGE_OPERATOR_CONTROL_ACK; diff --git a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_command_ack.h b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_command_ack.h index 2109e3207..df6e9b9e3 100644 --- a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_command_ack.h +++ b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_command_ack.h @@ -40,13 +40,13 @@ static inline uint16_t mavlink_msg_command_ack_pack(uint8_t system_id, uint8_t c _mav_put_uint16_t(buf, 0, command); _mav_put_uint8_t(buf, 2, result); - memcpy(_MAV_PAYLOAD(msg), buf, 3); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 3); #else mavlink_command_ack_t packet; packet.command = command; packet.result = result; - memcpy(_MAV_PAYLOAD(msg), &packet, 3); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 3); #endif msg->msgid = MAVLINK_MSG_ID_COMMAND_ACK; @@ -72,13 +72,13 @@ static inline uint16_t mavlink_msg_command_ack_pack_chan(uint8_t system_id, uint _mav_put_uint16_t(buf, 0, command); _mav_put_uint8_t(buf, 2, result); - memcpy(_MAV_PAYLOAD(msg), buf, 3); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 3); #else mavlink_command_ack_t packet; packet.command = command; packet.result = result; - memcpy(_MAV_PAYLOAD(msg), &packet, 3); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 3); #endif msg->msgid = MAVLINK_MSG_ID_COMMAND_ACK; diff --git a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_command_long.h b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_command_long.h index 7a8bac533..54ca77eaa 100644 --- a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_command_long.h +++ b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_command_long.h @@ -76,7 +76,7 @@ static inline uint16_t mavlink_msg_command_long_pack(uint8_t system_id, uint8_t _mav_put_uint8_t(buf, 31, target_component); _mav_put_uint8_t(buf, 32, confirmation); - memcpy(_MAV_PAYLOAD(msg), buf, 33); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 33); #else mavlink_command_long_t packet; packet.param1 = param1; @@ -91,7 +91,7 @@ static inline uint16_t mavlink_msg_command_long_pack(uint8_t system_id, uint8_t packet.target_component = target_component; packet.confirmation = confirmation; - memcpy(_MAV_PAYLOAD(msg), &packet, 33); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 33); #endif msg->msgid = MAVLINK_MSG_ID_COMMAND_LONG; @@ -135,7 +135,7 @@ static inline uint16_t mavlink_msg_command_long_pack_chan(uint8_t system_id, uin _mav_put_uint8_t(buf, 31, target_component); _mav_put_uint8_t(buf, 32, confirmation); - memcpy(_MAV_PAYLOAD(msg), buf, 33); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 33); #else mavlink_command_long_t packet; packet.param1 = param1; @@ -150,7 +150,7 @@ static inline uint16_t mavlink_msg_command_long_pack_chan(uint8_t system_id, uin packet.target_component = target_component; packet.confirmation = confirmation; - memcpy(_MAV_PAYLOAD(msg), &packet, 33); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 33); #endif msg->msgid = MAVLINK_MSG_ID_COMMAND_LONG; diff --git a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_data_stream.h b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_data_stream.h index 1c8df4b41..e5ec29045 100644 --- a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_data_stream.h +++ b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_data_stream.h @@ -44,14 +44,14 @@ static inline uint16_t mavlink_msg_data_stream_pack(uint8_t system_id, uint8_t c _mav_put_uint8_t(buf, 2, stream_id); _mav_put_uint8_t(buf, 3, on_off); - memcpy(_MAV_PAYLOAD(msg), buf, 4); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 4); #else mavlink_data_stream_t packet; packet.message_rate = message_rate; packet.stream_id = stream_id; packet.on_off = on_off; - memcpy(_MAV_PAYLOAD(msg), &packet, 4); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 4); #endif msg->msgid = MAVLINK_MSG_ID_DATA_STREAM; @@ -79,14 +79,14 @@ static inline uint16_t mavlink_msg_data_stream_pack_chan(uint8_t system_id, uint _mav_put_uint8_t(buf, 2, stream_id); _mav_put_uint8_t(buf, 3, on_off); - memcpy(_MAV_PAYLOAD(msg), buf, 4); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 4); #else mavlink_data_stream_t packet; packet.message_rate = message_rate; packet.stream_id = stream_id; packet.on_off = on_off; - memcpy(_MAV_PAYLOAD(msg), &packet, 4); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 4); #endif msg->msgid = MAVLINK_MSG_ID_DATA_STREAM; diff --git a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_debug.h b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_debug.h index 1687a16cd..5ff88e6a8 100644 --- a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_debug.h +++ b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_debug.h @@ -44,14 +44,14 @@ static inline uint16_t mavlink_msg_debug_pack(uint8_t system_id, uint8_t compone _mav_put_float(buf, 4, value); _mav_put_uint8_t(buf, 8, ind); - memcpy(_MAV_PAYLOAD(msg), buf, 9); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 9); #else mavlink_debug_t packet; packet.time_boot_ms = time_boot_ms; packet.value = value; packet.ind = ind; - memcpy(_MAV_PAYLOAD(msg), &packet, 9); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 9); #endif msg->msgid = MAVLINK_MSG_ID_DEBUG; @@ -79,14 +79,14 @@ static inline uint16_t mavlink_msg_debug_pack_chan(uint8_t system_id, uint8_t co _mav_put_float(buf, 4, value); _mav_put_uint8_t(buf, 8, ind); - memcpy(_MAV_PAYLOAD(msg), buf, 9); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 9); #else mavlink_debug_t packet; packet.time_boot_ms = time_boot_ms; packet.value = value; packet.ind = ind; - memcpy(_MAV_PAYLOAD(msg), &packet, 9); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 9); #endif msg->msgid = MAVLINK_MSG_ID_DEBUG; diff --git a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_debug_vect.h b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_debug_vect.h index 8f3b90972..0b443a061 100644 --- a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_debug_vect.h +++ b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_debug_vect.h @@ -51,7 +51,7 @@ static inline uint16_t mavlink_msg_debug_vect_pack(uint8_t system_id, uint8_t co _mav_put_float(buf, 12, y); _mav_put_float(buf, 16, z); _mav_put_char_array(buf, 20, name, 10); - memcpy(_MAV_PAYLOAD(msg), buf, 30); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 30); #else mavlink_debug_vect_t packet; packet.time_usec = time_usec; @@ -59,7 +59,7 @@ static inline uint16_t mavlink_msg_debug_vect_pack(uint8_t system_id, uint8_t co packet.y = y; packet.z = z; mav_array_memcpy(packet.name, name, sizeof(char)*10); - memcpy(_MAV_PAYLOAD(msg), &packet, 30); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 30); #endif msg->msgid = MAVLINK_MSG_ID_DEBUG_VECT; @@ -90,7 +90,7 @@ static inline uint16_t mavlink_msg_debug_vect_pack_chan(uint8_t system_id, uint8 _mav_put_float(buf, 12, y); _mav_put_float(buf, 16, z); _mav_put_char_array(buf, 20, name, 10); - memcpy(_MAV_PAYLOAD(msg), buf, 30); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 30); #else mavlink_debug_vect_t packet; packet.time_usec = time_usec; @@ -98,7 +98,7 @@ static inline uint16_t mavlink_msg_debug_vect_pack_chan(uint8_t system_id, uint8 packet.y = y; packet.z = z; mav_array_memcpy(packet.name, name, sizeof(char)*10); - memcpy(_MAV_PAYLOAD(msg), &packet, 30); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 30); #endif msg->msgid = MAVLINK_MSG_ID_DEBUG_VECT; diff --git a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_file_transfer_dir_list.h b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_file_transfer_dir_list.h new file mode 100644 index 000000000..27f5a91db --- /dev/null +++ b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_file_transfer_dir_list.h @@ -0,0 +1,182 @@ +// MESSAGE FILE_TRANSFER_DIR_LIST PACKING + +#define MAVLINK_MSG_ID_FILE_TRANSFER_DIR_LIST 111 + +typedef struct __mavlink_file_transfer_dir_list_t +{ + uint64_t transfer_uid; ///< Unique transfer ID + char dir_path[240]; ///< Directory path to list + uint8_t flags; ///< RESERVED +} mavlink_file_transfer_dir_list_t; + +#define MAVLINK_MSG_ID_FILE_TRANSFER_DIR_LIST_LEN 249 +#define MAVLINK_MSG_ID_111_LEN 249 + +#define MAVLINK_MSG_FILE_TRANSFER_DIR_LIST_FIELD_DIR_PATH_LEN 240 + +#define MAVLINK_MESSAGE_INFO_FILE_TRANSFER_DIR_LIST { \ + "FILE_TRANSFER_DIR_LIST", \ + 3, \ + { { "transfer_uid", NULL, MAVLINK_TYPE_UINT64_T, 0, 0, offsetof(mavlink_file_transfer_dir_list_t, transfer_uid) }, \ + { "dir_path", NULL, MAVLINK_TYPE_CHAR, 240, 8, offsetof(mavlink_file_transfer_dir_list_t, dir_path) }, \ + { "flags", NULL, MAVLINK_TYPE_UINT8_T, 0, 248, offsetof(mavlink_file_transfer_dir_list_t, flags) }, \ + } \ +} + + +/** + * @brief Pack a file_transfer_dir_list message + * @param system_id ID of this system + * @param component_id ID of this component (e.g. 200 for IMU) + * @param msg The MAVLink message to compress the data into + * + * @param transfer_uid Unique transfer ID + * @param dir_path Directory path to list + * @param flags RESERVED + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_file_transfer_dir_list_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, + uint64_t transfer_uid, const char *dir_path, uint8_t flags) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[249]; + _mav_put_uint64_t(buf, 0, transfer_uid); + _mav_put_uint8_t(buf, 248, flags); + _mav_put_char_array(buf, 8, dir_path, 240); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 249); +#else + mavlink_file_transfer_dir_list_t packet; + packet.transfer_uid = transfer_uid; + packet.flags = flags; + mav_array_memcpy(packet.dir_path, dir_path, sizeof(char)*240); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 249); +#endif + + msg->msgid = MAVLINK_MSG_ID_FILE_TRANSFER_DIR_LIST; + return mavlink_finalize_message(msg, system_id, component_id, 249, 93); +} + +/** + * @brief Pack a file_transfer_dir_list message on a channel + * @param system_id ID of this system + * @param component_id ID of this component (e.g. 200 for IMU) + * @param chan The MAVLink channel this message was sent over + * @param msg The MAVLink message to compress the data into + * @param transfer_uid Unique transfer ID + * @param dir_path Directory path to list + * @param flags RESERVED + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_file_transfer_dir_list_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, + mavlink_message_t* msg, + uint64_t transfer_uid,const char *dir_path,uint8_t flags) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[249]; + _mav_put_uint64_t(buf, 0, transfer_uid); + _mav_put_uint8_t(buf, 248, flags); + _mav_put_char_array(buf, 8, dir_path, 240); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 249); +#else + mavlink_file_transfer_dir_list_t packet; + packet.transfer_uid = transfer_uid; + packet.flags = flags; + mav_array_memcpy(packet.dir_path, dir_path, sizeof(char)*240); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 249); +#endif + + msg->msgid = MAVLINK_MSG_ID_FILE_TRANSFER_DIR_LIST; + return mavlink_finalize_message_chan(msg, system_id, component_id, chan, 249, 93); +} + +/** + * @brief Encode a file_transfer_dir_list struct into a message + * + * @param system_id ID of this system + * @param component_id ID of this component (e.g. 200 for IMU) + * @param msg The MAVLink message to compress the data into + * @param file_transfer_dir_list C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_file_transfer_dir_list_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_file_transfer_dir_list_t* file_transfer_dir_list) +{ + return mavlink_msg_file_transfer_dir_list_pack(system_id, component_id, msg, file_transfer_dir_list->transfer_uid, file_transfer_dir_list->dir_path, file_transfer_dir_list->flags); +} + +/** + * @brief Send a file_transfer_dir_list message + * @param chan MAVLink channel to send the message + * + * @param transfer_uid Unique transfer ID + * @param dir_path Directory path to list + * @param flags RESERVED + */ +#ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS + +static inline void mavlink_msg_file_transfer_dir_list_send(mavlink_channel_t chan, uint64_t transfer_uid, const char *dir_path, uint8_t flags) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[249]; + _mav_put_uint64_t(buf, 0, transfer_uid); + _mav_put_uint8_t(buf, 248, flags); + _mav_put_char_array(buf, 8, dir_path, 240); + _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_FILE_TRANSFER_DIR_LIST, buf, 249, 93); +#else + mavlink_file_transfer_dir_list_t packet; + packet.transfer_uid = transfer_uid; + packet.flags = flags; + mav_array_memcpy(packet.dir_path, dir_path, sizeof(char)*240); + _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_FILE_TRANSFER_DIR_LIST, (const char *)&packet, 249, 93); +#endif +} + +#endif + +// MESSAGE FILE_TRANSFER_DIR_LIST UNPACKING + + +/** + * @brief Get field transfer_uid from file_transfer_dir_list message + * + * @return Unique transfer ID + */ +static inline uint64_t mavlink_msg_file_transfer_dir_list_get_transfer_uid(const mavlink_message_t* msg) +{ + return _MAV_RETURN_uint64_t(msg, 0); +} + +/** + * @brief Get field dir_path from file_transfer_dir_list message + * + * @return Directory path to list + */ +static inline uint16_t mavlink_msg_file_transfer_dir_list_get_dir_path(const mavlink_message_t* msg, char *dir_path) +{ + return _MAV_RETURN_char_array(msg, dir_path, 240, 8); +} + +/** + * @brief Get field flags from file_transfer_dir_list message + * + * @return RESERVED + */ +static inline uint8_t mavlink_msg_file_transfer_dir_list_get_flags(const mavlink_message_t* msg) +{ + return _MAV_RETURN_uint8_t(msg, 248); +} + +/** + * @brief Decode a file_transfer_dir_list message into a struct + * + * @param msg The message to decode + * @param file_transfer_dir_list C-struct to decode the message contents into + */ +static inline void mavlink_msg_file_transfer_dir_list_decode(const mavlink_message_t* msg, mavlink_file_transfer_dir_list_t* file_transfer_dir_list) +{ +#if MAVLINK_NEED_BYTE_SWAP + file_transfer_dir_list->transfer_uid = mavlink_msg_file_transfer_dir_list_get_transfer_uid(msg); + mavlink_msg_file_transfer_dir_list_get_dir_path(msg, file_transfer_dir_list->dir_path); + file_transfer_dir_list->flags = mavlink_msg_file_transfer_dir_list_get_flags(msg); +#else + memcpy(file_transfer_dir_list, _MAV_PAYLOAD(msg), 249); +#endif +} diff --git a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_file_transfer_res.h b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_file_transfer_res.h new file mode 100644 index 000000000..f7035ec9e --- /dev/null +++ b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_file_transfer_res.h @@ -0,0 +1,166 @@ +// MESSAGE FILE_TRANSFER_RES PACKING + +#define MAVLINK_MSG_ID_FILE_TRANSFER_RES 112 + +typedef struct __mavlink_file_transfer_res_t +{ + uint64_t transfer_uid; ///< Unique transfer ID + uint8_t result; ///< 0: OK, 1: not permitted, 2: bad path / file name, 3: no space left on device +} mavlink_file_transfer_res_t; + +#define MAVLINK_MSG_ID_FILE_TRANSFER_RES_LEN 9 +#define MAVLINK_MSG_ID_112_LEN 9 + + + +#define MAVLINK_MESSAGE_INFO_FILE_TRANSFER_RES { \ + "FILE_TRANSFER_RES", \ + 2, \ + { { "transfer_uid", NULL, MAVLINK_TYPE_UINT64_T, 0, 0, offsetof(mavlink_file_transfer_res_t, transfer_uid) }, \ + { "result", NULL, MAVLINK_TYPE_UINT8_T, 0, 8, offsetof(mavlink_file_transfer_res_t, result) }, \ + } \ +} + + +/** + * @brief Pack a file_transfer_res message + * @param system_id ID of this system + * @param component_id ID of this component (e.g. 200 for IMU) + * @param msg The MAVLink message to compress the data into + * + * @param transfer_uid Unique transfer ID + * @param result 0: OK, 1: not permitted, 2: bad path / file name, 3: no space left on device + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_file_transfer_res_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, + uint64_t transfer_uid, uint8_t result) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[9]; + _mav_put_uint64_t(buf, 0, transfer_uid); + _mav_put_uint8_t(buf, 8, result); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 9); +#else + mavlink_file_transfer_res_t packet; + packet.transfer_uid = transfer_uid; + packet.result = result; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 9); +#endif + + msg->msgid = MAVLINK_MSG_ID_FILE_TRANSFER_RES; + return mavlink_finalize_message(msg, system_id, component_id, 9, 124); +} + +/** + * @brief Pack a file_transfer_res message on a channel + * @param system_id ID of this system + * @param component_id ID of this component (e.g. 200 for IMU) + * @param chan The MAVLink channel this message was sent over + * @param msg The MAVLink message to compress the data into + * @param transfer_uid Unique transfer ID + * @param result 0: OK, 1: not permitted, 2: bad path / file name, 3: no space left on device + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_file_transfer_res_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, + mavlink_message_t* msg, + uint64_t transfer_uid,uint8_t result) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[9]; + _mav_put_uint64_t(buf, 0, transfer_uid); + _mav_put_uint8_t(buf, 8, result); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 9); +#else + mavlink_file_transfer_res_t packet; + packet.transfer_uid = transfer_uid; + packet.result = result; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 9); +#endif + + msg->msgid = MAVLINK_MSG_ID_FILE_TRANSFER_RES; + return mavlink_finalize_message_chan(msg, system_id, component_id, chan, 9, 124); +} + +/** + * @brief Encode a file_transfer_res struct into a message + * + * @param system_id ID of this system + * @param component_id ID of this component (e.g. 200 for IMU) + * @param msg The MAVLink message to compress the data into + * @param file_transfer_res C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_file_transfer_res_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_file_transfer_res_t* file_transfer_res) +{ + return mavlink_msg_file_transfer_res_pack(system_id, component_id, msg, file_transfer_res->transfer_uid, file_transfer_res->result); +} + +/** + * @brief Send a file_transfer_res message + * @param chan MAVLink channel to send the message + * + * @param transfer_uid Unique transfer ID + * @param result 0: OK, 1: not permitted, 2: bad path / file name, 3: no space left on device + */ +#ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS + +static inline void mavlink_msg_file_transfer_res_send(mavlink_channel_t chan, uint64_t transfer_uid, uint8_t result) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[9]; + _mav_put_uint64_t(buf, 0, transfer_uid); + _mav_put_uint8_t(buf, 8, result); + + _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_FILE_TRANSFER_RES, buf, 9, 124); +#else + mavlink_file_transfer_res_t packet; + packet.transfer_uid = transfer_uid; + packet.result = result; + + _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_FILE_TRANSFER_RES, (const char *)&packet, 9, 124); +#endif +} + +#endif + +// MESSAGE FILE_TRANSFER_RES UNPACKING + + +/** + * @brief Get field transfer_uid from file_transfer_res message + * + * @return Unique transfer ID + */ +static inline uint64_t mavlink_msg_file_transfer_res_get_transfer_uid(const mavlink_message_t* msg) +{ + return _MAV_RETURN_uint64_t(msg, 0); +} + +/** + * @brief Get field result from file_transfer_res message + * + * @return 0: OK, 1: not permitted, 2: bad path / file name, 3: no space left on device + */ +static inline uint8_t mavlink_msg_file_transfer_res_get_result(const mavlink_message_t* msg) +{ + return _MAV_RETURN_uint8_t(msg, 8); +} + +/** + * @brief Decode a file_transfer_res message into a struct + * + * @param msg The message to decode + * @param file_transfer_res C-struct to decode the message contents into + */ +static inline void mavlink_msg_file_transfer_res_decode(const mavlink_message_t* msg, mavlink_file_transfer_res_t* file_transfer_res) +{ +#if MAVLINK_NEED_BYTE_SWAP + file_transfer_res->transfer_uid = mavlink_msg_file_transfer_res_get_transfer_uid(msg); + file_transfer_res->result = mavlink_msg_file_transfer_res_get_result(msg); +#else + memcpy(file_transfer_res, _MAV_PAYLOAD(msg), 9); +#endif +} diff --git a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_file_transfer_start.h b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_file_transfer_start.h new file mode 100644 index 000000000..5eaa9b220 --- /dev/null +++ b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_file_transfer_start.h @@ -0,0 +1,226 @@ +// MESSAGE FILE_TRANSFER_START PACKING + +#define MAVLINK_MSG_ID_FILE_TRANSFER_START 110 + +typedef struct __mavlink_file_transfer_start_t +{ + uint64_t transfer_uid; ///< Unique transfer ID + uint32_t file_size; ///< File size in bytes + char dest_path[240]; ///< Destination path + uint8_t direction; ///< Transfer direction: 0: from requester, 1: to requester + uint8_t flags; ///< RESERVED +} mavlink_file_transfer_start_t; + +#define MAVLINK_MSG_ID_FILE_TRANSFER_START_LEN 254 +#define MAVLINK_MSG_ID_110_LEN 254 + +#define MAVLINK_MSG_FILE_TRANSFER_START_FIELD_DEST_PATH_LEN 240 + +#define MAVLINK_MESSAGE_INFO_FILE_TRANSFER_START { \ + "FILE_TRANSFER_START", \ + 5, \ + { { "transfer_uid", NULL, MAVLINK_TYPE_UINT64_T, 0, 0, offsetof(mavlink_file_transfer_start_t, transfer_uid) }, \ + { "file_size", NULL, MAVLINK_TYPE_UINT32_T, 0, 8, offsetof(mavlink_file_transfer_start_t, file_size) }, \ + { "dest_path", NULL, MAVLINK_TYPE_CHAR, 240, 12, offsetof(mavlink_file_transfer_start_t, dest_path) }, \ + { "direction", NULL, MAVLINK_TYPE_UINT8_T, 0, 252, offsetof(mavlink_file_transfer_start_t, direction) }, \ + { "flags", NULL, MAVLINK_TYPE_UINT8_T, 0, 253, offsetof(mavlink_file_transfer_start_t, flags) }, \ + } \ +} + + +/** + * @brief Pack a file_transfer_start message + * @param system_id ID of this system + * @param component_id ID of this component (e.g. 200 for IMU) + * @param msg The MAVLink message to compress the data into + * + * @param transfer_uid Unique transfer ID + * @param dest_path Destination path + * @param direction Transfer direction: 0: from requester, 1: to requester + * @param file_size File size in bytes + * @param flags RESERVED + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_file_transfer_start_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, + uint64_t transfer_uid, const char *dest_path, uint8_t direction, uint32_t file_size, uint8_t flags) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[254]; + _mav_put_uint64_t(buf, 0, transfer_uid); + _mav_put_uint32_t(buf, 8, file_size); + _mav_put_uint8_t(buf, 252, direction); + _mav_put_uint8_t(buf, 253, flags); + _mav_put_char_array(buf, 12, dest_path, 240); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 254); +#else + mavlink_file_transfer_start_t packet; + packet.transfer_uid = transfer_uid; + packet.file_size = file_size; + packet.direction = direction; + packet.flags = flags; + mav_array_memcpy(packet.dest_path, dest_path, sizeof(char)*240); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 254); +#endif + + msg->msgid = MAVLINK_MSG_ID_FILE_TRANSFER_START; + return mavlink_finalize_message(msg, system_id, component_id, 254, 235); +} + +/** + * @brief Pack a file_transfer_start message on a channel + * @param system_id ID of this system + * @param component_id ID of this component (e.g. 200 for IMU) + * @param chan The MAVLink channel this message was sent over + * @param msg The MAVLink message to compress the data into + * @param transfer_uid Unique transfer ID + * @param dest_path Destination path + * @param direction Transfer direction: 0: from requester, 1: to requester + * @param file_size File size in bytes + * @param flags RESERVED + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_file_transfer_start_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, + mavlink_message_t* msg, + uint64_t transfer_uid,const char *dest_path,uint8_t direction,uint32_t file_size,uint8_t flags) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[254]; + _mav_put_uint64_t(buf, 0, transfer_uid); + _mav_put_uint32_t(buf, 8, file_size); + _mav_put_uint8_t(buf, 252, direction); + _mav_put_uint8_t(buf, 253, flags); + _mav_put_char_array(buf, 12, dest_path, 240); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 254); +#else + mavlink_file_transfer_start_t packet; + packet.transfer_uid = transfer_uid; + packet.file_size = file_size; + packet.direction = direction; + packet.flags = flags; + mav_array_memcpy(packet.dest_path, dest_path, sizeof(char)*240); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 254); +#endif + + msg->msgid = MAVLINK_MSG_ID_FILE_TRANSFER_START; + return mavlink_finalize_message_chan(msg, system_id, component_id, chan, 254, 235); +} + +/** + * @brief Encode a file_transfer_start struct into a message + * + * @param system_id ID of this system + * @param component_id ID of this component (e.g. 200 for IMU) + * @param msg The MAVLink message to compress the data into + * @param file_transfer_start C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_file_transfer_start_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_file_transfer_start_t* file_transfer_start) +{ + return mavlink_msg_file_transfer_start_pack(system_id, component_id, msg, file_transfer_start->transfer_uid, file_transfer_start->dest_path, file_transfer_start->direction, file_transfer_start->file_size, file_transfer_start->flags); +} + +/** + * @brief Send a file_transfer_start message + * @param chan MAVLink channel to send the message + * + * @param transfer_uid Unique transfer ID + * @param dest_path Destination path + * @param direction Transfer direction: 0: from requester, 1: to requester + * @param file_size File size in bytes + * @param flags RESERVED + */ +#ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS + +static inline void mavlink_msg_file_transfer_start_send(mavlink_channel_t chan, uint64_t transfer_uid, const char *dest_path, uint8_t direction, uint32_t file_size, uint8_t flags) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[254]; + _mav_put_uint64_t(buf, 0, transfer_uid); + _mav_put_uint32_t(buf, 8, file_size); + _mav_put_uint8_t(buf, 252, direction); + _mav_put_uint8_t(buf, 253, flags); + _mav_put_char_array(buf, 12, dest_path, 240); + _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_FILE_TRANSFER_START, buf, 254, 235); +#else + mavlink_file_transfer_start_t packet; + packet.transfer_uid = transfer_uid; + packet.file_size = file_size; + packet.direction = direction; + packet.flags = flags; + mav_array_memcpy(packet.dest_path, dest_path, sizeof(char)*240); + _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_FILE_TRANSFER_START, (const char *)&packet, 254, 235); +#endif +} + +#endif + +// MESSAGE FILE_TRANSFER_START UNPACKING + + +/** + * @brief Get field transfer_uid from file_transfer_start message + * + * @return Unique transfer ID + */ +static inline uint64_t mavlink_msg_file_transfer_start_get_transfer_uid(const mavlink_message_t* msg) +{ + return _MAV_RETURN_uint64_t(msg, 0); +} + +/** + * @brief Get field dest_path from file_transfer_start message + * + * @return Destination path + */ +static inline uint16_t mavlink_msg_file_transfer_start_get_dest_path(const mavlink_message_t* msg, char *dest_path) +{ + return _MAV_RETURN_char_array(msg, dest_path, 240, 12); +} + +/** + * @brief Get field direction from file_transfer_start message + * + * @return Transfer direction: 0: from requester, 1: to requester + */ +static inline uint8_t mavlink_msg_file_transfer_start_get_direction(const mavlink_message_t* msg) +{ + return _MAV_RETURN_uint8_t(msg, 252); +} + +/** + * @brief Get field file_size from file_transfer_start message + * + * @return File size in bytes + */ +static inline uint32_t mavlink_msg_file_transfer_start_get_file_size(const mavlink_message_t* msg) +{ + return _MAV_RETURN_uint32_t(msg, 8); +} + +/** + * @brief Get field flags from file_transfer_start message + * + * @return RESERVED + */ +static inline uint8_t mavlink_msg_file_transfer_start_get_flags(const mavlink_message_t* msg) +{ + return _MAV_RETURN_uint8_t(msg, 253); +} + +/** + * @brief Decode a file_transfer_start message into a struct + * + * @param msg The message to decode + * @param file_transfer_start C-struct to decode the message contents into + */ +static inline void mavlink_msg_file_transfer_start_decode(const mavlink_message_t* msg, mavlink_file_transfer_start_t* file_transfer_start) +{ +#if MAVLINK_NEED_BYTE_SWAP + file_transfer_start->transfer_uid = mavlink_msg_file_transfer_start_get_transfer_uid(msg); + file_transfer_start->file_size = mavlink_msg_file_transfer_start_get_file_size(msg); + mavlink_msg_file_transfer_start_get_dest_path(msg, file_transfer_start->dest_path); + file_transfer_start->direction = mavlink_msg_file_transfer_start_get_direction(msg); + file_transfer_start->flags = mavlink_msg_file_transfer_start_get_flags(msg); +#else + memcpy(file_transfer_start, _MAV_PAYLOAD(msg), 254); +#endif +} diff --git a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_global_position_int.h b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_global_position_int.h index c5be7fec6..780f562c5 100644 --- a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_global_position_int.h +++ b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_global_position_int.h @@ -68,7 +68,7 @@ static inline uint16_t mavlink_msg_global_position_int_pack(uint8_t system_id, u _mav_put_int16_t(buf, 24, vz); _mav_put_uint16_t(buf, 26, hdg); - memcpy(_MAV_PAYLOAD(msg), buf, 28); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 28); #else mavlink_global_position_int_t packet; packet.time_boot_ms = time_boot_ms; @@ -81,7 +81,7 @@ static inline uint16_t mavlink_msg_global_position_int_pack(uint8_t system_id, u packet.vz = vz; packet.hdg = hdg; - memcpy(_MAV_PAYLOAD(msg), &packet, 28); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 28); #endif msg->msgid = MAVLINK_MSG_ID_GLOBAL_POSITION_INT; @@ -121,7 +121,7 @@ static inline uint16_t mavlink_msg_global_position_int_pack_chan(uint8_t system_ _mav_put_int16_t(buf, 24, vz); _mav_put_uint16_t(buf, 26, hdg); - memcpy(_MAV_PAYLOAD(msg), buf, 28); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 28); #else mavlink_global_position_int_t packet; packet.time_boot_ms = time_boot_ms; @@ -134,7 +134,7 @@ static inline uint16_t mavlink_msg_global_position_int_pack_chan(uint8_t system_ packet.vz = vz; packet.hdg = hdg; - memcpy(_MAV_PAYLOAD(msg), &packet, 28); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 28); #endif msg->msgid = MAVLINK_MSG_ID_GLOBAL_POSITION_INT; diff --git a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_global_position_setpoint_int.h b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_global_position_setpoint_int.h index e38df91dc..853b85dae 100644 --- a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_global_position_setpoint_int.h +++ b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_global_position_setpoint_int.h @@ -52,7 +52,7 @@ static inline uint16_t mavlink_msg_global_position_setpoint_int_pack(uint8_t sys _mav_put_int16_t(buf, 12, yaw); _mav_put_uint8_t(buf, 14, coordinate_frame); - memcpy(_MAV_PAYLOAD(msg), buf, 15); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 15); #else mavlink_global_position_setpoint_int_t packet; packet.latitude = latitude; @@ -61,7 +61,7 @@ static inline uint16_t mavlink_msg_global_position_setpoint_int_pack(uint8_t sys packet.yaw = yaw; packet.coordinate_frame = coordinate_frame; - memcpy(_MAV_PAYLOAD(msg), &packet, 15); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 15); #endif msg->msgid = MAVLINK_MSG_ID_GLOBAL_POSITION_SETPOINT_INT; @@ -93,7 +93,7 @@ static inline uint16_t mavlink_msg_global_position_setpoint_int_pack_chan(uint8_ _mav_put_int16_t(buf, 12, yaw); _mav_put_uint8_t(buf, 14, coordinate_frame); - memcpy(_MAV_PAYLOAD(msg), buf, 15); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 15); #else mavlink_global_position_setpoint_int_t packet; packet.latitude = latitude; @@ -102,7 +102,7 @@ static inline uint16_t mavlink_msg_global_position_setpoint_int_pack_chan(uint8_ packet.yaw = yaw; packet.coordinate_frame = coordinate_frame; - memcpy(_MAV_PAYLOAD(msg), &packet, 15); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 15); #endif msg->msgid = MAVLINK_MSG_ID_GLOBAL_POSITION_SETPOINT_INT; diff --git a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_global_vision_position_estimate.h b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_global_vision_position_estimate.h index 06c6357b1..a911fe25e 100644 --- a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_global_vision_position_estimate.h +++ b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_global_vision_position_estimate.h @@ -4,7 +4,7 @@ typedef struct __mavlink_global_vision_position_estimate_t { - uint64_t usec; ///< Timestamp (milliseconds) + uint64_t usec; ///< Timestamp (microseconds, synced to UNIX time or since system boot) float x; ///< Global X position float y; ///< Global Y position float z; ///< Global Z position @@ -38,7 +38,7 @@ typedef struct __mavlink_global_vision_position_estimate_t * @param component_id ID of this component (e.g. 200 for IMU) * @param msg The MAVLink message to compress the data into * - * @param usec Timestamp (milliseconds) + * @param usec Timestamp (microseconds, synced to UNIX time or since system boot) * @param x Global X position * @param y Global Y position * @param z Global Z position @@ -60,7 +60,7 @@ static inline uint16_t mavlink_msg_global_vision_position_estimate_pack(uint8_t _mav_put_float(buf, 24, pitch); _mav_put_float(buf, 28, yaw); - memcpy(_MAV_PAYLOAD(msg), buf, 32); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 32); #else mavlink_global_vision_position_estimate_t packet; packet.usec = usec; @@ -71,7 +71,7 @@ static inline uint16_t mavlink_msg_global_vision_position_estimate_pack(uint8_t packet.pitch = pitch; packet.yaw = yaw; - memcpy(_MAV_PAYLOAD(msg), &packet, 32); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 32); #endif msg->msgid = MAVLINK_MSG_ID_GLOBAL_VISION_POSITION_ESTIMATE; @@ -84,7 +84,7 @@ static inline uint16_t mavlink_msg_global_vision_position_estimate_pack(uint8_t * @param component_id ID of this component (e.g. 200 for IMU) * @param chan The MAVLink channel this message was sent over * @param msg The MAVLink message to compress the data into - * @param usec Timestamp (milliseconds) + * @param usec Timestamp (microseconds, synced to UNIX time or since system boot) * @param x Global X position * @param y Global Y position * @param z Global Z position @@ -107,7 +107,7 @@ static inline uint16_t mavlink_msg_global_vision_position_estimate_pack_chan(uin _mav_put_float(buf, 24, pitch); _mav_put_float(buf, 28, yaw); - memcpy(_MAV_PAYLOAD(msg), buf, 32); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 32); #else mavlink_global_vision_position_estimate_t packet; packet.usec = usec; @@ -118,7 +118,7 @@ static inline uint16_t mavlink_msg_global_vision_position_estimate_pack_chan(uin packet.pitch = pitch; packet.yaw = yaw; - memcpy(_MAV_PAYLOAD(msg), &packet, 32); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 32); #endif msg->msgid = MAVLINK_MSG_ID_GLOBAL_VISION_POSITION_ESTIMATE; @@ -142,7 +142,7 @@ static inline uint16_t mavlink_msg_global_vision_position_estimate_encode(uint8_ * @brief Send a global_vision_position_estimate message * @param chan MAVLink channel to send the message * - * @param usec Timestamp (milliseconds) + * @param usec Timestamp (microseconds, synced to UNIX time or since system boot) * @param x Global X position * @param y Global Y position * @param z Global Z position @@ -187,7 +187,7 @@ static inline void mavlink_msg_global_vision_position_estimate_send(mavlink_chan /** * @brief Get field usec from global_vision_position_estimate message * - * @return Timestamp (milliseconds) + * @return Timestamp (microseconds, synced to UNIX time or since system boot) */ static inline uint64_t mavlink_msg_global_vision_position_estimate_get_usec(const mavlink_message_t* msg) { diff --git a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_gps_global_origin.h b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_gps_global_origin.h index 3df5a58f9..2084718b5 100644 --- a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_gps_global_origin.h +++ b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_gps_global_origin.h @@ -44,14 +44,14 @@ static inline uint16_t mavlink_msg_gps_global_origin_pack(uint8_t system_id, uin _mav_put_int32_t(buf, 4, longitude); _mav_put_int32_t(buf, 8, altitude); - memcpy(_MAV_PAYLOAD(msg), buf, 12); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 12); #else mavlink_gps_global_origin_t packet; packet.latitude = latitude; packet.longitude = longitude; packet.altitude = altitude; - memcpy(_MAV_PAYLOAD(msg), &packet, 12); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 12); #endif msg->msgid = MAVLINK_MSG_ID_GPS_GLOBAL_ORIGIN; @@ -79,14 +79,14 @@ static inline uint16_t mavlink_msg_gps_global_origin_pack_chan(uint8_t system_id _mav_put_int32_t(buf, 4, longitude); _mav_put_int32_t(buf, 8, altitude); - memcpy(_MAV_PAYLOAD(msg), buf, 12); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 12); #else mavlink_gps_global_origin_t packet; packet.latitude = latitude; packet.longitude = longitude; packet.altitude = altitude; - memcpy(_MAV_PAYLOAD(msg), &packet, 12); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 12); #endif msg->msgid = MAVLINK_MSG_ID_GPS_GLOBAL_ORIGIN; diff --git a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_gps_raw_int.h b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_gps_raw_int.h index 866ada26e..57ec97376 100644 --- a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_gps_raw_int.h +++ b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_gps_raw_int.h @@ -72,7 +72,7 @@ static inline uint16_t mavlink_msg_gps_raw_int_pack(uint8_t system_id, uint8_t c _mav_put_uint8_t(buf, 28, fix_type); _mav_put_uint8_t(buf, 29, satellites_visible); - memcpy(_MAV_PAYLOAD(msg), buf, 30); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 30); #else mavlink_gps_raw_int_t packet; packet.time_usec = time_usec; @@ -86,7 +86,7 @@ static inline uint16_t mavlink_msg_gps_raw_int_pack(uint8_t system_id, uint8_t c packet.fix_type = fix_type; packet.satellites_visible = satellites_visible; - memcpy(_MAV_PAYLOAD(msg), &packet, 30); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 30); #endif msg->msgid = MAVLINK_MSG_ID_GPS_RAW_INT; @@ -128,7 +128,7 @@ static inline uint16_t mavlink_msg_gps_raw_int_pack_chan(uint8_t system_id, uint _mav_put_uint8_t(buf, 28, fix_type); _mav_put_uint8_t(buf, 29, satellites_visible); - memcpy(_MAV_PAYLOAD(msg), buf, 30); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 30); #else mavlink_gps_raw_int_t packet; packet.time_usec = time_usec; @@ -142,7 +142,7 @@ static inline uint16_t mavlink_msg_gps_raw_int_pack_chan(uint8_t system_id, uint packet.fix_type = fix_type; packet.satellites_visible = satellites_visible; - memcpy(_MAV_PAYLOAD(msg), &packet, 30); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 30); #endif msg->msgid = MAVLINK_MSG_ID_GPS_RAW_INT; diff --git a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_gps_status.h b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_gps_status.h index 5ae1f3ab1..bd3257f88 100644 --- a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_gps_status.h +++ b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_gps_status.h @@ -59,7 +59,7 @@ static inline uint16_t mavlink_msg_gps_status_pack(uint8_t system_id, uint8_t co _mav_put_uint8_t_array(buf, 41, satellite_elevation, 20); _mav_put_uint8_t_array(buf, 61, satellite_azimuth, 20); _mav_put_uint8_t_array(buf, 81, satellite_snr, 20); - memcpy(_MAV_PAYLOAD(msg), buf, 101); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 101); #else mavlink_gps_status_t packet; packet.satellites_visible = satellites_visible; @@ -68,7 +68,7 @@ static inline uint16_t mavlink_msg_gps_status_pack(uint8_t system_id, uint8_t co mav_array_memcpy(packet.satellite_elevation, satellite_elevation, sizeof(uint8_t)*20); mav_array_memcpy(packet.satellite_azimuth, satellite_azimuth, sizeof(uint8_t)*20); mav_array_memcpy(packet.satellite_snr, satellite_snr, sizeof(uint8_t)*20); - memcpy(_MAV_PAYLOAD(msg), &packet, 101); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 101); #endif msg->msgid = MAVLINK_MSG_ID_GPS_STATUS; @@ -101,7 +101,7 @@ static inline uint16_t mavlink_msg_gps_status_pack_chan(uint8_t system_id, uint8 _mav_put_uint8_t_array(buf, 41, satellite_elevation, 20); _mav_put_uint8_t_array(buf, 61, satellite_azimuth, 20); _mav_put_uint8_t_array(buf, 81, satellite_snr, 20); - memcpy(_MAV_PAYLOAD(msg), buf, 101); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 101); #else mavlink_gps_status_t packet; packet.satellites_visible = satellites_visible; @@ -110,7 +110,7 @@ static inline uint16_t mavlink_msg_gps_status_pack_chan(uint8_t system_id, uint8 mav_array_memcpy(packet.satellite_elevation, satellite_elevation, sizeof(uint8_t)*20); mav_array_memcpy(packet.satellite_azimuth, satellite_azimuth, sizeof(uint8_t)*20); mav_array_memcpy(packet.satellite_snr, satellite_snr, sizeof(uint8_t)*20); - memcpy(_MAV_PAYLOAD(msg), &packet, 101); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 101); #endif msg->msgid = MAVLINK_MSG_ID_GPS_STATUS; diff --git a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_heartbeat.h b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_heartbeat.h index d194f2127..599ea0bc5 100644 --- a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_heartbeat.h +++ b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_heartbeat.h @@ -4,12 +4,12 @@ typedef struct __mavlink_heartbeat_t { - uint32_t custom_mode; ///< Navigation mode bitfield, see MAV_AUTOPILOT_CUSTOM_MODE ENUM for some examples. This field is autopilot-specific. + uint32_t custom_mode; ///< A bitfield for use for autopilot-specific flags. uint8_t type; ///< Type of the MAV (quadrotor, helicopter, etc., up to 15 types, defined in MAV_TYPE ENUM) - uint8_t autopilot; ///< Autopilot type / class. defined in MAV_CLASS ENUM + uint8_t autopilot; ///< Autopilot type / class. defined in MAV_AUTOPILOT ENUM uint8_t base_mode; ///< System mode bitfield, see MAV_MODE_FLAGS ENUM in mavlink/include/mavlink_types.h - uint8_t system_status; ///< System status flag, see MAV_STATUS ENUM - uint8_t mavlink_version; ///< MAVLink version + uint8_t system_status; ///< System status flag, see MAV_STATE ENUM + uint8_t mavlink_version; ///< MAVLink version, not writable by user, gets added by protocol because of magic data type: uint8_t_mavlink_version } mavlink_heartbeat_t; #define MAVLINK_MSG_ID_HEARTBEAT_LEN 9 @@ -37,10 +37,10 @@ typedef struct __mavlink_heartbeat_t * @param msg The MAVLink message to compress the data into * * @param type Type of the MAV (quadrotor, helicopter, etc., up to 15 types, defined in MAV_TYPE ENUM) - * @param autopilot Autopilot type / class. defined in MAV_CLASS ENUM + * @param autopilot Autopilot type / class. defined in MAV_AUTOPILOT ENUM * @param base_mode System mode bitfield, see MAV_MODE_FLAGS ENUM in mavlink/include/mavlink_types.h - * @param custom_mode Navigation mode bitfield, see MAV_AUTOPILOT_CUSTOM_MODE ENUM for some examples. This field is autopilot-specific. - * @param system_status System status flag, see MAV_STATUS ENUM + * @param custom_mode A bitfield for use for autopilot-specific flags. + * @param system_status System status flag, see MAV_STATE ENUM * @return length of the message in bytes (excluding serial stream start sign) */ static inline uint16_t mavlink_msg_heartbeat_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, @@ -55,7 +55,7 @@ static inline uint16_t mavlink_msg_heartbeat_pack(uint8_t system_id, uint8_t com _mav_put_uint8_t(buf, 7, system_status); _mav_put_uint8_t(buf, 8, 3); - memcpy(_MAV_PAYLOAD(msg), buf, 9); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 9); #else mavlink_heartbeat_t packet; packet.custom_mode = custom_mode; @@ -65,7 +65,7 @@ static inline uint16_t mavlink_msg_heartbeat_pack(uint8_t system_id, uint8_t com packet.system_status = system_status; packet.mavlink_version = 3; - memcpy(_MAV_PAYLOAD(msg), &packet, 9); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 9); #endif msg->msgid = MAVLINK_MSG_ID_HEARTBEAT; @@ -79,10 +79,10 @@ static inline uint16_t mavlink_msg_heartbeat_pack(uint8_t system_id, uint8_t com * @param chan The MAVLink channel this message was sent over * @param msg The MAVLink message to compress the data into * @param type Type of the MAV (quadrotor, helicopter, etc., up to 15 types, defined in MAV_TYPE ENUM) - * @param autopilot Autopilot type / class. defined in MAV_CLASS ENUM + * @param autopilot Autopilot type / class. defined in MAV_AUTOPILOT ENUM * @param base_mode System mode bitfield, see MAV_MODE_FLAGS ENUM in mavlink/include/mavlink_types.h - * @param custom_mode Navigation mode bitfield, see MAV_AUTOPILOT_CUSTOM_MODE ENUM for some examples. This field is autopilot-specific. - * @param system_status System status flag, see MAV_STATUS ENUM + * @param custom_mode A bitfield for use for autopilot-specific flags. + * @param system_status System status flag, see MAV_STATE ENUM * @return length of the message in bytes (excluding serial stream start sign) */ static inline uint16_t mavlink_msg_heartbeat_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, @@ -98,7 +98,7 @@ static inline uint16_t mavlink_msg_heartbeat_pack_chan(uint8_t system_id, uint8_ _mav_put_uint8_t(buf, 7, system_status); _mav_put_uint8_t(buf, 8, 3); - memcpy(_MAV_PAYLOAD(msg), buf, 9); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 9); #else mavlink_heartbeat_t packet; packet.custom_mode = custom_mode; @@ -108,7 +108,7 @@ static inline uint16_t mavlink_msg_heartbeat_pack_chan(uint8_t system_id, uint8_ packet.system_status = system_status; packet.mavlink_version = 3; - memcpy(_MAV_PAYLOAD(msg), &packet, 9); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 9); #endif msg->msgid = MAVLINK_MSG_ID_HEARTBEAT; @@ -133,10 +133,10 @@ static inline uint16_t mavlink_msg_heartbeat_encode(uint8_t system_id, uint8_t c * @param chan MAVLink channel to send the message * * @param type Type of the MAV (quadrotor, helicopter, etc., up to 15 types, defined in MAV_TYPE ENUM) - * @param autopilot Autopilot type / class. defined in MAV_CLASS ENUM + * @param autopilot Autopilot type / class. defined in MAV_AUTOPILOT ENUM * @param base_mode System mode bitfield, see MAV_MODE_FLAGS ENUM in mavlink/include/mavlink_types.h - * @param custom_mode Navigation mode bitfield, see MAV_AUTOPILOT_CUSTOM_MODE ENUM for some examples. This field is autopilot-specific. - * @param system_status System status flag, see MAV_STATUS ENUM + * @param custom_mode A bitfield for use for autopilot-specific flags. + * @param system_status System status flag, see MAV_STATE ENUM */ #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS @@ -183,7 +183,7 @@ static inline uint8_t mavlink_msg_heartbeat_get_type(const mavlink_message_t* ms /** * @brief Get field autopilot from heartbeat message * - * @return Autopilot type / class. defined in MAV_CLASS ENUM + * @return Autopilot type / class. defined in MAV_AUTOPILOT ENUM */ static inline uint8_t mavlink_msg_heartbeat_get_autopilot(const mavlink_message_t* msg) { @@ -203,7 +203,7 @@ static inline uint8_t mavlink_msg_heartbeat_get_base_mode(const mavlink_message_ /** * @brief Get field custom_mode from heartbeat message * - * @return Navigation mode bitfield, see MAV_AUTOPILOT_CUSTOM_MODE ENUM for some examples. This field is autopilot-specific. + * @return A bitfield for use for autopilot-specific flags. */ static inline uint32_t mavlink_msg_heartbeat_get_custom_mode(const mavlink_message_t* msg) { @@ -213,7 +213,7 @@ static inline uint32_t mavlink_msg_heartbeat_get_custom_mode(const mavlink_messa /** * @brief Get field system_status from heartbeat message * - * @return System status flag, see MAV_STATUS ENUM + * @return System status flag, see MAV_STATE ENUM */ static inline uint8_t mavlink_msg_heartbeat_get_system_status(const mavlink_message_t* msg) { @@ -223,7 +223,7 @@ static inline uint8_t mavlink_msg_heartbeat_get_system_status(const mavlink_mess /** * @brief Get field mavlink_version from heartbeat message * - * @return MAVLink version + * @return MAVLink version, not writable by user, gets added by protocol because of magic data type: uint8_t_mavlink_version */ static inline uint8_t mavlink_msg_heartbeat_get_mavlink_version(const mavlink_message_t* msg) { diff --git a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_highres_imu.h b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_highres_imu.h new file mode 100644 index 000000000..9714c698f --- /dev/null +++ b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_highres_imu.h @@ -0,0 +1,452 @@ +// MESSAGE HIGHRES_IMU PACKING + +#define MAVLINK_MSG_ID_HIGHRES_IMU 105 + +typedef struct __mavlink_highres_imu_t +{ + uint64_t time_usec; ///< Timestamp (microseconds, synced to UNIX time or since system boot) + float xacc; ///< X acceleration (m/s^2) + float yacc; ///< Y acceleration (m/s^2) + float zacc; ///< Z acceleration (m/s^2) + float xgyro; ///< Angular speed around X axis (rad / sec) + float ygyro; ///< Angular speed around Y axis (rad / sec) + float zgyro; ///< Angular speed around Z axis (rad / sec) + float xmag; ///< X Magnetic field (Gauss) + float ymag; ///< Y Magnetic field (Gauss) + float zmag; ///< Z Magnetic field (Gauss) + float abs_pressure; ///< Absolute pressure in millibar + float diff_pressure; ///< Differential pressure in millibar + float pressure_alt; ///< Altitude calculated from pressure + float temperature; ///< Temperature in degrees celsius + uint16_t fields_updated; ///< Bitmask for fields that have updated since last message, bit 0 = xacc, bit 12: temperature +} mavlink_highres_imu_t; + +#define MAVLINK_MSG_ID_HIGHRES_IMU_LEN 62 +#define MAVLINK_MSG_ID_105_LEN 62 + + + +#define MAVLINK_MESSAGE_INFO_HIGHRES_IMU { \ + "HIGHRES_IMU", \ + 15, \ + { { "time_usec", NULL, MAVLINK_TYPE_UINT64_T, 0, 0, offsetof(mavlink_highres_imu_t, time_usec) }, \ + { "xacc", NULL, MAVLINK_TYPE_FLOAT, 0, 8, offsetof(mavlink_highres_imu_t, xacc) }, \ + { "yacc", NULL, MAVLINK_TYPE_FLOAT, 0, 12, offsetof(mavlink_highres_imu_t, yacc) }, \ + { "zacc", NULL, MAVLINK_TYPE_FLOAT, 0, 16, offsetof(mavlink_highres_imu_t, zacc) }, \ + { "xgyro", NULL, MAVLINK_TYPE_FLOAT, 0, 20, offsetof(mavlink_highres_imu_t, xgyro) }, \ + { "ygyro", NULL, MAVLINK_TYPE_FLOAT, 0, 24, offsetof(mavlink_highres_imu_t, ygyro) }, \ + { "zgyro", NULL, MAVLINK_TYPE_FLOAT, 0, 28, offsetof(mavlink_highres_imu_t, zgyro) }, \ + { "xmag", NULL, MAVLINK_TYPE_FLOAT, 0, 32, offsetof(mavlink_highres_imu_t, xmag) }, \ + { "ymag", NULL, MAVLINK_TYPE_FLOAT, 0, 36, offsetof(mavlink_highres_imu_t, ymag) }, \ + { "zmag", NULL, MAVLINK_TYPE_FLOAT, 0, 40, offsetof(mavlink_highres_imu_t, zmag) }, \ + { "abs_pressure", NULL, MAVLINK_TYPE_FLOAT, 0, 44, offsetof(mavlink_highres_imu_t, abs_pressure) }, \ + { "diff_pressure", NULL, MAVLINK_TYPE_FLOAT, 0, 48, offsetof(mavlink_highres_imu_t, diff_pressure) }, \ + { "pressure_alt", NULL, MAVLINK_TYPE_FLOAT, 0, 52, offsetof(mavlink_highres_imu_t, pressure_alt) }, \ + { "temperature", NULL, MAVLINK_TYPE_FLOAT, 0, 56, offsetof(mavlink_highres_imu_t, temperature) }, \ + { "fields_updated", NULL, MAVLINK_TYPE_UINT16_T, 0, 60, offsetof(mavlink_highres_imu_t, fields_updated) }, \ + } \ +} + + +/** + * @brief Pack a highres_imu message + * @param system_id ID of this system + * @param component_id ID of this component (e.g. 200 for IMU) + * @param msg The MAVLink message to compress the data into + * + * @param time_usec Timestamp (microseconds, synced to UNIX time or since system boot) + * @param xacc X acceleration (m/s^2) + * @param yacc Y acceleration (m/s^2) + * @param zacc Z acceleration (m/s^2) + * @param xgyro Angular speed around X axis (rad / sec) + * @param ygyro Angular speed around Y axis (rad / sec) + * @param zgyro Angular speed around Z axis (rad / sec) + * @param xmag X Magnetic field (Gauss) + * @param ymag Y Magnetic field (Gauss) + * @param zmag Z Magnetic field (Gauss) + * @param abs_pressure Absolute pressure in millibar + * @param diff_pressure Differential pressure in millibar + * @param pressure_alt Altitude calculated from pressure + * @param temperature Temperature in degrees celsius + * @param fields_updated Bitmask for fields that have updated since last message, bit 0 = xacc, bit 12: temperature + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_highres_imu_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, + uint64_t time_usec, float xacc, float yacc, float zacc, float xgyro, float ygyro, float zgyro, float xmag, float ymag, float zmag, float abs_pressure, float diff_pressure, float pressure_alt, float temperature, uint16_t fields_updated) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[62]; + _mav_put_uint64_t(buf, 0, time_usec); + _mav_put_float(buf, 8, xacc); + _mav_put_float(buf, 12, yacc); + _mav_put_float(buf, 16, zacc); + _mav_put_float(buf, 20, xgyro); + _mav_put_float(buf, 24, ygyro); + _mav_put_float(buf, 28, zgyro); + _mav_put_float(buf, 32, xmag); + _mav_put_float(buf, 36, ymag); + _mav_put_float(buf, 40, zmag); + _mav_put_float(buf, 44, abs_pressure); + _mav_put_float(buf, 48, diff_pressure); + _mav_put_float(buf, 52, pressure_alt); + _mav_put_float(buf, 56, temperature); + _mav_put_uint16_t(buf, 60, fields_updated); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 62); +#else + mavlink_highres_imu_t packet; + packet.time_usec = time_usec; + packet.xacc = xacc; + packet.yacc = yacc; + packet.zacc = zacc; + packet.xgyro = xgyro; + packet.ygyro = ygyro; + packet.zgyro = zgyro; + packet.xmag = xmag; + packet.ymag = ymag; + packet.zmag = zmag; + packet.abs_pressure = abs_pressure; + packet.diff_pressure = diff_pressure; + packet.pressure_alt = pressure_alt; + packet.temperature = temperature; + packet.fields_updated = fields_updated; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 62); +#endif + + msg->msgid = MAVLINK_MSG_ID_HIGHRES_IMU; + return mavlink_finalize_message(msg, system_id, component_id, 62, 93); +} + +/** + * @brief Pack a highres_imu message on a channel + * @param system_id ID of this system + * @param component_id ID of this component (e.g. 200 for IMU) + * @param chan The MAVLink channel this message was sent over + * @param msg The MAVLink message to compress the data into + * @param time_usec Timestamp (microseconds, synced to UNIX time or since system boot) + * @param xacc X acceleration (m/s^2) + * @param yacc Y acceleration (m/s^2) + * @param zacc Z acceleration (m/s^2) + * @param xgyro Angular speed around X axis (rad / sec) + * @param ygyro Angular speed around Y axis (rad / sec) + * @param zgyro Angular speed around Z axis (rad / sec) + * @param xmag X Magnetic field (Gauss) + * @param ymag Y Magnetic field (Gauss) + * @param zmag Z Magnetic field (Gauss) + * @param abs_pressure Absolute pressure in millibar + * @param diff_pressure Differential pressure in millibar + * @param pressure_alt Altitude calculated from pressure + * @param temperature Temperature in degrees celsius + * @param fields_updated Bitmask for fields that have updated since last message, bit 0 = xacc, bit 12: temperature + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_highres_imu_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, + mavlink_message_t* msg, + uint64_t time_usec,float xacc,float yacc,float zacc,float xgyro,float ygyro,float zgyro,float xmag,float ymag,float zmag,float abs_pressure,float diff_pressure,float pressure_alt,float temperature,uint16_t fields_updated) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[62]; + _mav_put_uint64_t(buf, 0, time_usec); + _mav_put_float(buf, 8, xacc); + _mav_put_float(buf, 12, yacc); + _mav_put_float(buf, 16, zacc); + _mav_put_float(buf, 20, xgyro); + _mav_put_float(buf, 24, ygyro); + _mav_put_float(buf, 28, zgyro); + _mav_put_float(buf, 32, xmag); + _mav_put_float(buf, 36, ymag); + _mav_put_float(buf, 40, zmag); + _mav_put_float(buf, 44, abs_pressure); + _mav_put_float(buf, 48, diff_pressure); + _mav_put_float(buf, 52, pressure_alt); + _mav_put_float(buf, 56, temperature); + _mav_put_uint16_t(buf, 60, fields_updated); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 62); +#else + mavlink_highres_imu_t packet; + packet.time_usec = time_usec; + packet.xacc = xacc; + packet.yacc = yacc; + packet.zacc = zacc; + packet.xgyro = xgyro; + packet.ygyro = ygyro; + packet.zgyro = zgyro; + packet.xmag = xmag; + packet.ymag = ymag; + packet.zmag = zmag; + packet.abs_pressure = abs_pressure; + packet.diff_pressure = diff_pressure; + packet.pressure_alt = pressure_alt; + packet.temperature = temperature; + packet.fields_updated = fields_updated; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 62); +#endif + + msg->msgid = MAVLINK_MSG_ID_HIGHRES_IMU; + return mavlink_finalize_message_chan(msg, system_id, component_id, chan, 62, 93); +} + +/** + * @brief Encode a highres_imu struct into a message + * + * @param system_id ID of this system + * @param component_id ID of this component (e.g. 200 for IMU) + * @param msg The MAVLink message to compress the data into + * @param highres_imu C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_highres_imu_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_highres_imu_t* highres_imu) +{ + return mavlink_msg_highres_imu_pack(system_id, component_id, msg, highres_imu->time_usec, highres_imu->xacc, highres_imu->yacc, highres_imu->zacc, highres_imu->xgyro, highres_imu->ygyro, highres_imu->zgyro, highres_imu->xmag, highres_imu->ymag, highres_imu->zmag, highres_imu->abs_pressure, highres_imu->diff_pressure, highres_imu->pressure_alt, highres_imu->temperature, highres_imu->fields_updated); +} + +/** + * @brief Send a highres_imu message + * @param chan MAVLink channel to send the message + * + * @param time_usec Timestamp (microseconds, synced to UNIX time or since system boot) + * @param xacc X acceleration (m/s^2) + * @param yacc Y acceleration (m/s^2) + * @param zacc Z acceleration (m/s^2) + * @param xgyro Angular speed around X axis (rad / sec) + * @param ygyro Angular speed around Y axis (rad / sec) + * @param zgyro Angular speed around Z axis (rad / sec) + * @param xmag X Magnetic field (Gauss) + * @param ymag Y Magnetic field (Gauss) + * @param zmag Z Magnetic field (Gauss) + * @param abs_pressure Absolute pressure in millibar + * @param diff_pressure Differential pressure in millibar + * @param pressure_alt Altitude calculated from pressure + * @param temperature Temperature in degrees celsius + * @param fields_updated Bitmask for fields that have updated since last message, bit 0 = xacc, bit 12: temperature + */ +#ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS + +static inline void mavlink_msg_highres_imu_send(mavlink_channel_t chan, uint64_t time_usec, float xacc, float yacc, float zacc, float xgyro, float ygyro, float zgyro, float xmag, float ymag, float zmag, float abs_pressure, float diff_pressure, float pressure_alt, float temperature, uint16_t fields_updated) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[62]; + _mav_put_uint64_t(buf, 0, time_usec); + _mav_put_float(buf, 8, xacc); + _mav_put_float(buf, 12, yacc); + _mav_put_float(buf, 16, zacc); + _mav_put_float(buf, 20, xgyro); + _mav_put_float(buf, 24, ygyro); + _mav_put_float(buf, 28, zgyro); + _mav_put_float(buf, 32, xmag); + _mav_put_float(buf, 36, ymag); + _mav_put_float(buf, 40, zmag); + _mav_put_float(buf, 44, abs_pressure); + _mav_put_float(buf, 48, diff_pressure); + _mav_put_float(buf, 52, pressure_alt); + _mav_put_float(buf, 56, temperature); + _mav_put_uint16_t(buf, 60, fields_updated); + + _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_HIGHRES_IMU, buf, 62, 93); +#else + mavlink_highres_imu_t packet; + packet.time_usec = time_usec; + packet.xacc = xacc; + packet.yacc = yacc; + packet.zacc = zacc; + packet.xgyro = xgyro; + packet.ygyro = ygyro; + packet.zgyro = zgyro; + packet.xmag = xmag; + packet.ymag = ymag; + packet.zmag = zmag; + packet.abs_pressure = abs_pressure; + packet.diff_pressure = diff_pressure; + packet.pressure_alt = pressure_alt; + packet.temperature = temperature; + packet.fields_updated = fields_updated; + + _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_HIGHRES_IMU, (const char *)&packet, 62, 93); +#endif +} + +#endif + +// MESSAGE HIGHRES_IMU UNPACKING + + +/** + * @brief Get field time_usec from highres_imu message + * + * @return Timestamp (microseconds, synced to UNIX time or since system boot) + */ +static inline uint64_t mavlink_msg_highres_imu_get_time_usec(const mavlink_message_t* msg) +{ + return _MAV_RETURN_uint64_t(msg, 0); +} + +/** + * @brief Get field xacc from highres_imu message + * + * @return X acceleration (m/s^2) + */ +static inline float mavlink_msg_highres_imu_get_xacc(const mavlink_message_t* msg) +{ + return _MAV_RETURN_float(msg, 8); +} + +/** + * @brief Get field yacc from highres_imu message + * + * @return Y acceleration (m/s^2) + */ +static inline float mavlink_msg_highres_imu_get_yacc(const mavlink_message_t* msg) +{ + return _MAV_RETURN_float(msg, 12); +} + +/** + * @brief Get field zacc from highres_imu message + * + * @return Z acceleration (m/s^2) + */ +static inline float mavlink_msg_highres_imu_get_zacc(const mavlink_message_t* msg) +{ + return _MAV_RETURN_float(msg, 16); +} + +/** + * @brief Get field xgyro from highres_imu message + * + * @return Angular speed around X axis (rad / sec) + */ +static inline float mavlink_msg_highres_imu_get_xgyro(const mavlink_message_t* msg) +{ + return _MAV_RETURN_float(msg, 20); +} + +/** + * @brief Get field ygyro from highres_imu message + * + * @return Angular speed around Y axis (rad / sec) + */ +static inline float mavlink_msg_highres_imu_get_ygyro(const mavlink_message_t* msg) +{ + return _MAV_RETURN_float(msg, 24); +} + +/** + * @brief Get field zgyro from highres_imu message + * + * @return Angular speed around Z axis (rad / sec) + */ +static inline float mavlink_msg_highres_imu_get_zgyro(const mavlink_message_t* msg) +{ + return _MAV_RETURN_float(msg, 28); +} + +/** + * @brief Get field xmag from highres_imu message + * + * @return X Magnetic field (Gauss) + */ +static inline float mavlink_msg_highres_imu_get_xmag(const mavlink_message_t* msg) +{ + return _MAV_RETURN_float(msg, 32); +} + +/** + * @brief Get field ymag from highres_imu message + * + * @return Y Magnetic field (Gauss) + */ +static inline float mavlink_msg_highres_imu_get_ymag(const mavlink_message_t* msg) +{ + return _MAV_RETURN_float(msg, 36); +} + +/** + * @brief Get field zmag from highres_imu message + * + * @return Z Magnetic field (Gauss) + */ +static inline float mavlink_msg_highres_imu_get_zmag(const mavlink_message_t* msg) +{ + return _MAV_RETURN_float(msg, 40); +} + +/** + * @brief Get field abs_pressure from highres_imu message + * + * @return Absolute pressure in millibar + */ +static inline float mavlink_msg_highres_imu_get_abs_pressure(const mavlink_message_t* msg) +{ + return _MAV_RETURN_float(msg, 44); +} + +/** + * @brief Get field diff_pressure from highres_imu message + * + * @return Differential pressure in millibar + */ +static inline float mavlink_msg_highres_imu_get_diff_pressure(const mavlink_message_t* msg) +{ + return _MAV_RETURN_float(msg, 48); +} + +/** + * @brief Get field pressure_alt from highres_imu message + * + * @return Altitude calculated from pressure + */ +static inline float mavlink_msg_highres_imu_get_pressure_alt(const mavlink_message_t* msg) +{ + return _MAV_RETURN_float(msg, 52); +} + +/** + * @brief Get field temperature from highres_imu message + * + * @return Temperature in degrees celsius + */ +static inline float mavlink_msg_highres_imu_get_temperature(const mavlink_message_t* msg) +{ + return _MAV_RETURN_float(msg, 56); +} + +/** + * @brief Get field fields_updated from highres_imu message + * + * @return Bitmask for fields that have updated since last message, bit 0 = xacc, bit 12: temperature + */ +static inline uint16_t mavlink_msg_highres_imu_get_fields_updated(const mavlink_message_t* msg) +{ + return _MAV_RETURN_uint16_t(msg, 60); +} + +/** + * @brief Decode a highres_imu message into a struct + * + * @param msg The message to decode + * @param highres_imu C-struct to decode the message contents into + */ +static inline void mavlink_msg_highres_imu_decode(const mavlink_message_t* msg, mavlink_highres_imu_t* highres_imu) +{ +#if MAVLINK_NEED_BYTE_SWAP + highres_imu->time_usec = mavlink_msg_highres_imu_get_time_usec(msg); + highres_imu->xacc = mavlink_msg_highres_imu_get_xacc(msg); + highres_imu->yacc = mavlink_msg_highres_imu_get_yacc(msg); + highres_imu->zacc = mavlink_msg_highres_imu_get_zacc(msg); + highres_imu->xgyro = mavlink_msg_highres_imu_get_xgyro(msg); + highres_imu->ygyro = mavlink_msg_highres_imu_get_ygyro(msg); + highres_imu->zgyro = mavlink_msg_highres_imu_get_zgyro(msg); + highres_imu->xmag = mavlink_msg_highres_imu_get_xmag(msg); + highres_imu->ymag = mavlink_msg_highres_imu_get_ymag(msg); + highres_imu->zmag = mavlink_msg_highres_imu_get_zmag(msg); + highres_imu->abs_pressure = mavlink_msg_highres_imu_get_abs_pressure(msg); + highres_imu->diff_pressure = mavlink_msg_highres_imu_get_diff_pressure(msg); + highres_imu->pressure_alt = mavlink_msg_highres_imu_get_pressure_alt(msg); + highres_imu->temperature = mavlink_msg_highres_imu_get_temperature(msg); + highres_imu->fields_updated = mavlink_msg_highres_imu_get_fields_updated(msg); +#else + memcpy(highres_imu, _MAV_PAYLOAD(msg), 62); +#endif +} diff --git a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_hil_controls.h b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_hil_controls.h index 23c84bc56..41a9bc949 100644 --- a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_hil_controls.h +++ b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_hil_controls.h @@ -76,7 +76,7 @@ static inline uint16_t mavlink_msg_hil_controls_pack(uint8_t system_id, uint8_t _mav_put_uint8_t(buf, 40, mode); _mav_put_uint8_t(buf, 41, nav_mode); - memcpy(_MAV_PAYLOAD(msg), buf, 42); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 42); #else mavlink_hil_controls_t packet; packet.time_usec = time_usec; @@ -91,7 +91,7 @@ static inline uint16_t mavlink_msg_hil_controls_pack(uint8_t system_id, uint8_t packet.mode = mode; packet.nav_mode = nav_mode; - memcpy(_MAV_PAYLOAD(msg), &packet, 42); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 42); #endif msg->msgid = MAVLINK_MSG_ID_HIL_CONTROLS; @@ -135,7 +135,7 @@ static inline uint16_t mavlink_msg_hil_controls_pack_chan(uint8_t system_id, uin _mav_put_uint8_t(buf, 40, mode); _mav_put_uint8_t(buf, 41, nav_mode); - memcpy(_MAV_PAYLOAD(msg), buf, 42); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 42); #else mavlink_hil_controls_t packet; packet.time_usec = time_usec; @@ -150,7 +150,7 @@ static inline uint16_t mavlink_msg_hil_controls_pack_chan(uint8_t system_id, uin packet.mode = mode; packet.nav_mode = nav_mode; - memcpy(_MAV_PAYLOAD(msg), &packet, 42); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 42); #endif msg->msgid = MAVLINK_MSG_ID_HIL_CONTROLS; diff --git a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_hil_rc_inputs_raw.h b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_hil_rc_inputs_raw.h index d02c41539..7ac0853d3 100644 --- a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_hil_rc_inputs_raw.h +++ b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_hil_rc_inputs_raw.h @@ -88,7 +88,7 @@ static inline uint16_t mavlink_msg_hil_rc_inputs_raw_pack(uint8_t system_id, uin _mav_put_uint16_t(buf, 30, chan12_raw); _mav_put_uint8_t(buf, 32, rssi); - memcpy(_MAV_PAYLOAD(msg), buf, 33); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 33); #else mavlink_hil_rc_inputs_raw_t packet; packet.time_usec = time_usec; @@ -106,7 +106,7 @@ static inline uint16_t mavlink_msg_hil_rc_inputs_raw_pack(uint8_t system_id, uin packet.chan12_raw = chan12_raw; packet.rssi = rssi; - memcpy(_MAV_PAYLOAD(msg), &packet, 33); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 33); #endif msg->msgid = MAVLINK_MSG_ID_HIL_RC_INPUTS_RAW; @@ -156,7 +156,7 @@ static inline uint16_t mavlink_msg_hil_rc_inputs_raw_pack_chan(uint8_t system_id _mav_put_uint16_t(buf, 30, chan12_raw); _mav_put_uint8_t(buf, 32, rssi); - memcpy(_MAV_PAYLOAD(msg), buf, 33); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 33); #else mavlink_hil_rc_inputs_raw_t packet; packet.time_usec = time_usec; @@ -174,7 +174,7 @@ static inline uint16_t mavlink_msg_hil_rc_inputs_raw_pack_chan(uint8_t system_id packet.chan12_raw = chan12_raw; packet.rssi = rssi; - memcpy(_MAV_PAYLOAD(msg), &packet, 33); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 33); #endif msg->msgid = MAVLINK_MSG_ID_HIL_RC_INPUTS_RAW; diff --git a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_hil_state.h b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_hil_state.h index f61c5170f..144781295 100644 --- a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_hil_state.h +++ b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_hil_state.h @@ -96,7 +96,7 @@ static inline uint16_t mavlink_msg_hil_state_pack(uint8_t system_id, uint8_t com _mav_put_int16_t(buf, 52, yacc); _mav_put_int16_t(buf, 54, zacc); - memcpy(_MAV_PAYLOAD(msg), buf, 56); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 56); #else mavlink_hil_state_t packet; packet.time_usec = time_usec; @@ -116,7 +116,7 @@ static inline uint16_t mavlink_msg_hil_state_pack(uint8_t system_id, uint8_t com packet.yacc = yacc; packet.zacc = zacc; - memcpy(_MAV_PAYLOAD(msg), &packet, 56); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 56); #endif msg->msgid = MAVLINK_MSG_ID_HIL_STATE; @@ -170,7 +170,7 @@ static inline uint16_t mavlink_msg_hil_state_pack_chan(uint8_t system_id, uint8_ _mav_put_int16_t(buf, 52, yacc); _mav_put_int16_t(buf, 54, zacc); - memcpy(_MAV_PAYLOAD(msg), buf, 56); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 56); #else mavlink_hil_state_t packet; packet.time_usec = time_usec; @@ -190,7 +190,7 @@ static inline uint16_t mavlink_msg_hil_state_pack_chan(uint8_t system_id, uint8_ packet.yacc = yacc; packet.zacc = zacc; - memcpy(_MAV_PAYLOAD(msg), &packet, 56); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 56); #endif msg->msgid = MAVLINK_MSG_ID_HIL_STATE; diff --git a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_local_position_ned.h b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_local_position_ned.h index d59ae0b1a..fe0a791fc 100644 --- a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_local_position_ned.h +++ b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_local_position_ned.h @@ -60,7 +60,7 @@ static inline uint16_t mavlink_msg_local_position_ned_pack(uint8_t system_id, ui _mav_put_float(buf, 20, vy); _mav_put_float(buf, 24, vz); - memcpy(_MAV_PAYLOAD(msg), buf, 28); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 28); #else mavlink_local_position_ned_t packet; packet.time_boot_ms = time_boot_ms; @@ -71,7 +71,7 @@ static inline uint16_t mavlink_msg_local_position_ned_pack(uint8_t system_id, ui packet.vy = vy; packet.vz = vz; - memcpy(_MAV_PAYLOAD(msg), &packet, 28); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 28); #endif msg->msgid = MAVLINK_MSG_ID_LOCAL_POSITION_NED; @@ -107,7 +107,7 @@ static inline uint16_t mavlink_msg_local_position_ned_pack_chan(uint8_t system_i _mav_put_float(buf, 20, vy); _mav_put_float(buf, 24, vz); - memcpy(_MAV_PAYLOAD(msg), buf, 28); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 28); #else mavlink_local_position_ned_t packet; packet.time_boot_ms = time_boot_ms; @@ -118,7 +118,7 @@ static inline uint16_t mavlink_msg_local_position_ned_pack_chan(uint8_t system_i packet.vy = vy; packet.vz = vz; - memcpy(_MAV_PAYLOAD(msg), &packet, 28); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 28); #endif msg->msgid = MAVLINK_MSG_ID_LOCAL_POSITION_NED; diff --git a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_local_position_ned_system_global_offset.h b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_local_position_ned_system_global_offset.h new file mode 100644 index 000000000..ac1941db0 --- /dev/null +++ b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_local_position_ned_system_global_offset.h @@ -0,0 +1,276 @@ +// MESSAGE LOCAL_POSITION_NED_SYSTEM_GLOBAL_OFFSET PACKING + +#define MAVLINK_MSG_ID_LOCAL_POSITION_NED_SYSTEM_GLOBAL_OFFSET 89 + +typedef struct __mavlink_local_position_ned_system_global_offset_t +{ + uint32_t time_boot_ms; ///< Timestamp (milliseconds since system boot) + float x; ///< X Position + float y; ///< Y Position + float z; ///< Z Position + float roll; ///< Roll + float pitch; ///< Pitch + float yaw; ///< Yaw +} mavlink_local_position_ned_system_global_offset_t; + +#define MAVLINK_MSG_ID_LOCAL_POSITION_NED_SYSTEM_GLOBAL_OFFSET_LEN 28 +#define MAVLINK_MSG_ID_89_LEN 28 + + + +#define MAVLINK_MESSAGE_INFO_LOCAL_POSITION_NED_SYSTEM_GLOBAL_OFFSET { \ + "LOCAL_POSITION_NED_SYSTEM_GLOBAL_OFFSET", \ + 7, \ + { { "time_boot_ms", NULL, MAVLINK_TYPE_UINT32_T, 0, 0, offsetof(mavlink_local_position_ned_system_global_offset_t, time_boot_ms) }, \ + { "x", NULL, MAVLINK_TYPE_FLOAT, 0, 4, offsetof(mavlink_local_position_ned_system_global_offset_t, x) }, \ + { "y", NULL, MAVLINK_TYPE_FLOAT, 0, 8, offsetof(mavlink_local_position_ned_system_global_offset_t, y) }, \ + { "z", NULL, MAVLINK_TYPE_FLOAT, 0, 12, offsetof(mavlink_local_position_ned_system_global_offset_t, z) }, \ + { "roll", NULL, MAVLINK_TYPE_FLOAT, 0, 16, offsetof(mavlink_local_position_ned_system_global_offset_t, roll) }, \ + { "pitch", NULL, MAVLINK_TYPE_FLOAT, 0, 20, offsetof(mavlink_local_position_ned_system_global_offset_t, pitch) }, \ + { "yaw", NULL, MAVLINK_TYPE_FLOAT, 0, 24, offsetof(mavlink_local_position_ned_system_global_offset_t, yaw) }, \ + } \ +} + + +/** + * @brief Pack a local_position_ned_system_global_offset message + * @param system_id ID of this system + * @param component_id ID of this component (e.g. 200 for IMU) + * @param msg The MAVLink message to compress the data into + * + * @param time_boot_ms Timestamp (milliseconds since system boot) + * @param x X Position + * @param y Y Position + * @param z Z Position + * @param roll Roll + * @param pitch Pitch + * @param yaw Yaw + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_local_position_ned_system_global_offset_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, + uint32_t time_boot_ms, float x, float y, float z, float roll, float pitch, float yaw) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[28]; + _mav_put_uint32_t(buf, 0, time_boot_ms); + _mav_put_float(buf, 4, x); + _mav_put_float(buf, 8, y); + _mav_put_float(buf, 12, z); + _mav_put_float(buf, 16, roll); + _mav_put_float(buf, 20, pitch); + _mav_put_float(buf, 24, yaw); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 28); +#else + mavlink_local_position_ned_system_global_offset_t packet; + packet.time_boot_ms = time_boot_ms; + packet.x = x; + packet.y = y; + packet.z = z; + packet.roll = roll; + packet.pitch = pitch; + packet.yaw = yaw; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 28); +#endif + + msg->msgid = MAVLINK_MSG_ID_LOCAL_POSITION_NED_SYSTEM_GLOBAL_OFFSET; + return mavlink_finalize_message(msg, system_id, component_id, 28, 231); +} + +/** + * @brief Pack a local_position_ned_system_global_offset message on a channel + * @param system_id ID of this system + * @param component_id ID of this component (e.g. 200 for IMU) + * @param chan The MAVLink channel this message was sent over + * @param msg The MAVLink message to compress the data into + * @param time_boot_ms Timestamp (milliseconds since system boot) + * @param x X Position + * @param y Y Position + * @param z Z Position + * @param roll Roll + * @param pitch Pitch + * @param yaw Yaw + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_local_position_ned_system_global_offset_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, + mavlink_message_t* msg, + uint32_t time_boot_ms,float x,float y,float z,float roll,float pitch,float yaw) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[28]; + _mav_put_uint32_t(buf, 0, time_boot_ms); + _mav_put_float(buf, 4, x); + _mav_put_float(buf, 8, y); + _mav_put_float(buf, 12, z); + _mav_put_float(buf, 16, roll); + _mav_put_float(buf, 20, pitch); + _mav_put_float(buf, 24, yaw); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 28); +#else + mavlink_local_position_ned_system_global_offset_t packet; + packet.time_boot_ms = time_boot_ms; + packet.x = x; + packet.y = y; + packet.z = z; + packet.roll = roll; + packet.pitch = pitch; + packet.yaw = yaw; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 28); +#endif + + msg->msgid = MAVLINK_MSG_ID_LOCAL_POSITION_NED_SYSTEM_GLOBAL_OFFSET; + return mavlink_finalize_message_chan(msg, system_id, component_id, chan, 28, 231); +} + +/** + * @brief Encode a local_position_ned_system_global_offset struct into a message + * + * @param system_id ID of this system + * @param component_id ID of this component (e.g. 200 for IMU) + * @param msg The MAVLink message to compress the data into + * @param local_position_ned_system_global_offset C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_local_position_ned_system_global_offset_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_local_position_ned_system_global_offset_t* local_position_ned_system_global_offset) +{ + return mavlink_msg_local_position_ned_system_global_offset_pack(system_id, component_id, msg, local_position_ned_system_global_offset->time_boot_ms, local_position_ned_system_global_offset->x, local_position_ned_system_global_offset->y, local_position_ned_system_global_offset->z, local_position_ned_system_global_offset->roll, local_position_ned_system_global_offset->pitch, local_position_ned_system_global_offset->yaw); +} + +/** + * @brief Send a local_position_ned_system_global_offset message + * @param chan MAVLink channel to send the message + * + * @param time_boot_ms Timestamp (milliseconds since system boot) + * @param x X Position + * @param y Y Position + * @param z Z Position + * @param roll Roll + * @param pitch Pitch + * @param yaw Yaw + */ +#ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS + +static inline void mavlink_msg_local_position_ned_system_global_offset_send(mavlink_channel_t chan, uint32_t time_boot_ms, float x, float y, float z, float roll, float pitch, float yaw) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[28]; + _mav_put_uint32_t(buf, 0, time_boot_ms); + _mav_put_float(buf, 4, x); + _mav_put_float(buf, 8, y); + _mav_put_float(buf, 12, z); + _mav_put_float(buf, 16, roll); + _mav_put_float(buf, 20, pitch); + _mav_put_float(buf, 24, yaw); + + _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_LOCAL_POSITION_NED_SYSTEM_GLOBAL_OFFSET, buf, 28, 231); +#else + mavlink_local_position_ned_system_global_offset_t packet; + packet.time_boot_ms = time_boot_ms; + packet.x = x; + packet.y = y; + packet.z = z; + packet.roll = roll; + packet.pitch = pitch; + packet.yaw = yaw; + + _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_LOCAL_POSITION_NED_SYSTEM_GLOBAL_OFFSET, (const char *)&packet, 28, 231); +#endif +} + +#endif + +// MESSAGE LOCAL_POSITION_NED_SYSTEM_GLOBAL_OFFSET UNPACKING + + +/** + * @brief Get field time_boot_ms from local_position_ned_system_global_offset message + * + * @return Timestamp (milliseconds since system boot) + */ +static inline uint32_t mavlink_msg_local_position_ned_system_global_offset_get_time_boot_ms(const mavlink_message_t* msg) +{ + return _MAV_RETURN_uint32_t(msg, 0); +} + +/** + * @brief Get field x from local_position_ned_system_global_offset message + * + * @return X Position + */ +static inline float mavlink_msg_local_position_ned_system_global_offset_get_x(const mavlink_message_t* msg) +{ + return _MAV_RETURN_float(msg, 4); +} + +/** + * @brief Get field y from local_position_ned_system_global_offset message + * + * @return Y Position + */ +static inline float mavlink_msg_local_position_ned_system_global_offset_get_y(const mavlink_message_t* msg) +{ + return _MAV_RETURN_float(msg, 8); +} + +/** + * @brief Get field z from local_position_ned_system_global_offset message + * + * @return Z Position + */ +static inline float mavlink_msg_local_position_ned_system_global_offset_get_z(const mavlink_message_t* msg) +{ + return _MAV_RETURN_float(msg, 12); +} + +/** + * @brief Get field roll from local_position_ned_system_global_offset message + * + * @return Roll + */ +static inline float mavlink_msg_local_position_ned_system_global_offset_get_roll(const mavlink_message_t* msg) +{ + return _MAV_RETURN_float(msg, 16); +} + +/** + * @brief Get field pitch from local_position_ned_system_global_offset message + * + * @return Pitch + */ +static inline float mavlink_msg_local_position_ned_system_global_offset_get_pitch(const mavlink_message_t* msg) +{ + return _MAV_RETURN_float(msg, 20); +} + +/** + * @brief Get field yaw from local_position_ned_system_global_offset message + * + * @return Yaw + */ +static inline float mavlink_msg_local_position_ned_system_global_offset_get_yaw(const mavlink_message_t* msg) +{ + return _MAV_RETURN_float(msg, 24); +} + +/** + * @brief Decode a local_position_ned_system_global_offset message into a struct + * + * @param msg The message to decode + * @param local_position_ned_system_global_offset C-struct to decode the message contents into + */ +static inline void mavlink_msg_local_position_ned_system_global_offset_decode(const mavlink_message_t* msg, mavlink_local_position_ned_system_global_offset_t* local_position_ned_system_global_offset) +{ +#if MAVLINK_NEED_BYTE_SWAP + local_position_ned_system_global_offset->time_boot_ms = mavlink_msg_local_position_ned_system_global_offset_get_time_boot_ms(msg); + local_position_ned_system_global_offset->x = mavlink_msg_local_position_ned_system_global_offset_get_x(msg); + local_position_ned_system_global_offset->y = mavlink_msg_local_position_ned_system_global_offset_get_y(msg); + local_position_ned_system_global_offset->z = mavlink_msg_local_position_ned_system_global_offset_get_z(msg); + local_position_ned_system_global_offset->roll = mavlink_msg_local_position_ned_system_global_offset_get_roll(msg); + local_position_ned_system_global_offset->pitch = mavlink_msg_local_position_ned_system_global_offset_get_pitch(msg); + local_position_ned_system_global_offset->yaw = mavlink_msg_local_position_ned_system_global_offset_get_yaw(msg); +#else + memcpy(local_position_ned_system_global_offset, _MAV_PAYLOAD(msg), 28); +#endif +} diff --git a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_local_position_setpoint.h b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_local_position_setpoint.h index 7a83b16c6..9ab87d0da 100644 --- a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_local_position_setpoint.h +++ b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_local_position_setpoint.h @@ -52,7 +52,7 @@ static inline uint16_t mavlink_msg_local_position_setpoint_pack(uint8_t system_i _mav_put_float(buf, 12, yaw); _mav_put_uint8_t(buf, 16, coordinate_frame); - memcpy(_MAV_PAYLOAD(msg), buf, 17); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 17); #else mavlink_local_position_setpoint_t packet; packet.x = x; @@ -61,7 +61,7 @@ static inline uint16_t mavlink_msg_local_position_setpoint_pack(uint8_t system_i packet.yaw = yaw; packet.coordinate_frame = coordinate_frame; - memcpy(_MAV_PAYLOAD(msg), &packet, 17); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 17); #endif msg->msgid = MAVLINK_MSG_ID_LOCAL_POSITION_SETPOINT; @@ -93,7 +93,7 @@ static inline uint16_t mavlink_msg_local_position_setpoint_pack_chan(uint8_t sys _mav_put_float(buf, 12, yaw); _mav_put_uint8_t(buf, 16, coordinate_frame); - memcpy(_MAV_PAYLOAD(msg), buf, 17); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 17); #else mavlink_local_position_setpoint_t packet; packet.x = x; @@ -102,7 +102,7 @@ static inline uint16_t mavlink_msg_local_position_setpoint_pack_chan(uint8_t sys packet.yaw = yaw; packet.coordinate_frame = coordinate_frame; - memcpy(_MAV_PAYLOAD(msg), &packet, 17); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 17); #endif msg->msgid = MAVLINK_MSG_ID_LOCAL_POSITION_SETPOINT; diff --git a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_manual_control.h b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_manual_control.h index febb4535e..96b3d3040 100644 --- a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_manual_control.h +++ b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_manual_control.h @@ -4,34 +4,28 @@ typedef struct __mavlink_manual_control_t { - float roll; ///< roll - float pitch; ///< pitch - float yaw; ///< yaw - float thrust; ///< thrust - uint8_t target; ///< The system to be controlled - uint8_t roll_manual; ///< roll control enabled auto:0, manual:1 - uint8_t pitch_manual; ///< pitch auto:0, manual:1 - uint8_t yaw_manual; ///< yaw auto:0, manual:1 - uint8_t thrust_manual; ///< thrust auto:0, manual:1 + int16_t x; ///< X-axis, normalized to the range [-1000,1000]. A value of INT16_MAX indicates that this axis is invalid. Generally corresponds to forward(1000)-backward(-1000) movement on a joystick and the pitch of a vehicle. + int16_t y; ///< Y-axis, normalized to the range [-1000,1000]. A value of INT16_MAX indicates that this axis is invalid. Generally corresponds to left(-1000)-right(1000) movement on a joystick and the roll of a vehicle. + int16_t z; ///< Z-axis, normalized to the range [-1000,1000]. A value of INT16_MAX indicates that this axis is invalid. Generally corresponds to a separate slider movement with maximum being 1000 and minimum being -1000 on a joystick and the thrust of a vehicle. + int16_t r; ///< R-axis, normalized to the range [-1000,1000]. A value of INT16_MAX indicates that this axis is invalid. Generally corresponds to a twisting of the joystick, with counter-clockwise being 1000 and clockwise being -1000, and the yaw of a vehicle. + uint16_t buttons; ///< A bitfield corresponding to the joystick buttons' current state, 1 for pressed, 0 for released. The lowest bit corresponds to Button 1. + uint8_t target; ///< The system to be controlled. } mavlink_manual_control_t; -#define MAVLINK_MSG_ID_MANUAL_CONTROL_LEN 21 -#define MAVLINK_MSG_ID_69_LEN 21 +#define MAVLINK_MSG_ID_MANUAL_CONTROL_LEN 11 +#define MAVLINK_MSG_ID_69_LEN 11 #define MAVLINK_MESSAGE_INFO_MANUAL_CONTROL { \ "MANUAL_CONTROL", \ - 9, \ - { { "roll", NULL, MAVLINK_TYPE_FLOAT, 0, 0, offsetof(mavlink_manual_control_t, roll) }, \ - { "pitch", NULL, MAVLINK_TYPE_FLOAT, 0, 4, offsetof(mavlink_manual_control_t, pitch) }, \ - { "yaw", NULL, MAVLINK_TYPE_FLOAT, 0, 8, offsetof(mavlink_manual_control_t, yaw) }, \ - { "thrust", NULL, MAVLINK_TYPE_FLOAT, 0, 12, offsetof(mavlink_manual_control_t, thrust) }, \ - { "target", NULL, MAVLINK_TYPE_UINT8_T, 0, 16, offsetof(mavlink_manual_control_t, target) }, \ - { "roll_manual", NULL, MAVLINK_TYPE_UINT8_T, 0, 17, offsetof(mavlink_manual_control_t, roll_manual) }, \ - { "pitch_manual", NULL, MAVLINK_TYPE_UINT8_T, 0, 18, offsetof(mavlink_manual_control_t, pitch_manual) }, \ - { "yaw_manual", NULL, MAVLINK_TYPE_UINT8_T, 0, 19, offsetof(mavlink_manual_control_t, yaw_manual) }, \ - { "thrust_manual", NULL, MAVLINK_TYPE_UINT8_T, 0, 20, offsetof(mavlink_manual_control_t, thrust_manual) }, \ + 6, \ + { { "x", NULL, MAVLINK_TYPE_INT16_T, 0, 0, offsetof(mavlink_manual_control_t, x) }, \ + { "y", NULL, MAVLINK_TYPE_INT16_T, 0, 2, offsetof(mavlink_manual_control_t, y) }, \ + { "z", NULL, MAVLINK_TYPE_INT16_T, 0, 4, offsetof(mavlink_manual_control_t, z) }, \ + { "r", NULL, MAVLINK_TYPE_INT16_T, 0, 6, offsetof(mavlink_manual_control_t, r) }, \ + { "buttons", NULL, MAVLINK_TYPE_UINT16_T, 0, 8, offsetof(mavlink_manual_control_t, buttons) }, \ + { "target", NULL, MAVLINK_TYPE_UINT8_T, 0, 10, offsetof(mavlink_manual_control_t, target) }, \ } \ } @@ -42,50 +36,41 @@ typedef struct __mavlink_manual_control_t * @param component_id ID of this component (e.g. 200 for IMU) * @param msg The MAVLink message to compress the data into * - * @param target The system to be controlled - * @param roll roll - * @param pitch pitch - * @param yaw yaw - * @param thrust thrust - * @param roll_manual roll control enabled auto:0, manual:1 - * @param pitch_manual pitch auto:0, manual:1 - * @param yaw_manual yaw auto:0, manual:1 - * @param thrust_manual thrust auto:0, manual:1 + * @param target The system to be controlled. + * @param x X-axis, normalized to the range [-1000,1000]. A value of INT16_MAX indicates that this axis is invalid. Generally corresponds to forward(1000)-backward(-1000) movement on a joystick and the pitch of a vehicle. + * @param y Y-axis, normalized to the range [-1000,1000]. A value of INT16_MAX indicates that this axis is invalid. Generally corresponds to left(-1000)-right(1000) movement on a joystick and the roll of a vehicle. + * @param z Z-axis, normalized to the range [-1000,1000]. A value of INT16_MAX indicates that this axis is invalid. Generally corresponds to a separate slider movement with maximum being 1000 and minimum being -1000 on a joystick and the thrust of a vehicle. + * @param r R-axis, normalized to the range [-1000,1000]. A value of INT16_MAX indicates that this axis is invalid. Generally corresponds to a twisting of the joystick, with counter-clockwise being 1000 and clockwise being -1000, and the yaw of a vehicle. + * @param buttons A bitfield corresponding to the joystick buttons' current state, 1 for pressed, 0 for released. The lowest bit corresponds to Button 1. * @return length of the message in bytes (excluding serial stream start sign) */ static inline uint16_t mavlink_msg_manual_control_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, - uint8_t target, float roll, float pitch, float yaw, float thrust, uint8_t roll_manual, uint8_t pitch_manual, uint8_t yaw_manual, uint8_t thrust_manual) + uint8_t target, int16_t x, int16_t y, int16_t z, int16_t r, uint16_t buttons) { #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS - char buf[21]; - _mav_put_float(buf, 0, roll); - _mav_put_float(buf, 4, pitch); - _mav_put_float(buf, 8, yaw); - _mav_put_float(buf, 12, thrust); - _mav_put_uint8_t(buf, 16, target); - _mav_put_uint8_t(buf, 17, roll_manual); - _mav_put_uint8_t(buf, 18, pitch_manual); - _mav_put_uint8_t(buf, 19, yaw_manual); - _mav_put_uint8_t(buf, 20, thrust_manual); + char buf[11]; + _mav_put_int16_t(buf, 0, x); + _mav_put_int16_t(buf, 2, y); + _mav_put_int16_t(buf, 4, z); + _mav_put_int16_t(buf, 6, r); + _mav_put_uint16_t(buf, 8, buttons); + _mav_put_uint8_t(buf, 10, target); - memcpy(_MAV_PAYLOAD(msg), buf, 21); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 11); #else mavlink_manual_control_t packet; - packet.roll = roll; - packet.pitch = pitch; - packet.yaw = yaw; - packet.thrust = thrust; + packet.x = x; + packet.y = y; + packet.z = z; + packet.r = r; + packet.buttons = buttons; packet.target = target; - packet.roll_manual = roll_manual; - packet.pitch_manual = pitch_manual; - packet.yaw_manual = yaw_manual; - packet.thrust_manual = thrust_manual; - memcpy(_MAV_PAYLOAD(msg), &packet, 21); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 11); #endif msg->msgid = MAVLINK_MSG_ID_MANUAL_CONTROL; - return mavlink_finalize_message(msg, system_id, component_id, 21, 52); + return mavlink_finalize_message(msg, system_id, component_id, 11, 243); } /** @@ -94,51 +79,42 @@ static inline uint16_t mavlink_msg_manual_control_pack(uint8_t system_id, uint8_ * @param component_id ID of this component (e.g. 200 for IMU) * @param chan The MAVLink channel this message was sent over * @param msg The MAVLink message to compress the data into - * @param target The system to be controlled - * @param roll roll - * @param pitch pitch - * @param yaw yaw - * @param thrust thrust - * @param roll_manual roll control enabled auto:0, manual:1 - * @param pitch_manual pitch auto:0, manual:1 - * @param yaw_manual yaw auto:0, manual:1 - * @param thrust_manual thrust auto:0, manual:1 + * @param target The system to be controlled. + * @param x X-axis, normalized to the range [-1000,1000]. A value of INT16_MAX indicates that this axis is invalid. Generally corresponds to forward(1000)-backward(-1000) movement on a joystick and the pitch of a vehicle. + * @param y Y-axis, normalized to the range [-1000,1000]. A value of INT16_MAX indicates that this axis is invalid. Generally corresponds to left(-1000)-right(1000) movement on a joystick and the roll of a vehicle. + * @param z Z-axis, normalized to the range [-1000,1000]. A value of INT16_MAX indicates that this axis is invalid. Generally corresponds to a separate slider movement with maximum being 1000 and minimum being -1000 on a joystick and the thrust of a vehicle. + * @param r R-axis, normalized to the range [-1000,1000]. A value of INT16_MAX indicates that this axis is invalid. Generally corresponds to a twisting of the joystick, with counter-clockwise being 1000 and clockwise being -1000, and the yaw of a vehicle. + * @param buttons A bitfield corresponding to the joystick buttons' current state, 1 for pressed, 0 for released. The lowest bit corresponds to Button 1. * @return length of the message in bytes (excluding serial stream start sign) */ static inline uint16_t mavlink_msg_manual_control_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, - uint8_t target,float roll,float pitch,float yaw,float thrust,uint8_t roll_manual,uint8_t pitch_manual,uint8_t yaw_manual,uint8_t thrust_manual) + uint8_t target,int16_t x,int16_t y,int16_t z,int16_t r,uint16_t buttons) { #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS - char buf[21]; - _mav_put_float(buf, 0, roll); - _mav_put_float(buf, 4, pitch); - _mav_put_float(buf, 8, yaw); - _mav_put_float(buf, 12, thrust); - _mav_put_uint8_t(buf, 16, target); - _mav_put_uint8_t(buf, 17, roll_manual); - _mav_put_uint8_t(buf, 18, pitch_manual); - _mav_put_uint8_t(buf, 19, yaw_manual); - _mav_put_uint8_t(buf, 20, thrust_manual); + char buf[11]; + _mav_put_int16_t(buf, 0, x); + _mav_put_int16_t(buf, 2, y); + _mav_put_int16_t(buf, 4, z); + _mav_put_int16_t(buf, 6, r); + _mav_put_uint16_t(buf, 8, buttons); + _mav_put_uint8_t(buf, 10, target); - memcpy(_MAV_PAYLOAD(msg), buf, 21); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 11); #else mavlink_manual_control_t packet; - packet.roll = roll; - packet.pitch = pitch; - packet.yaw = yaw; - packet.thrust = thrust; + packet.x = x; + packet.y = y; + packet.z = z; + packet.r = r; + packet.buttons = buttons; packet.target = target; - packet.roll_manual = roll_manual; - packet.pitch_manual = pitch_manual; - packet.yaw_manual = yaw_manual; - packet.thrust_manual = thrust_manual; - memcpy(_MAV_PAYLOAD(msg), &packet, 21); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 11); #endif msg->msgid = MAVLINK_MSG_ID_MANUAL_CONTROL; - return mavlink_finalize_message_chan(msg, system_id, component_id, chan, 21, 52); + return mavlink_finalize_message_chan(msg, system_id, component_id, chan, 11, 243); } /** @@ -151,53 +127,44 @@ static inline uint16_t mavlink_msg_manual_control_pack_chan(uint8_t system_id, u */ static inline uint16_t mavlink_msg_manual_control_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_manual_control_t* manual_control) { - return mavlink_msg_manual_control_pack(system_id, component_id, msg, manual_control->target, manual_control->roll, manual_control->pitch, manual_control->yaw, manual_control->thrust, manual_control->roll_manual, manual_control->pitch_manual, manual_control->yaw_manual, manual_control->thrust_manual); + return mavlink_msg_manual_control_pack(system_id, component_id, msg, manual_control->target, manual_control->x, manual_control->y, manual_control->z, manual_control->r, manual_control->buttons); } /** * @brief Send a manual_control message * @param chan MAVLink channel to send the message * - * @param target The system to be controlled - * @param roll roll - * @param pitch pitch - * @param yaw yaw - * @param thrust thrust - * @param roll_manual roll control enabled auto:0, manual:1 - * @param pitch_manual pitch auto:0, manual:1 - * @param yaw_manual yaw auto:0, manual:1 - * @param thrust_manual thrust auto:0, manual:1 + * @param target The system to be controlled. + * @param x X-axis, normalized to the range [-1000,1000]. A value of INT16_MAX indicates that this axis is invalid. Generally corresponds to forward(1000)-backward(-1000) movement on a joystick and the pitch of a vehicle. + * @param y Y-axis, normalized to the range [-1000,1000]. A value of INT16_MAX indicates that this axis is invalid. Generally corresponds to left(-1000)-right(1000) movement on a joystick and the roll of a vehicle. + * @param z Z-axis, normalized to the range [-1000,1000]. A value of INT16_MAX indicates that this axis is invalid. Generally corresponds to a separate slider movement with maximum being 1000 and minimum being -1000 on a joystick and the thrust of a vehicle. + * @param r R-axis, normalized to the range [-1000,1000]. A value of INT16_MAX indicates that this axis is invalid. Generally corresponds to a twisting of the joystick, with counter-clockwise being 1000 and clockwise being -1000, and the yaw of a vehicle. + * @param buttons A bitfield corresponding to the joystick buttons' current state, 1 for pressed, 0 for released. The lowest bit corresponds to Button 1. */ #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS -static inline void mavlink_msg_manual_control_send(mavlink_channel_t chan, uint8_t target, float roll, float pitch, float yaw, float thrust, uint8_t roll_manual, uint8_t pitch_manual, uint8_t yaw_manual, uint8_t thrust_manual) +static inline void mavlink_msg_manual_control_send(mavlink_channel_t chan, uint8_t target, int16_t x, int16_t y, int16_t z, int16_t r, uint16_t buttons) { #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS - char buf[21]; - _mav_put_float(buf, 0, roll); - _mav_put_float(buf, 4, pitch); - _mav_put_float(buf, 8, yaw); - _mav_put_float(buf, 12, thrust); - _mav_put_uint8_t(buf, 16, target); - _mav_put_uint8_t(buf, 17, roll_manual); - _mav_put_uint8_t(buf, 18, pitch_manual); - _mav_put_uint8_t(buf, 19, yaw_manual); - _mav_put_uint8_t(buf, 20, thrust_manual); + char buf[11]; + _mav_put_int16_t(buf, 0, x); + _mav_put_int16_t(buf, 2, y); + _mav_put_int16_t(buf, 4, z); + _mav_put_int16_t(buf, 6, r); + _mav_put_uint16_t(buf, 8, buttons); + _mav_put_uint8_t(buf, 10, target); - _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_MANUAL_CONTROL, buf, 21, 52); + _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_MANUAL_CONTROL, buf, 11, 243); #else mavlink_manual_control_t packet; - packet.roll = roll; - packet.pitch = pitch; - packet.yaw = yaw; - packet.thrust = thrust; + packet.x = x; + packet.y = y; + packet.z = z; + packet.r = r; + packet.buttons = buttons; packet.target = target; - packet.roll_manual = roll_manual; - packet.pitch_manual = pitch_manual; - packet.yaw_manual = yaw_manual; - packet.thrust_manual = thrust_manual; - _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_MANUAL_CONTROL, (const char *)&packet, 21, 52); + _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_MANUAL_CONTROL, (const char *)&packet, 11, 243); #endif } @@ -209,91 +176,61 @@ static inline void mavlink_msg_manual_control_send(mavlink_channel_t chan, uint8 /** * @brief Get field target from manual_control message * - * @return The system to be controlled + * @return The system to be controlled. */ static inline uint8_t mavlink_msg_manual_control_get_target(const mavlink_message_t* msg) { - return _MAV_RETURN_uint8_t(msg, 16); + return _MAV_RETURN_uint8_t(msg, 10); } /** - * @brief Get field roll from manual_control message + * @brief Get field x from manual_control message * - * @return roll + * @return X-axis, normalized to the range [-1000,1000]. A value of INT16_MAX indicates that this axis is invalid. Generally corresponds to forward(1000)-backward(-1000) movement on a joystick and the pitch of a vehicle. */ -static inline float mavlink_msg_manual_control_get_roll(const mavlink_message_t* msg) +static inline int16_t mavlink_msg_manual_control_get_x(const mavlink_message_t* msg) { - return _MAV_RETURN_float(msg, 0); + return _MAV_RETURN_int16_t(msg, 0); } /** - * @brief Get field pitch from manual_control message + * @brief Get field y from manual_control message * - * @return pitch + * @return Y-axis, normalized to the range [-1000,1000]. A value of INT16_MAX indicates that this axis is invalid. Generally corresponds to left(-1000)-right(1000) movement on a joystick and the roll of a vehicle. */ -static inline float mavlink_msg_manual_control_get_pitch(const mavlink_message_t* msg) +static inline int16_t mavlink_msg_manual_control_get_y(const mavlink_message_t* msg) { - return _MAV_RETURN_float(msg, 4); + return _MAV_RETURN_int16_t(msg, 2); } /** - * @brief Get field yaw from manual_control message + * @brief Get field z from manual_control message * - * @return yaw + * @return Z-axis, normalized to the range [-1000,1000]. A value of INT16_MAX indicates that this axis is invalid. Generally corresponds to a separate slider movement with maximum being 1000 and minimum being -1000 on a joystick and the thrust of a vehicle. */ -static inline float mavlink_msg_manual_control_get_yaw(const mavlink_message_t* msg) +static inline int16_t mavlink_msg_manual_control_get_z(const mavlink_message_t* msg) { - return _MAV_RETURN_float(msg, 8); + return _MAV_RETURN_int16_t(msg, 4); } /** - * @brief Get field thrust from manual_control message + * @brief Get field r from manual_control message * - * @return thrust + * @return R-axis, normalized to the range [-1000,1000]. A value of INT16_MAX indicates that this axis is invalid. Generally corresponds to a twisting of the joystick, with counter-clockwise being 1000 and clockwise being -1000, and the yaw of a vehicle. */ -static inline float mavlink_msg_manual_control_get_thrust(const mavlink_message_t* msg) +static inline int16_t mavlink_msg_manual_control_get_r(const mavlink_message_t* msg) { - return _MAV_RETURN_float(msg, 12); + return _MAV_RETURN_int16_t(msg, 6); } /** - * @brief Get field roll_manual from manual_control message + * @brief Get field buttons from manual_control message * - * @return roll control enabled auto:0, manual:1 + * @return A bitfield corresponding to the joystick buttons' current state, 1 for pressed, 0 for released. The lowest bit corresponds to Button 1. */ -static inline uint8_t mavlink_msg_manual_control_get_roll_manual(const mavlink_message_t* msg) +static inline uint16_t mavlink_msg_manual_control_get_buttons(const mavlink_message_t* msg) { - return _MAV_RETURN_uint8_t(msg, 17); -} - -/** - * @brief Get field pitch_manual from manual_control message - * - * @return pitch auto:0, manual:1 - */ -static inline uint8_t mavlink_msg_manual_control_get_pitch_manual(const mavlink_message_t* msg) -{ - return _MAV_RETURN_uint8_t(msg, 18); -} - -/** - * @brief Get field yaw_manual from manual_control message - * - * @return yaw auto:0, manual:1 - */ -static inline uint8_t mavlink_msg_manual_control_get_yaw_manual(const mavlink_message_t* msg) -{ - return _MAV_RETURN_uint8_t(msg, 19); -} - -/** - * @brief Get field thrust_manual from manual_control message - * - * @return thrust auto:0, manual:1 - */ -static inline uint8_t mavlink_msg_manual_control_get_thrust_manual(const mavlink_message_t* msg) -{ - return _MAV_RETURN_uint8_t(msg, 20); + return _MAV_RETURN_uint16_t(msg, 8); } /** @@ -305,16 +242,13 @@ static inline uint8_t mavlink_msg_manual_control_get_thrust_manual(const mavlink static inline void mavlink_msg_manual_control_decode(const mavlink_message_t* msg, mavlink_manual_control_t* manual_control) { #if MAVLINK_NEED_BYTE_SWAP - manual_control->roll = mavlink_msg_manual_control_get_roll(msg); - manual_control->pitch = mavlink_msg_manual_control_get_pitch(msg); - manual_control->yaw = mavlink_msg_manual_control_get_yaw(msg); - manual_control->thrust = mavlink_msg_manual_control_get_thrust(msg); + manual_control->x = mavlink_msg_manual_control_get_x(msg); + manual_control->y = mavlink_msg_manual_control_get_y(msg); + manual_control->z = mavlink_msg_manual_control_get_z(msg); + manual_control->r = mavlink_msg_manual_control_get_r(msg); + manual_control->buttons = mavlink_msg_manual_control_get_buttons(msg); manual_control->target = mavlink_msg_manual_control_get_target(msg); - manual_control->roll_manual = mavlink_msg_manual_control_get_roll_manual(msg); - manual_control->pitch_manual = mavlink_msg_manual_control_get_pitch_manual(msg); - manual_control->yaw_manual = mavlink_msg_manual_control_get_yaw_manual(msg); - manual_control->thrust_manual = mavlink_msg_manual_control_get_thrust_manual(msg); #else - memcpy(manual_control, _MAV_PAYLOAD(msg), 21); + memcpy(manual_control, _MAV_PAYLOAD(msg), 11); #endif } diff --git a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_manual_setpoint.h b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_manual_setpoint.h new file mode 100644 index 000000000..71db380a1 --- /dev/null +++ b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_manual_setpoint.h @@ -0,0 +1,276 @@ +// MESSAGE MANUAL_SETPOINT PACKING + +#define MAVLINK_MSG_ID_MANUAL_SETPOINT 81 + +typedef struct __mavlink_manual_setpoint_t +{ + uint32_t time_boot_ms; ///< Timestamp in milliseconds since system boot + float roll; ///< Desired roll rate in radians per second + float pitch; ///< Desired pitch rate in radians per second + float yaw; ///< Desired yaw rate in radians per second + float thrust; ///< Collective thrust, normalized to 0 .. 1 + uint8_t mode_switch; ///< Flight mode switch position, 0.. 255 + uint8_t manual_override_switch; ///< Override mode switch position, 0.. 255 +} mavlink_manual_setpoint_t; + +#define MAVLINK_MSG_ID_MANUAL_SETPOINT_LEN 22 +#define MAVLINK_MSG_ID_81_LEN 22 + + + +#define MAVLINK_MESSAGE_INFO_MANUAL_SETPOINT { \ + "MANUAL_SETPOINT", \ + 7, \ + { { "time_boot_ms", NULL, MAVLINK_TYPE_UINT32_T, 0, 0, offsetof(mavlink_manual_setpoint_t, time_boot_ms) }, \ + { "roll", NULL, MAVLINK_TYPE_FLOAT, 0, 4, offsetof(mavlink_manual_setpoint_t, roll) }, \ + { "pitch", NULL, MAVLINK_TYPE_FLOAT, 0, 8, offsetof(mavlink_manual_setpoint_t, pitch) }, \ + { "yaw", NULL, MAVLINK_TYPE_FLOAT, 0, 12, offsetof(mavlink_manual_setpoint_t, yaw) }, \ + { "thrust", NULL, MAVLINK_TYPE_FLOAT, 0, 16, offsetof(mavlink_manual_setpoint_t, thrust) }, \ + { "mode_switch", NULL, MAVLINK_TYPE_UINT8_T, 0, 20, offsetof(mavlink_manual_setpoint_t, mode_switch) }, \ + { "manual_override_switch", NULL, MAVLINK_TYPE_UINT8_T, 0, 21, offsetof(mavlink_manual_setpoint_t, manual_override_switch) }, \ + } \ +} + + +/** + * @brief Pack a manual_setpoint message + * @param system_id ID of this system + * @param component_id ID of this component (e.g. 200 for IMU) + * @param msg The MAVLink message to compress the data into + * + * @param time_boot_ms Timestamp in milliseconds since system boot + * @param roll Desired roll rate in radians per second + * @param pitch Desired pitch rate in radians per second + * @param yaw Desired yaw rate in radians per second + * @param thrust Collective thrust, normalized to 0 .. 1 + * @param mode_switch Flight mode switch position, 0.. 255 + * @param manual_override_switch Override mode switch position, 0.. 255 + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_manual_setpoint_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, + uint32_t time_boot_ms, float roll, float pitch, float yaw, float thrust, uint8_t mode_switch, uint8_t manual_override_switch) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[22]; + _mav_put_uint32_t(buf, 0, time_boot_ms); + _mav_put_float(buf, 4, roll); + _mav_put_float(buf, 8, pitch); + _mav_put_float(buf, 12, yaw); + _mav_put_float(buf, 16, thrust); + _mav_put_uint8_t(buf, 20, mode_switch); + _mav_put_uint8_t(buf, 21, manual_override_switch); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 22); +#else + mavlink_manual_setpoint_t packet; + packet.time_boot_ms = time_boot_ms; + packet.roll = roll; + packet.pitch = pitch; + packet.yaw = yaw; + packet.thrust = thrust; + packet.mode_switch = mode_switch; + packet.manual_override_switch = manual_override_switch; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 22); +#endif + + msg->msgid = MAVLINK_MSG_ID_MANUAL_SETPOINT; + return mavlink_finalize_message(msg, system_id, component_id, 22, 106); +} + +/** + * @brief Pack a manual_setpoint message on a channel + * @param system_id ID of this system + * @param component_id ID of this component (e.g. 200 for IMU) + * @param chan The MAVLink channel this message was sent over + * @param msg The MAVLink message to compress the data into + * @param time_boot_ms Timestamp in milliseconds since system boot + * @param roll Desired roll rate in radians per second + * @param pitch Desired pitch rate in radians per second + * @param yaw Desired yaw rate in radians per second + * @param thrust Collective thrust, normalized to 0 .. 1 + * @param mode_switch Flight mode switch position, 0.. 255 + * @param manual_override_switch Override mode switch position, 0.. 255 + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_manual_setpoint_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, + mavlink_message_t* msg, + uint32_t time_boot_ms,float roll,float pitch,float yaw,float thrust,uint8_t mode_switch,uint8_t manual_override_switch) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[22]; + _mav_put_uint32_t(buf, 0, time_boot_ms); + _mav_put_float(buf, 4, roll); + _mav_put_float(buf, 8, pitch); + _mav_put_float(buf, 12, yaw); + _mav_put_float(buf, 16, thrust); + _mav_put_uint8_t(buf, 20, mode_switch); + _mav_put_uint8_t(buf, 21, manual_override_switch); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 22); +#else + mavlink_manual_setpoint_t packet; + packet.time_boot_ms = time_boot_ms; + packet.roll = roll; + packet.pitch = pitch; + packet.yaw = yaw; + packet.thrust = thrust; + packet.mode_switch = mode_switch; + packet.manual_override_switch = manual_override_switch; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 22); +#endif + + msg->msgid = MAVLINK_MSG_ID_MANUAL_SETPOINT; + return mavlink_finalize_message_chan(msg, system_id, component_id, chan, 22, 106); +} + +/** + * @brief Encode a manual_setpoint struct into a message + * + * @param system_id ID of this system + * @param component_id ID of this component (e.g. 200 for IMU) + * @param msg The MAVLink message to compress the data into + * @param manual_setpoint C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_manual_setpoint_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_manual_setpoint_t* manual_setpoint) +{ + return mavlink_msg_manual_setpoint_pack(system_id, component_id, msg, manual_setpoint->time_boot_ms, manual_setpoint->roll, manual_setpoint->pitch, manual_setpoint->yaw, manual_setpoint->thrust, manual_setpoint->mode_switch, manual_setpoint->manual_override_switch); +} + +/** + * @brief Send a manual_setpoint message + * @param chan MAVLink channel to send the message + * + * @param time_boot_ms Timestamp in milliseconds since system boot + * @param roll Desired roll rate in radians per second + * @param pitch Desired pitch rate in radians per second + * @param yaw Desired yaw rate in radians per second + * @param thrust Collective thrust, normalized to 0 .. 1 + * @param mode_switch Flight mode switch position, 0.. 255 + * @param manual_override_switch Override mode switch position, 0.. 255 + */ +#ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS + +static inline void mavlink_msg_manual_setpoint_send(mavlink_channel_t chan, uint32_t time_boot_ms, float roll, float pitch, float yaw, float thrust, uint8_t mode_switch, uint8_t manual_override_switch) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[22]; + _mav_put_uint32_t(buf, 0, time_boot_ms); + _mav_put_float(buf, 4, roll); + _mav_put_float(buf, 8, pitch); + _mav_put_float(buf, 12, yaw); + _mav_put_float(buf, 16, thrust); + _mav_put_uint8_t(buf, 20, mode_switch); + _mav_put_uint8_t(buf, 21, manual_override_switch); + + _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_MANUAL_SETPOINT, buf, 22, 106); +#else + mavlink_manual_setpoint_t packet; + packet.time_boot_ms = time_boot_ms; + packet.roll = roll; + packet.pitch = pitch; + packet.yaw = yaw; + packet.thrust = thrust; + packet.mode_switch = mode_switch; + packet.manual_override_switch = manual_override_switch; + + _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_MANUAL_SETPOINT, (const char *)&packet, 22, 106); +#endif +} + +#endif + +// MESSAGE MANUAL_SETPOINT UNPACKING + + +/** + * @brief Get field time_boot_ms from manual_setpoint message + * + * @return Timestamp in milliseconds since system boot + */ +static inline uint32_t mavlink_msg_manual_setpoint_get_time_boot_ms(const mavlink_message_t* msg) +{ + return _MAV_RETURN_uint32_t(msg, 0); +} + +/** + * @brief Get field roll from manual_setpoint message + * + * @return Desired roll rate in radians per second + */ +static inline float mavlink_msg_manual_setpoint_get_roll(const mavlink_message_t* msg) +{ + return _MAV_RETURN_float(msg, 4); +} + +/** + * @brief Get field pitch from manual_setpoint message + * + * @return Desired pitch rate in radians per second + */ +static inline float mavlink_msg_manual_setpoint_get_pitch(const mavlink_message_t* msg) +{ + return _MAV_RETURN_float(msg, 8); +} + +/** + * @brief Get field yaw from manual_setpoint message + * + * @return Desired yaw rate in radians per second + */ +static inline float mavlink_msg_manual_setpoint_get_yaw(const mavlink_message_t* msg) +{ + return _MAV_RETURN_float(msg, 12); +} + +/** + * @brief Get field thrust from manual_setpoint message + * + * @return Collective thrust, normalized to 0 .. 1 + */ +static inline float mavlink_msg_manual_setpoint_get_thrust(const mavlink_message_t* msg) +{ + return _MAV_RETURN_float(msg, 16); +} + +/** + * @brief Get field mode_switch from manual_setpoint message + * + * @return Flight mode switch position, 0.. 255 + */ +static inline uint8_t mavlink_msg_manual_setpoint_get_mode_switch(const mavlink_message_t* msg) +{ + return _MAV_RETURN_uint8_t(msg, 20); +} + +/** + * @brief Get field manual_override_switch from manual_setpoint message + * + * @return Override mode switch position, 0.. 255 + */ +static inline uint8_t mavlink_msg_manual_setpoint_get_manual_override_switch(const mavlink_message_t* msg) +{ + return _MAV_RETURN_uint8_t(msg, 21); +} + +/** + * @brief Decode a manual_setpoint message into a struct + * + * @param msg The message to decode + * @param manual_setpoint C-struct to decode the message contents into + */ +static inline void mavlink_msg_manual_setpoint_decode(const mavlink_message_t* msg, mavlink_manual_setpoint_t* manual_setpoint) +{ +#if MAVLINK_NEED_BYTE_SWAP + manual_setpoint->time_boot_ms = mavlink_msg_manual_setpoint_get_time_boot_ms(msg); + manual_setpoint->roll = mavlink_msg_manual_setpoint_get_roll(msg); + manual_setpoint->pitch = mavlink_msg_manual_setpoint_get_pitch(msg); + manual_setpoint->yaw = mavlink_msg_manual_setpoint_get_yaw(msg); + manual_setpoint->thrust = mavlink_msg_manual_setpoint_get_thrust(msg); + manual_setpoint->mode_switch = mavlink_msg_manual_setpoint_get_mode_switch(msg); + manual_setpoint->manual_override_switch = mavlink_msg_manual_setpoint_get_manual_override_switch(msg); +#else + memcpy(manual_setpoint, _MAV_PAYLOAD(msg), 22); +#endif +} diff --git a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_memory_vect.h b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_memory_vect.h index e59db361a..a61c13019 100644 --- a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_memory_vect.h +++ b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_memory_vect.h @@ -47,14 +47,14 @@ static inline uint16_t mavlink_msg_memory_vect_pack(uint8_t system_id, uint8_t c _mav_put_uint8_t(buf, 2, ver); _mav_put_uint8_t(buf, 3, type); _mav_put_int8_t_array(buf, 4, value, 32); - memcpy(_MAV_PAYLOAD(msg), buf, 36); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 36); #else mavlink_memory_vect_t packet; packet.address = address; packet.ver = ver; packet.type = type; mav_array_memcpy(packet.value, value, sizeof(int8_t)*32); - memcpy(_MAV_PAYLOAD(msg), &packet, 36); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 36); #endif msg->msgid = MAVLINK_MSG_ID_MEMORY_VECT; @@ -83,14 +83,14 @@ static inline uint16_t mavlink_msg_memory_vect_pack_chan(uint8_t system_id, uint _mav_put_uint8_t(buf, 2, ver); _mav_put_uint8_t(buf, 3, type); _mav_put_int8_t_array(buf, 4, value, 32); - memcpy(_MAV_PAYLOAD(msg), buf, 36); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 36); #else mavlink_memory_vect_t packet; packet.address = address; packet.ver = ver; packet.type = type; mav_array_memcpy(packet.value, value, sizeof(int8_t)*32); - memcpy(_MAV_PAYLOAD(msg), &packet, 36); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 36); #endif msg->msgid = MAVLINK_MSG_ID_MEMORY_VECT; diff --git a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_mission_ack.h b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_mission_ack.h index 1696e7658..92eca79d1 100644 --- a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_mission_ack.h +++ b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_mission_ack.h @@ -44,14 +44,14 @@ static inline uint16_t mavlink_msg_mission_ack_pack(uint8_t system_id, uint8_t c _mav_put_uint8_t(buf, 1, target_component); _mav_put_uint8_t(buf, 2, type); - memcpy(_MAV_PAYLOAD(msg), buf, 3); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 3); #else mavlink_mission_ack_t packet; packet.target_system = target_system; packet.target_component = target_component; packet.type = type; - memcpy(_MAV_PAYLOAD(msg), &packet, 3); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 3); #endif msg->msgid = MAVLINK_MSG_ID_MISSION_ACK; @@ -79,14 +79,14 @@ static inline uint16_t mavlink_msg_mission_ack_pack_chan(uint8_t system_id, uint _mav_put_uint8_t(buf, 1, target_component); _mav_put_uint8_t(buf, 2, type); - memcpy(_MAV_PAYLOAD(msg), buf, 3); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 3); #else mavlink_mission_ack_t packet; packet.target_system = target_system; packet.target_component = target_component; packet.type = type; - memcpy(_MAV_PAYLOAD(msg), &packet, 3); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 3); #endif msg->msgid = MAVLINK_MSG_ID_MISSION_ACK; diff --git a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_mission_clear_all.h b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_mission_clear_all.h index c421f5789..602852f7e 100644 --- a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_mission_clear_all.h +++ b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_mission_clear_all.h @@ -40,13 +40,13 @@ static inline uint16_t mavlink_msg_mission_clear_all_pack(uint8_t system_id, uin _mav_put_uint8_t(buf, 0, target_system); _mav_put_uint8_t(buf, 1, target_component); - memcpy(_MAV_PAYLOAD(msg), buf, 2); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 2); #else mavlink_mission_clear_all_t packet; packet.target_system = target_system; packet.target_component = target_component; - memcpy(_MAV_PAYLOAD(msg), &packet, 2); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 2); #endif msg->msgid = MAVLINK_MSG_ID_MISSION_CLEAR_ALL; @@ -72,13 +72,13 @@ static inline uint16_t mavlink_msg_mission_clear_all_pack_chan(uint8_t system_id _mav_put_uint8_t(buf, 0, target_system); _mav_put_uint8_t(buf, 1, target_component); - memcpy(_MAV_PAYLOAD(msg), buf, 2); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 2); #else mavlink_mission_clear_all_t packet; packet.target_system = target_system; packet.target_component = target_component; - memcpy(_MAV_PAYLOAD(msg), &packet, 2); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 2); #endif msg->msgid = MAVLINK_MSG_ID_MISSION_CLEAR_ALL; diff --git a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_mission_count.h b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_mission_count.h index 967071d8c..61d8b221c 100644 --- a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_mission_count.h +++ b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_mission_count.h @@ -44,14 +44,14 @@ static inline uint16_t mavlink_msg_mission_count_pack(uint8_t system_id, uint8_t _mav_put_uint8_t(buf, 2, target_system); _mav_put_uint8_t(buf, 3, target_component); - memcpy(_MAV_PAYLOAD(msg), buf, 4); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 4); #else mavlink_mission_count_t packet; packet.count = count; packet.target_system = target_system; packet.target_component = target_component; - memcpy(_MAV_PAYLOAD(msg), &packet, 4); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 4); #endif msg->msgid = MAVLINK_MSG_ID_MISSION_COUNT; @@ -79,14 +79,14 @@ static inline uint16_t mavlink_msg_mission_count_pack_chan(uint8_t system_id, ui _mav_put_uint8_t(buf, 2, target_system); _mav_put_uint8_t(buf, 3, target_component); - memcpy(_MAV_PAYLOAD(msg), buf, 4); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 4); #else mavlink_mission_count_t packet; packet.count = count; packet.target_system = target_system; packet.target_component = target_component; - memcpy(_MAV_PAYLOAD(msg), &packet, 4); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 4); #endif msg->msgid = MAVLINK_MSG_ID_MISSION_COUNT; diff --git a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_mission_current.h b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_mission_current.h index 2ad9fbc60..99370f835 100644 --- a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_mission_current.h +++ b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_mission_current.h @@ -36,12 +36,12 @@ static inline uint16_t mavlink_msg_mission_current_pack(uint8_t system_id, uint8 char buf[2]; _mav_put_uint16_t(buf, 0, seq); - memcpy(_MAV_PAYLOAD(msg), buf, 2); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 2); #else mavlink_mission_current_t packet; packet.seq = seq; - memcpy(_MAV_PAYLOAD(msg), &packet, 2); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 2); #endif msg->msgid = MAVLINK_MSG_ID_MISSION_CURRENT; @@ -65,12 +65,12 @@ static inline uint16_t mavlink_msg_mission_current_pack_chan(uint8_t system_id, char buf[2]; _mav_put_uint16_t(buf, 0, seq); - memcpy(_MAV_PAYLOAD(msg), buf, 2); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 2); #else mavlink_mission_current_t packet; packet.seq = seq; - memcpy(_MAV_PAYLOAD(msg), &packet, 2); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 2); #endif msg->msgid = MAVLINK_MSG_ID_MISSION_CURRENT; diff --git a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_mission_item.h b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_mission_item.h index e2d894aee..d2c66d4da 100644 --- a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_mission_item.h +++ b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_mission_item.h @@ -88,7 +88,7 @@ static inline uint16_t mavlink_msg_mission_item_pack(uint8_t system_id, uint8_t _mav_put_uint8_t(buf, 35, current); _mav_put_uint8_t(buf, 36, autocontinue); - memcpy(_MAV_PAYLOAD(msg), buf, 37); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 37); #else mavlink_mission_item_t packet; packet.param1 = param1; @@ -106,7 +106,7 @@ static inline uint16_t mavlink_msg_mission_item_pack(uint8_t system_id, uint8_t packet.current = current; packet.autocontinue = autocontinue; - memcpy(_MAV_PAYLOAD(msg), &packet, 37); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 37); #endif msg->msgid = MAVLINK_MSG_ID_MISSION_ITEM; @@ -156,7 +156,7 @@ static inline uint16_t mavlink_msg_mission_item_pack_chan(uint8_t system_id, uin _mav_put_uint8_t(buf, 35, current); _mav_put_uint8_t(buf, 36, autocontinue); - memcpy(_MAV_PAYLOAD(msg), buf, 37); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 37); #else mavlink_mission_item_t packet; packet.param1 = param1; @@ -174,7 +174,7 @@ static inline uint16_t mavlink_msg_mission_item_pack_chan(uint8_t system_id, uin packet.current = current; packet.autocontinue = autocontinue; - memcpy(_MAV_PAYLOAD(msg), &packet, 37); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 37); #endif msg->msgid = MAVLINK_MSG_ID_MISSION_ITEM; diff --git a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_mission_item_reached.h b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_mission_item_reached.h index 7d935cade..171f9857e 100644 --- a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_mission_item_reached.h +++ b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_mission_item_reached.h @@ -36,12 +36,12 @@ static inline uint16_t mavlink_msg_mission_item_reached_pack(uint8_t system_id, char buf[2]; _mav_put_uint16_t(buf, 0, seq); - memcpy(_MAV_PAYLOAD(msg), buf, 2); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 2); #else mavlink_mission_item_reached_t packet; packet.seq = seq; - memcpy(_MAV_PAYLOAD(msg), &packet, 2); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 2); #endif msg->msgid = MAVLINK_MSG_ID_MISSION_ITEM_REACHED; @@ -65,12 +65,12 @@ static inline uint16_t mavlink_msg_mission_item_reached_pack_chan(uint8_t system char buf[2]; _mav_put_uint16_t(buf, 0, seq); - memcpy(_MAV_PAYLOAD(msg), buf, 2); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 2); #else mavlink_mission_item_reached_t packet; packet.seq = seq; - memcpy(_MAV_PAYLOAD(msg), &packet, 2); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 2); #endif msg->msgid = MAVLINK_MSG_ID_MISSION_ITEM_REACHED; diff --git a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_mission_request.h b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_mission_request.h index 5fb55ddb6..cde0a0cfb 100644 --- a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_mission_request.h +++ b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_mission_request.h @@ -44,14 +44,14 @@ static inline uint16_t mavlink_msg_mission_request_pack(uint8_t system_id, uint8 _mav_put_uint8_t(buf, 2, target_system); _mav_put_uint8_t(buf, 3, target_component); - memcpy(_MAV_PAYLOAD(msg), buf, 4); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 4); #else mavlink_mission_request_t packet; packet.seq = seq; packet.target_system = target_system; packet.target_component = target_component; - memcpy(_MAV_PAYLOAD(msg), &packet, 4); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 4); #endif msg->msgid = MAVLINK_MSG_ID_MISSION_REQUEST; @@ -79,14 +79,14 @@ static inline uint16_t mavlink_msg_mission_request_pack_chan(uint8_t system_id, _mav_put_uint8_t(buf, 2, target_system); _mav_put_uint8_t(buf, 3, target_component); - memcpy(_MAV_PAYLOAD(msg), buf, 4); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 4); #else mavlink_mission_request_t packet; packet.seq = seq; packet.target_system = target_system; packet.target_component = target_component; - memcpy(_MAV_PAYLOAD(msg), &packet, 4); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 4); #endif msg->msgid = MAVLINK_MSG_ID_MISSION_REQUEST; diff --git a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_mission_request_list.h b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_mission_request_list.h index c41d0fa0b..1ada635b5 100644 --- a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_mission_request_list.h +++ b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_mission_request_list.h @@ -40,13 +40,13 @@ static inline uint16_t mavlink_msg_mission_request_list_pack(uint8_t system_id, _mav_put_uint8_t(buf, 0, target_system); _mav_put_uint8_t(buf, 1, target_component); - memcpy(_MAV_PAYLOAD(msg), buf, 2); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 2); #else mavlink_mission_request_list_t packet; packet.target_system = target_system; packet.target_component = target_component; - memcpy(_MAV_PAYLOAD(msg), &packet, 2); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 2); #endif msg->msgid = MAVLINK_MSG_ID_MISSION_REQUEST_LIST; @@ -72,13 +72,13 @@ static inline uint16_t mavlink_msg_mission_request_list_pack_chan(uint8_t system _mav_put_uint8_t(buf, 0, target_system); _mav_put_uint8_t(buf, 1, target_component); - memcpy(_MAV_PAYLOAD(msg), buf, 2); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 2); #else mavlink_mission_request_list_t packet; packet.target_system = target_system; packet.target_component = target_component; - memcpy(_MAV_PAYLOAD(msg), &packet, 2); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 2); #endif msg->msgid = MAVLINK_MSG_ID_MISSION_REQUEST_LIST; diff --git a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_mission_request_partial_list.h b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_mission_request_partial_list.h index 92e0ea745..76fd43bef 100644 --- a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_mission_request_partial_list.h +++ b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_mission_request_partial_list.h @@ -48,7 +48,7 @@ static inline uint16_t mavlink_msg_mission_request_partial_list_pack(uint8_t sys _mav_put_uint8_t(buf, 4, target_system); _mav_put_uint8_t(buf, 5, target_component); - memcpy(_MAV_PAYLOAD(msg), buf, 6); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 6); #else mavlink_mission_request_partial_list_t packet; packet.start_index = start_index; @@ -56,7 +56,7 @@ static inline uint16_t mavlink_msg_mission_request_partial_list_pack(uint8_t sys packet.target_system = target_system; packet.target_component = target_component; - memcpy(_MAV_PAYLOAD(msg), &packet, 6); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 6); #endif msg->msgid = MAVLINK_MSG_ID_MISSION_REQUEST_PARTIAL_LIST; @@ -86,7 +86,7 @@ static inline uint16_t mavlink_msg_mission_request_partial_list_pack_chan(uint8_ _mav_put_uint8_t(buf, 4, target_system); _mav_put_uint8_t(buf, 5, target_component); - memcpy(_MAV_PAYLOAD(msg), buf, 6); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 6); #else mavlink_mission_request_partial_list_t packet; packet.start_index = start_index; @@ -94,7 +94,7 @@ static inline uint16_t mavlink_msg_mission_request_partial_list_pack_chan(uint8_ packet.target_system = target_system; packet.target_component = target_component; - memcpy(_MAV_PAYLOAD(msg), &packet, 6); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 6); #endif msg->msgid = MAVLINK_MSG_ID_MISSION_REQUEST_PARTIAL_LIST; diff --git a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_mission_set_current.h b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_mission_set_current.h index 6fb6fd1cc..de0dbcd75 100644 --- a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_mission_set_current.h +++ b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_mission_set_current.h @@ -44,14 +44,14 @@ static inline uint16_t mavlink_msg_mission_set_current_pack(uint8_t system_id, u _mav_put_uint8_t(buf, 2, target_system); _mav_put_uint8_t(buf, 3, target_component); - memcpy(_MAV_PAYLOAD(msg), buf, 4); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 4); #else mavlink_mission_set_current_t packet; packet.seq = seq; packet.target_system = target_system; packet.target_component = target_component; - memcpy(_MAV_PAYLOAD(msg), &packet, 4); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 4); #endif msg->msgid = MAVLINK_MSG_ID_MISSION_SET_CURRENT; @@ -79,14 +79,14 @@ static inline uint16_t mavlink_msg_mission_set_current_pack_chan(uint8_t system_ _mav_put_uint8_t(buf, 2, target_system); _mav_put_uint8_t(buf, 3, target_component); - memcpy(_MAV_PAYLOAD(msg), buf, 4); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 4); #else mavlink_mission_set_current_t packet; packet.seq = seq; packet.target_system = target_system; packet.target_component = target_component; - memcpy(_MAV_PAYLOAD(msg), &packet, 4); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 4); #endif msg->msgid = MAVLINK_MSG_ID_MISSION_SET_CURRENT; diff --git a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_mission_write_partial_list.h b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_mission_write_partial_list.h index 59f438de2..0e77569cf 100644 --- a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_mission_write_partial_list.h +++ b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_mission_write_partial_list.h @@ -48,7 +48,7 @@ static inline uint16_t mavlink_msg_mission_write_partial_list_pack(uint8_t syste _mav_put_uint8_t(buf, 4, target_system); _mav_put_uint8_t(buf, 5, target_component); - memcpy(_MAV_PAYLOAD(msg), buf, 6); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 6); #else mavlink_mission_write_partial_list_t packet; packet.start_index = start_index; @@ -56,7 +56,7 @@ static inline uint16_t mavlink_msg_mission_write_partial_list_pack(uint8_t syste packet.target_system = target_system; packet.target_component = target_component; - memcpy(_MAV_PAYLOAD(msg), &packet, 6); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 6); #endif msg->msgid = MAVLINK_MSG_ID_MISSION_WRITE_PARTIAL_LIST; @@ -86,7 +86,7 @@ static inline uint16_t mavlink_msg_mission_write_partial_list_pack_chan(uint8_t _mav_put_uint8_t(buf, 4, target_system); _mav_put_uint8_t(buf, 5, target_component); - memcpy(_MAV_PAYLOAD(msg), buf, 6); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 6); #else mavlink_mission_write_partial_list_t packet; packet.start_index = start_index; @@ -94,7 +94,7 @@ static inline uint16_t mavlink_msg_mission_write_partial_list_pack_chan(uint8_t packet.target_system = target_system; packet.target_component = target_component; - memcpy(_MAV_PAYLOAD(msg), &packet, 6); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 6); #endif msg->msgid = MAVLINK_MSG_ID_MISSION_WRITE_PARTIAL_LIST; diff --git a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_named_value_float.h b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_named_value_float.h index feabb8f31..23a819e2c 100644 --- a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_named_value_float.h +++ b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_named_value_float.h @@ -43,13 +43,13 @@ static inline uint16_t mavlink_msg_named_value_float_pack(uint8_t system_id, uin _mav_put_uint32_t(buf, 0, time_boot_ms); _mav_put_float(buf, 4, value); _mav_put_char_array(buf, 8, name, 10); - memcpy(_MAV_PAYLOAD(msg), buf, 18); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 18); #else mavlink_named_value_float_t packet; packet.time_boot_ms = time_boot_ms; packet.value = value; mav_array_memcpy(packet.name, name, sizeof(char)*10); - memcpy(_MAV_PAYLOAD(msg), &packet, 18); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 18); #endif msg->msgid = MAVLINK_MSG_ID_NAMED_VALUE_FLOAT; @@ -76,13 +76,13 @@ static inline uint16_t mavlink_msg_named_value_float_pack_chan(uint8_t system_id _mav_put_uint32_t(buf, 0, time_boot_ms); _mav_put_float(buf, 4, value); _mav_put_char_array(buf, 8, name, 10); - memcpy(_MAV_PAYLOAD(msg), buf, 18); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 18); #else mavlink_named_value_float_t packet; packet.time_boot_ms = time_boot_ms; packet.value = value; mav_array_memcpy(packet.name, name, sizeof(char)*10); - memcpy(_MAV_PAYLOAD(msg), &packet, 18); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 18); #endif msg->msgid = MAVLINK_MSG_ID_NAMED_VALUE_FLOAT; diff --git a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_named_value_int.h b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_named_value_int.h index 463b44d67..3c67dff03 100644 --- a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_named_value_int.h +++ b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_named_value_int.h @@ -43,13 +43,13 @@ static inline uint16_t mavlink_msg_named_value_int_pack(uint8_t system_id, uint8 _mav_put_uint32_t(buf, 0, time_boot_ms); _mav_put_int32_t(buf, 4, value); _mav_put_char_array(buf, 8, name, 10); - memcpy(_MAV_PAYLOAD(msg), buf, 18); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 18); #else mavlink_named_value_int_t packet; packet.time_boot_ms = time_boot_ms; packet.value = value; mav_array_memcpy(packet.name, name, sizeof(char)*10); - memcpy(_MAV_PAYLOAD(msg), &packet, 18); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 18); #endif msg->msgid = MAVLINK_MSG_ID_NAMED_VALUE_INT; @@ -76,13 +76,13 @@ static inline uint16_t mavlink_msg_named_value_int_pack_chan(uint8_t system_id, _mav_put_uint32_t(buf, 0, time_boot_ms); _mav_put_int32_t(buf, 4, value); _mav_put_char_array(buf, 8, name, 10); - memcpy(_MAV_PAYLOAD(msg), buf, 18); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 18); #else mavlink_named_value_int_t packet; packet.time_boot_ms = time_boot_ms; packet.value = value; mav_array_memcpy(packet.name, name, sizeof(char)*10); - memcpy(_MAV_PAYLOAD(msg), &packet, 18); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 18); #endif msg->msgid = MAVLINK_MSG_ID_NAMED_VALUE_INT; diff --git a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_nav_controller_output.h b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_nav_controller_output.h index a8310c142..028afdabc 100644 --- a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_nav_controller_output.h +++ b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_nav_controller_output.h @@ -64,7 +64,7 @@ static inline uint16_t mavlink_msg_nav_controller_output_pack(uint8_t system_id, _mav_put_int16_t(buf, 22, target_bearing); _mav_put_uint16_t(buf, 24, wp_dist); - memcpy(_MAV_PAYLOAD(msg), buf, 26); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 26); #else mavlink_nav_controller_output_t packet; packet.nav_roll = nav_roll; @@ -76,7 +76,7 @@ static inline uint16_t mavlink_msg_nav_controller_output_pack(uint8_t system_id, packet.target_bearing = target_bearing; packet.wp_dist = wp_dist; - memcpy(_MAV_PAYLOAD(msg), &packet, 26); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 26); #endif msg->msgid = MAVLINK_MSG_ID_NAV_CONTROLLER_OUTPUT; @@ -114,7 +114,7 @@ static inline uint16_t mavlink_msg_nav_controller_output_pack_chan(uint8_t syste _mav_put_int16_t(buf, 22, target_bearing); _mav_put_uint16_t(buf, 24, wp_dist); - memcpy(_MAV_PAYLOAD(msg), buf, 26); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 26); #else mavlink_nav_controller_output_t packet; packet.nav_roll = nav_roll; @@ -126,7 +126,7 @@ static inline uint16_t mavlink_msg_nav_controller_output_pack_chan(uint8_t syste packet.target_bearing = target_bearing; packet.wp_dist = wp_dist; - memcpy(_MAV_PAYLOAD(msg), &packet, 26); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 26); #endif msg->msgid = MAVLINK_MSG_ID_NAV_CONTROLLER_OUTPUT; diff --git a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_omnidirectional_flow.h b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_omnidirectional_flow.h new file mode 100644 index 000000000..9bb1e3369 --- /dev/null +++ b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_omnidirectional_flow.h @@ -0,0 +1,249 @@ +// MESSAGE OMNIDIRECTIONAL_FLOW PACKING + +#define MAVLINK_MSG_ID_OMNIDIRECTIONAL_FLOW 106 + +typedef struct __mavlink_omnidirectional_flow_t +{ + uint64_t time_usec; ///< Timestamp (microseconds, synced to UNIX time or since system boot) + float front_distance_m; ///< Front distance in meters. Positive value (including zero): distance known. Negative value: Unknown distance + int16_t left[10]; ///< Flow in deci pixels (1 = 0.1 pixel) on left hemisphere + int16_t right[10]; ///< Flow in deci pixels (1 = 0.1 pixel) on right hemisphere + uint8_t sensor_id; ///< Sensor ID + uint8_t quality; ///< Optical flow quality / confidence. 0: bad, 255: maximum quality +} mavlink_omnidirectional_flow_t; + +#define MAVLINK_MSG_ID_OMNIDIRECTIONAL_FLOW_LEN 54 +#define MAVLINK_MSG_ID_106_LEN 54 + +#define MAVLINK_MSG_OMNIDIRECTIONAL_FLOW_FIELD_LEFT_LEN 10 +#define MAVLINK_MSG_OMNIDIRECTIONAL_FLOW_FIELD_RIGHT_LEN 10 + +#define MAVLINK_MESSAGE_INFO_OMNIDIRECTIONAL_FLOW { \ + "OMNIDIRECTIONAL_FLOW", \ + 6, \ + { { "time_usec", NULL, MAVLINK_TYPE_UINT64_T, 0, 0, offsetof(mavlink_omnidirectional_flow_t, time_usec) }, \ + { "front_distance_m", NULL, MAVLINK_TYPE_FLOAT, 0, 8, offsetof(mavlink_omnidirectional_flow_t, front_distance_m) }, \ + { "left", NULL, MAVLINK_TYPE_INT16_T, 10, 12, offsetof(mavlink_omnidirectional_flow_t, left) }, \ + { "right", NULL, MAVLINK_TYPE_INT16_T, 10, 32, offsetof(mavlink_omnidirectional_flow_t, right) }, \ + { "sensor_id", NULL, MAVLINK_TYPE_UINT8_T, 0, 52, offsetof(mavlink_omnidirectional_flow_t, sensor_id) }, \ + { "quality", NULL, MAVLINK_TYPE_UINT8_T, 0, 53, offsetof(mavlink_omnidirectional_flow_t, quality) }, \ + } \ +} + + +/** + * @brief Pack a omnidirectional_flow message + * @param system_id ID of this system + * @param component_id ID of this component (e.g. 200 for IMU) + * @param msg The MAVLink message to compress the data into + * + * @param time_usec Timestamp (microseconds, synced to UNIX time or since system boot) + * @param sensor_id Sensor ID + * @param left Flow in deci pixels (1 = 0.1 pixel) on left hemisphere + * @param right Flow in deci pixels (1 = 0.1 pixel) on right hemisphere + * @param quality Optical flow quality / confidence. 0: bad, 255: maximum quality + * @param front_distance_m Front distance in meters. Positive value (including zero): distance known. Negative value: Unknown distance + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_omnidirectional_flow_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, + uint64_t time_usec, uint8_t sensor_id, const int16_t *left, const int16_t *right, uint8_t quality, float front_distance_m) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[54]; + _mav_put_uint64_t(buf, 0, time_usec); + _mav_put_float(buf, 8, front_distance_m); + _mav_put_uint8_t(buf, 52, sensor_id); + _mav_put_uint8_t(buf, 53, quality); + _mav_put_int16_t_array(buf, 12, left, 10); + _mav_put_int16_t_array(buf, 32, right, 10); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 54); +#else + mavlink_omnidirectional_flow_t packet; + packet.time_usec = time_usec; + packet.front_distance_m = front_distance_m; + packet.sensor_id = sensor_id; + packet.quality = quality; + mav_array_memcpy(packet.left, left, sizeof(int16_t)*10); + mav_array_memcpy(packet.right, right, sizeof(int16_t)*10); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 54); +#endif + + msg->msgid = MAVLINK_MSG_ID_OMNIDIRECTIONAL_FLOW; + return mavlink_finalize_message(msg, system_id, component_id, 54, 211); +} + +/** + * @brief Pack a omnidirectional_flow message on a channel + * @param system_id ID of this system + * @param component_id ID of this component (e.g. 200 for IMU) + * @param chan The MAVLink channel this message was sent over + * @param msg The MAVLink message to compress the data into + * @param time_usec Timestamp (microseconds, synced to UNIX time or since system boot) + * @param sensor_id Sensor ID + * @param left Flow in deci pixels (1 = 0.1 pixel) on left hemisphere + * @param right Flow in deci pixels (1 = 0.1 pixel) on right hemisphere + * @param quality Optical flow quality / confidence. 0: bad, 255: maximum quality + * @param front_distance_m Front distance in meters. Positive value (including zero): distance known. Negative value: Unknown distance + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_omnidirectional_flow_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, + mavlink_message_t* msg, + uint64_t time_usec,uint8_t sensor_id,const int16_t *left,const int16_t *right,uint8_t quality,float front_distance_m) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[54]; + _mav_put_uint64_t(buf, 0, time_usec); + _mav_put_float(buf, 8, front_distance_m); + _mav_put_uint8_t(buf, 52, sensor_id); + _mav_put_uint8_t(buf, 53, quality); + _mav_put_int16_t_array(buf, 12, left, 10); + _mav_put_int16_t_array(buf, 32, right, 10); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 54); +#else + mavlink_omnidirectional_flow_t packet; + packet.time_usec = time_usec; + packet.front_distance_m = front_distance_m; + packet.sensor_id = sensor_id; + packet.quality = quality; + mav_array_memcpy(packet.left, left, sizeof(int16_t)*10); + mav_array_memcpy(packet.right, right, sizeof(int16_t)*10); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 54); +#endif + + msg->msgid = MAVLINK_MSG_ID_OMNIDIRECTIONAL_FLOW; + return mavlink_finalize_message_chan(msg, system_id, component_id, chan, 54, 211); +} + +/** + * @brief Encode a omnidirectional_flow struct into a message + * + * @param system_id ID of this system + * @param component_id ID of this component (e.g. 200 for IMU) + * @param msg The MAVLink message to compress the data into + * @param omnidirectional_flow C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_omnidirectional_flow_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_omnidirectional_flow_t* omnidirectional_flow) +{ + return mavlink_msg_omnidirectional_flow_pack(system_id, component_id, msg, omnidirectional_flow->time_usec, omnidirectional_flow->sensor_id, omnidirectional_flow->left, omnidirectional_flow->right, omnidirectional_flow->quality, omnidirectional_flow->front_distance_m); +} + +/** + * @brief Send a omnidirectional_flow message + * @param chan MAVLink channel to send the message + * + * @param time_usec Timestamp (microseconds, synced to UNIX time or since system boot) + * @param sensor_id Sensor ID + * @param left Flow in deci pixels (1 = 0.1 pixel) on left hemisphere + * @param right Flow in deci pixels (1 = 0.1 pixel) on right hemisphere + * @param quality Optical flow quality / confidence. 0: bad, 255: maximum quality + * @param front_distance_m Front distance in meters. Positive value (including zero): distance known. Negative value: Unknown distance + */ +#ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS + +static inline void mavlink_msg_omnidirectional_flow_send(mavlink_channel_t chan, uint64_t time_usec, uint8_t sensor_id, const int16_t *left, const int16_t *right, uint8_t quality, float front_distance_m) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[54]; + _mav_put_uint64_t(buf, 0, time_usec); + _mav_put_float(buf, 8, front_distance_m); + _mav_put_uint8_t(buf, 52, sensor_id); + _mav_put_uint8_t(buf, 53, quality); + _mav_put_int16_t_array(buf, 12, left, 10); + _mav_put_int16_t_array(buf, 32, right, 10); + _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_OMNIDIRECTIONAL_FLOW, buf, 54, 211); +#else + mavlink_omnidirectional_flow_t packet; + packet.time_usec = time_usec; + packet.front_distance_m = front_distance_m; + packet.sensor_id = sensor_id; + packet.quality = quality; + mav_array_memcpy(packet.left, left, sizeof(int16_t)*10); + mav_array_memcpy(packet.right, right, sizeof(int16_t)*10); + _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_OMNIDIRECTIONAL_FLOW, (const char *)&packet, 54, 211); +#endif +} + +#endif + +// MESSAGE OMNIDIRECTIONAL_FLOW UNPACKING + + +/** + * @brief Get field time_usec from omnidirectional_flow message + * + * @return Timestamp (microseconds, synced to UNIX time or since system boot) + */ +static inline uint64_t mavlink_msg_omnidirectional_flow_get_time_usec(const mavlink_message_t* msg) +{ + return _MAV_RETURN_uint64_t(msg, 0); +} + +/** + * @brief Get field sensor_id from omnidirectional_flow message + * + * @return Sensor ID + */ +static inline uint8_t mavlink_msg_omnidirectional_flow_get_sensor_id(const mavlink_message_t* msg) +{ + return _MAV_RETURN_uint8_t(msg, 52); +} + +/** + * @brief Get field left from omnidirectional_flow message + * + * @return Flow in deci pixels (1 = 0.1 pixel) on left hemisphere + */ +static inline uint16_t mavlink_msg_omnidirectional_flow_get_left(const mavlink_message_t* msg, int16_t *left) +{ + return _MAV_RETURN_int16_t_array(msg, left, 10, 12); +} + +/** + * @brief Get field right from omnidirectional_flow message + * + * @return Flow in deci pixels (1 = 0.1 pixel) on right hemisphere + */ +static inline uint16_t mavlink_msg_omnidirectional_flow_get_right(const mavlink_message_t* msg, int16_t *right) +{ + return _MAV_RETURN_int16_t_array(msg, right, 10, 32); +} + +/** + * @brief Get field quality from omnidirectional_flow message + * + * @return Optical flow quality / confidence. 0: bad, 255: maximum quality + */ +static inline uint8_t mavlink_msg_omnidirectional_flow_get_quality(const mavlink_message_t* msg) +{ + return _MAV_RETURN_uint8_t(msg, 53); +} + +/** + * @brief Get field front_distance_m from omnidirectional_flow message + * + * @return Front distance in meters. Positive value (including zero): distance known. Negative value: Unknown distance + */ +static inline float mavlink_msg_omnidirectional_flow_get_front_distance_m(const mavlink_message_t* msg) +{ + return _MAV_RETURN_float(msg, 8); +} + +/** + * @brief Decode a omnidirectional_flow message into a struct + * + * @param msg The message to decode + * @param omnidirectional_flow C-struct to decode the message contents into + */ +static inline void mavlink_msg_omnidirectional_flow_decode(const mavlink_message_t* msg, mavlink_omnidirectional_flow_t* omnidirectional_flow) +{ +#if MAVLINK_NEED_BYTE_SWAP + omnidirectional_flow->time_usec = mavlink_msg_omnidirectional_flow_get_time_usec(msg); + omnidirectional_flow->front_distance_m = mavlink_msg_omnidirectional_flow_get_front_distance_m(msg); + mavlink_msg_omnidirectional_flow_get_left(msg, omnidirectional_flow->left); + mavlink_msg_omnidirectional_flow_get_right(msg, omnidirectional_flow->right); + omnidirectional_flow->sensor_id = mavlink_msg_omnidirectional_flow_get_sensor_id(msg); + omnidirectional_flow->quality = mavlink_msg_omnidirectional_flow_get_quality(msg); +#else + memcpy(omnidirectional_flow, _MAV_PAYLOAD(msg), 54); +#endif +} diff --git a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_optical_flow.h b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_optical_flow.h index cebc1d902..b277cab51 100644 --- a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_optical_flow.h +++ b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_optical_flow.h @@ -5,27 +5,31 @@ typedef struct __mavlink_optical_flow_t { uint64_t time_usec; ///< Timestamp (UNIX) - float ground_distance; ///< Ground distance in meters + float flow_comp_m_x; ///< Flow in meters in x-sensor direction, angular-speed compensated + float flow_comp_m_y; ///< Flow in meters in y-sensor direction, angular-speed compensated + float ground_distance; ///< Ground distance in meters. Positive value: distance known. Negative value: Unknown distance int16_t flow_x; ///< Flow in pixels in x-sensor direction int16_t flow_y; ///< Flow in pixels in y-sensor direction uint8_t sensor_id; ///< Sensor ID uint8_t quality; ///< Optical flow quality / confidence. 0: bad, 255: maximum quality } mavlink_optical_flow_t; -#define MAVLINK_MSG_ID_OPTICAL_FLOW_LEN 18 -#define MAVLINK_MSG_ID_100_LEN 18 +#define MAVLINK_MSG_ID_OPTICAL_FLOW_LEN 26 +#define MAVLINK_MSG_ID_100_LEN 26 #define MAVLINK_MESSAGE_INFO_OPTICAL_FLOW { \ "OPTICAL_FLOW", \ - 6, \ + 8, \ { { "time_usec", NULL, MAVLINK_TYPE_UINT64_T, 0, 0, offsetof(mavlink_optical_flow_t, time_usec) }, \ - { "ground_distance", NULL, MAVLINK_TYPE_FLOAT, 0, 8, offsetof(mavlink_optical_flow_t, ground_distance) }, \ - { "flow_x", NULL, MAVLINK_TYPE_INT16_T, 0, 12, offsetof(mavlink_optical_flow_t, flow_x) }, \ - { "flow_y", NULL, MAVLINK_TYPE_INT16_T, 0, 14, offsetof(mavlink_optical_flow_t, flow_y) }, \ - { "sensor_id", NULL, MAVLINK_TYPE_UINT8_T, 0, 16, offsetof(mavlink_optical_flow_t, sensor_id) }, \ - { "quality", NULL, MAVLINK_TYPE_UINT8_T, 0, 17, offsetof(mavlink_optical_flow_t, quality) }, \ + { "flow_comp_m_x", NULL, MAVLINK_TYPE_FLOAT, 0, 8, offsetof(mavlink_optical_flow_t, flow_comp_m_x) }, \ + { "flow_comp_m_y", NULL, MAVLINK_TYPE_FLOAT, 0, 12, offsetof(mavlink_optical_flow_t, flow_comp_m_y) }, \ + { "ground_distance", NULL, MAVLINK_TYPE_FLOAT, 0, 16, offsetof(mavlink_optical_flow_t, ground_distance) }, \ + { "flow_x", NULL, MAVLINK_TYPE_INT16_T, 0, 20, offsetof(mavlink_optical_flow_t, flow_x) }, \ + { "flow_y", NULL, MAVLINK_TYPE_INT16_T, 0, 22, offsetof(mavlink_optical_flow_t, flow_y) }, \ + { "sensor_id", NULL, MAVLINK_TYPE_UINT8_T, 0, 24, offsetof(mavlink_optical_flow_t, sensor_id) }, \ + { "quality", NULL, MAVLINK_TYPE_UINT8_T, 0, 25, offsetof(mavlink_optical_flow_t, quality) }, \ } \ } @@ -40,37 +44,43 @@ typedef struct __mavlink_optical_flow_t * @param sensor_id Sensor ID * @param flow_x Flow in pixels in x-sensor direction * @param flow_y Flow in pixels in y-sensor direction + * @param flow_comp_m_x Flow in meters in x-sensor direction, angular-speed compensated + * @param flow_comp_m_y Flow in meters in y-sensor direction, angular-speed compensated * @param quality Optical flow quality / confidence. 0: bad, 255: maximum quality - * @param ground_distance Ground distance in meters + * @param ground_distance Ground distance in meters. Positive value: distance known. Negative value: Unknown distance * @return length of the message in bytes (excluding serial stream start sign) */ static inline uint16_t mavlink_msg_optical_flow_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, - uint64_t time_usec, uint8_t sensor_id, int16_t flow_x, int16_t flow_y, uint8_t quality, float ground_distance) + uint64_t time_usec, uint8_t sensor_id, int16_t flow_x, int16_t flow_y, float flow_comp_m_x, float flow_comp_m_y, uint8_t quality, float ground_distance) { #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS - char buf[18]; + char buf[26]; _mav_put_uint64_t(buf, 0, time_usec); - _mav_put_float(buf, 8, ground_distance); - _mav_put_int16_t(buf, 12, flow_x); - _mav_put_int16_t(buf, 14, flow_y); - _mav_put_uint8_t(buf, 16, sensor_id); - _mav_put_uint8_t(buf, 17, quality); + _mav_put_float(buf, 8, flow_comp_m_x); + _mav_put_float(buf, 12, flow_comp_m_y); + _mav_put_float(buf, 16, ground_distance); + _mav_put_int16_t(buf, 20, flow_x); + _mav_put_int16_t(buf, 22, flow_y); + _mav_put_uint8_t(buf, 24, sensor_id); + _mav_put_uint8_t(buf, 25, quality); - memcpy(_MAV_PAYLOAD(msg), buf, 18); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 26); #else mavlink_optical_flow_t packet; packet.time_usec = time_usec; + packet.flow_comp_m_x = flow_comp_m_x; + packet.flow_comp_m_y = flow_comp_m_y; packet.ground_distance = ground_distance; packet.flow_x = flow_x; packet.flow_y = flow_y; packet.sensor_id = sensor_id; packet.quality = quality; - memcpy(_MAV_PAYLOAD(msg), &packet, 18); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 26); #endif msg->msgid = MAVLINK_MSG_ID_OPTICAL_FLOW; - return mavlink_finalize_message(msg, system_id, component_id, 18, 19); + return mavlink_finalize_message(msg, system_id, component_id, 26, 175); } /** @@ -83,38 +93,44 @@ static inline uint16_t mavlink_msg_optical_flow_pack(uint8_t system_id, uint8_t * @param sensor_id Sensor ID * @param flow_x Flow in pixels in x-sensor direction * @param flow_y Flow in pixels in y-sensor direction + * @param flow_comp_m_x Flow in meters in x-sensor direction, angular-speed compensated + * @param flow_comp_m_y Flow in meters in y-sensor direction, angular-speed compensated * @param quality Optical flow quality / confidence. 0: bad, 255: maximum quality - * @param ground_distance Ground distance in meters + * @param ground_distance Ground distance in meters. Positive value: distance known. Negative value: Unknown distance * @return length of the message in bytes (excluding serial stream start sign) */ static inline uint16_t mavlink_msg_optical_flow_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, - uint64_t time_usec,uint8_t sensor_id,int16_t flow_x,int16_t flow_y,uint8_t quality,float ground_distance) + uint64_t time_usec,uint8_t sensor_id,int16_t flow_x,int16_t flow_y,float flow_comp_m_x,float flow_comp_m_y,uint8_t quality,float ground_distance) { #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS - char buf[18]; + char buf[26]; _mav_put_uint64_t(buf, 0, time_usec); - _mav_put_float(buf, 8, ground_distance); - _mav_put_int16_t(buf, 12, flow_x); - _mav_put_int16_t(buf, 14, flow_y); - _mav_put_uint8_t(buf, 16, sensor_id); - _mav_put_uint8_t(buf, 17, quality); + _mav_put_float(buf, 8, flow_comp_m_x); + _mav_put_float(buf, 12, flow_comp_m_y); + _mav_put_float(buf, 16, ground_distance); + _mav_put_int16_t(buf, 20, flow_x); + _mav_put_int16_t(buf, 22, flow_y); + _mav_put_uint8_t(buf, 24, sensor_id); + _mav_put_uint8_t(buf, 25, quality); - memcpy(_MAV_PAYLOAD(msg), buf, 18); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 26); #else mavlink_optical_flow_t packet; packet.time_usec = time_usec; + packet.flow_comp_m_x = flow_comp_m_x; + packet.flow_comp_m_y = flow_comp_m_y; packet.ground_distance = ground_distance; packet.flow_x = flow_x; packet.flow_y = flow_y; packet.sensor_id = sensor_id; packet.quality = quality; - memcpy(_MAV_PAYLOAD(msg), &packet, 18); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 26); #endif msg->msgid = MAVLINK_MSG_ID_OPTICAL_FLOW; - return mavlink_finalize_message_chan(msg, system_id, component_id, chan, 18, 19); + return mavlink_finalize_message_chan(msg, system_id, component_id, chan, 26, 175); } /** @@ -127,7 +143,7 @@ static inline uint16_t mavlink_msg_optical_flow_pack_chan(uint8_t system_id, uin */ static inline uint16_t mavlink_msg_optical_flow_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_optical_flow_t* optical_flow) { - return mavlink_msg_optical_flow_pack(system_id, component_id, msg, optical_flow->time_usec, optical_flow->sensor_id, optical_flow->flow_x, optical_flow->flow_y, optical_flow->quality, optical_flow->ground_distance); + return mavlink_msg_optical_flow_pack(system_id, component_id, msg, optical_flow->time_usec, optical_flow->sensor_id, optical_flow->flow_x, optical_flow->flow_y, optical_flow->flow_comp_m_x, optical_flow->flow_comp_m_y, optical_flow->quality, optical_flow->ground_distance); } /** @@ -138,33 +154,39 @@ static inline uint16_t mavlink_msg_optical_flow_encode(uint8_t system_id, uint8_ * @param sensor_id Sensor ID * @param flow_x Flow in pixels in x-sensor direction * @param flow_y Flow in pixels in y-sensor direction + * @param flow_comp_m_x Flow in meters in x-sensor direction, angular-speed compensated + * @param flow_comp_m_y Flow in meters in y-sensor direction, angular-speed compensated * @param quality Optical flow quality / confidence. 0: bad, 255: maximum quality - * @param ground_distance Ground distance in meters + * @param ground_distance Ground distance in meters. Positive value: distance known. Negative value: Unknown distance */ #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS -static inline void mavlink_msg_optical_flow_send(mavlink_channel_t chan, uint64_t time_usec, uint8_t sensor_id, int16_t flow_x, int16_t flow_y, uint8_t quality, float ground_distance) +static inline void mavlink_msg_optical_flow_send(mavlink_channel_t chan, uint64_t time_usec, uint8_t sensor_id, int16_t flow_x, int16_t flow_y, float flow_comp_m_x, float flow_comp_m_y, uint8_t quality, float ground_distance) { #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS - char buf[18]; + char buf[26]; _mav_put_uint64_t(buf, 0, time_usec); - _mav_put_float(buf, 8, ground_distance); - _mav_put_int16_t(buf, 12, flow_x); - _mav_put_int16_t(buf, 14, flow_y); - _mav_put_uint8_t(buf, 16, sensor_id); - _mav_put_uint8_t(buf, 17, quality); + _mav_put_float(buf, 8, flow_comp_m_x); + _mav_put_float(buf, 12, flow_comp_m_y); + _mav_put_float(buf, 16, ground_distance); + _mav_put_int16_t(buf, 20, flow_x); + _mav_put_int16_t(buf, 22, flow_y); + _mav_put_uint8_t(buf, 24, sensor_id); + _mav_put_uint8_t(buf, 25, quality); - _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_OPTICAL_FLOW, buf, 18, 19); + _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_OPTICAL_FLOW, buf, 26, 175); #else mavlink_optical_flow_t packet; packet.time_usec = time_usec; + packet.flow_comp_m_x = flow_comp_m_x; + packet.flow_comp_m_y = flow_comp_m_y; packet.ground_distance = ground_distance; packet.flow_x = flow_x; packet.flow_y = flow_y; packet.sensor_id = sensor_id; packet.quality = quality; - _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_OPTICAL_FLOW, (const char *)&packet, 18, 19); + _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_OPTICAL_FLOW, (const char *)&packet, 26, 175); #endif } @@ -190,7 +212,7 @@ static inline uint64_t mavlink_msg_optical_flow_get_time_usec(const mavlink_mess */ static inline uint8_t mavlink_msg_optical_flow_get_sensor_id(const mavlink_message_t* msg) { - return _MAV_RETURN_uint8_t(msg, 16); + return _MAV_RETURN_uint8_t(msg, 24); } /** @@ -200,7 +222,7 @@ static inline uint8_t mavlink_msg_optical_flow_get_sensor_id(const mavlink_messa */ static inline int16_t mavlink_msg_optical_flow_get_flow_x(const mavlink_message_t* msg) { - return _MAV_RETURN_int16_t(msg, 12); + return _MAV_RETURN_int16_t(msg, 20); } /** @@ -210,7 +232,27 @@ static inline int16_t mavlink_msg_optical_flow_get_flow_x(const mavlink_message_ */ static inline int16_t mavlink_msg_optical_flow_get_flow_y(const mavlink_message_t* msg) { - return _MAV_RETURN_int16_t(msg, 14); + return _MAV_RETURN_int16_t(msg, 22); +} + +/** + * @brief Get field flow_comp_m_x from optical_flow message + * + * @return Flow in meters in x-sensor direction, angular-speed compensated + */ +static inline float mavlink_msg_optical_flow_get_flow_comp_m_x(const mavlink_message_t* msg) +{ + return _MAV_RETURN_float(msg, 8); +} + +/** + * @brief Get field flow_comp_m_y from optical_flow message + * + * @return Flow in meters in y-sensor direction, angular-speed compensated + */ +static inline float mavlink_msg_optical_flow_get_flow_comp_m_y(const mavlink_message_t* msg) +{ + return _MAV_RETURN_float(msg, 12); } /** @@ -220,17 +262,17 @@ static inline int16_t mavlink_msg_optical_flow_get_flow_y(const mavlink_message_ */ static inline uint8_t mavlink_msg_optical_flow_get_quality(const mavlink_message_t* msg) { - return _MAV_RETURN_uint8_t(msg, 17); + return _MAV_RETURN_uint8_t(msg, 25); } /** * @brief Get field ground_distance from optical_flow message * - * @return Ground distance in meters + * @return Ground distance in meters. Positive value: distance known. Negative value: Unknown distance */ static inline float mavlink_msg_optical_flow_get_ground_distance(const mavlink_message_t* msg) { - return _MAV_RETURN_float(msg, 8); + return _MAV_RETURN_float(msg, 16); } /** @@ -243,12 +285,14 @@ static inline void mavlink_msg_optical_flow_decode(const mavlink_message_t* msg, { #if MAVLINK_NEED_BYTE_SWAP optical_flow->time_usec = mavlink_msg_optical_flow_get_time_usec(msg); + optical_flow->flow_comp_m_x = mavlink_msg_optical_flow_get_flow_comp_m_x(msg); + optical_flow->flow_comp_m_y = mavlink_msg_optical_flow_get_flow_comp_m_y(msg); optical_flow->ground_distance = mavlink_msg_optical_flow_get_ground_distance(msg); optical_flow->flow_x = mavlink_msg_optical_flow_get_flow_x(msg); optical_flow->flow_y = mavlink_msg_optical_flow_get_flow_y(msg); optical_flow->sensor_id = mavlink_msg_optical_flow_get_sensor_id(msg); optical_flow->quality = mavlink_msg_optical_flow_get_quality(msg); #else - memcpy(optical_flow, _MAV_PAYLOAD(msg), 18); + memcpy(optical_flow, _MAV_PAYLOAD(msg), 26); #endif } diff --git a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_param_request_list.h b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_param_request_list.h index 7ebd92284..125df80c8 100644 --- a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_param_request_list.h +++ b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_param_request_list.h @@ -40,13 +40,13 @@ static inline uint16_t mavlink_msg_param_request_list_pack(uint8_t system_id, ui _mav_put_uint8_t(buf, 0, target_system); _mav_put_uint8_t(buf, 1, target_component); - memcpy(_MAV_PAYLOAD(msg), buf, 2); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 2); #else mavlink_param_request_list_t packet; packet.target_system = target_system; packet.target_component = target_component; - memcpy(_MAV_PAYLOAD(msg), &packet, 2); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 2); #endif msg->msgid = MAVLINK_MSG_ID_PARAM_REQUEST_LIST; @@ -72,13 +72,13 @@ static inline uint16_t mavlink_msg_param_request_list_pack_chan(uint8_t system_i _mav_put_uint8_t(buf, 0, target_system); _mav_put_uint8_t(buf, 1, target_component); - memcpy(_MAV_PAYLOAD(msg), buf, 2); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 2); #else mavlink_param_request_list_t packet; packet.target_system = target_system; packet.target_component = target_component; - memcpy(_MAV_PAYLOAD(msg), &packet, 2); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 2); #endif msg->msgid = MAVLINK_MSG_ID_PARAM_REQUEST_LIST; diff --git a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_param_request_read.h b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_param_request_read.h index 92fac8037..dba528df9 100644 --- a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_param_request_read.h +++ b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_param_request_read.h @@ -4,10 +4,10 @@ typedef struct __mavlink_param_request_read_t { - int16_t param_index; ///< Parameter index. Send -1 to use the param ID field as identifier + int16_t param_index; ///< Parameter index. Send -1 to use the param ID field as identifier (else the param id will be ignored) uint8_t target_system; ///< System ID uint8_t target_component; ///< Component ID - char param_id[16]; ///< Onboard parameter id + char param_id[16]; ///< Onboard parameter id, terminated by NULL if the length is less than 16 human-readable chars and WITHOUT null termination (NULL) byte if the length is exactly 16 chars - applications have to provide 16+1 bytes storage if the ID is stored as string } mavlink_param_request_read_t; #define MAVLINK_MSG_ID_PARAM_REQUEST_READ_LEN 20 @@ -34,8 +34,8 @@ typedef struct __mavlink_param_request_read_t * * @param target_system System ID * @param target_component Component ID - * @param param_id Onboard parameter id - * @param param_index Parameter index. Send -1 to use the param ID field as identifier + * @param param_id Onboard parameter id, terminated by NULL if the length is less than 16 human-readable chars and WITHOUT null termination (NULL) byte if the length is exactly 16 chars - applications have to provide 16+1 bytes storage if the ID is stored as string + * @param param_index Parameter index. Send -1 to use the param ID field as identifier (else the param id will be ignored) * @return length of the message in bytes (excluding serial stream start sign) */ static inline uint16_t mavlink_msg_param_request_read_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, @@ -47,14 +47,14 @@ static inline uint16_t mavlink_msg_param_request_read_pack(uint8_t system_id, ui _mav_put_uint8_t(buf, 2, target_system); _mav_put_uint8_t(buf, 3, target_component); _mav_put_char_array(buf, 4, param_id, 16); - memcpy(_MAV_PAYLOAD(msg), buf, 20); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 20); #else mavlink_param_request_read_t packet; packet.param_index = param_index; packet.target_system = target_system; packet.target_component = target_component; mav_array_memcpy(packet.param_id, param_id, sizeof(char)*16); - memcpy(_MAV_PAYLOAD(msg), &packet, 20); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 20); #endif msg->msgid = MAVLINK_MSG_ID_PARAM_REQUEST_READ; @@ -69,8 +69,8 @@ static inline uint16_t mavlink_msg_param_request_read_pack(uint8_t system_id, ui * @param msg The MAVLink message to compress the data into * @param target_system System ID * @param target_component Component ID - * @param param_id Onboard parameter id - * @param param_index Parameter index. Send -1 to use the param ID field as identifier + * @param param_id Onboard parameter id, terminated by NULL if the length is less than 16 human-readable chars and WITHOUT null termination (NULL) byte if the length is exactly 16 chars - applications have to provide 16+1 bytes storage if the ID is stored as string + * @param param_index Parameter index. Send -1 to use the param ID field as identifier (else the param id will be ignored) * @return length of the message in bytes (excluding serial stream start sign) */ static inline uint16_t mavlink_msg_param_request_read_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, @@ -83,14 +83,14 @@ static inline uint16_t mavlink_msg_param_request_read_pack_chan(uint8_t system_i _mav_put_uint8_t(buf, 2, target_system); _mav_put_uint8_t(buf, 3, target_component); _mav_put_char_array(buf, 4, param_id, 16); - memcpy(_MAV_PAYLOAD(msg), buf, 20); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 20); #else mavlink_param_request_read_t packet; packet.param_index = param_index; packet.target_system = target_system; packet.target_component = target_component; mav_array_memcpy(packet.param_id, param_id, sizeof(char)*16); - memcpy(_MAV_PAYLOAD(msg), &packet, 20); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 20); #endif msg->msgid = MAVLINK_MSG_ID_PARAM_REQUEST_READ; @@ -116,8 +116,8 @@ static inline uint16_t mavlink_msg_param_request_read_encode(uint8_t system_id, * * @param target_system System ID * @param target_component Component ID - * @param param_id Onboard parameter id - * @param param_index Parameter index. Send -1 to use the param ID field as identifier + * @param param_id Onboard parameter id, terminated by NULL if the length is less than 16 human-readable chars and WITHOUT null termination (NULL) byte if the length is exactly 16 chars - applications have to provide 16+1 bytes storage if the ID is stored as string + * @param param_index Parameter index. Send -1 to use the param ID field as identifier (else the param id will be ignored) */ #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS @@ -168,7 +168,7 @@ static inline uint8_t mavlink_msg_param_request_read_get_target_component(const /** * @brief Get field param_id from param_request_read message * - * @return Onboard parameter id + * @return Onboard parameter id, terminated by NULL if the length is less than 16 human-readable chars and WITHOUT null termination (NULL) byte if the length is exactly 16 chars - applications have to provide 16+1 bytes storage if the ID is stored as string */ static inline uint16_t mavlink_msg_param_request_read_get_param_id(const mavlink_message_t* msg, char *param_id) { @@ -178,7 +178,7 @@ static inline uint16_t mavlink_msg_param_request_read_get_param_id(const mavlink /** * @brief Get field param_index from param_request_read message * - * @return Parameter index. Send -1 to use the param ID field as identifier + * @return Parameter index. Send -1 to use the param ID field as identifier (else the param id will be ignored) */ static inline int16_t mavlink_msg_param_request_read_get_param_index(const mavlink_message_t* msg) { diff --git a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_param_set.h b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_param_set.h index d65412d17..8f00f22e9 100644 --- a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_param_set.h +++ b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_param_set.h @@ -7,8 +7,8 @@ typedef struct __mavlink_param_set_t float param_value; ///< Onboard parameter value uint8_t target_system; ///< System ID uint8_t target_component; ///< Component ID - char param_id[16]; ///< Onboard parameter id - uint8_t param_type; ///< Onboard parameter type: see MAV_VAR enum + char param_id[16]; ///< Onboard parameter id, terminated by NULL if the length is less than 16 human-readable chars and WITHOUT null termination (NULL) byte if the length is exactly 16 chars - applications have to provide 16+1 bytes storage if the ID is stored as string + uint8_t param_type; ///< Onboard parameter type: see the MAV_PARAM_TYPE enum for supported data types. } mavlink_param_set_t; #define MAVLINK_MSG_ID_PARAM_SET_LEN 23 @@ -36,9 +36,9 @@ typedef struct __mavlink_param_set_t * * @param target_system System ID * @param target_component Component ID - * @param param_id Onboard parameter id + * @param param_id Onboard parameter id, terminated by NULL if the length is less than 16 human-readable chars and WITHOUT null termination (NULL) byte if the length is exactly 16 chars - applications have to provide 16+1 bytes storage if the ID is stored as string * @param param_value Onboard parameter value - * @param param_type Onboard parameter type: see MAV_VAR enum + * @param param_type Onboard parameter type: see the MAV_PARAM_TYPE enum for supported data types. * @return length of the message in bytes (excluding serial stream start sign) */ static inline uint16_t mavlink_msg_param_set_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, @@ -51,7 +51,7 @@ static inline uint16_t mavlink_msg_param_set_pack(uint8_t system_id, uint8_t com _mav_put_uint8_t(buf, 5, target_component); _mav_put_uint8_t(buf, 22, param_type); _mav_put_char_array(buf, 6, param_id, 16); - memcpy(_MAV_PAYLOAD(msg), buf, 23); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 23); #else mavlink_param_set_t packet; packet.param_value = param_value; @@ -59,7 +59,7 @@ static inline uint16_t mavlink_msg_param_set_pack(uint8_t system_id, uint8_t com packet.target_component = target_component; packet.param_type = param_type; mav_array_memcpy(packet.param_id, param_id, sizeof(char)*16); - memcpy(_MAV_PAYLOAD(msg), &packet, 23); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 23); #endif msg->msgid = MAVLINK_MSG_ID_PARAM_SET; @@ -74,9 +74,9 @@ static inline uint16_t mavlink_msg_param_set_pack(uint8_t system_id, uint8_t com * @param msg The MAVLink message to compress the data into * @param target_system System ID * @param target_component Component ID - * @param param_id Onboard parameter id + * @param param_id Onboard parameter id, terminated by NULL if the length is less than 16 human-readable chars and WITHOUT null termination (NULL) byte if the length is exactly 16 chars - applications have to provide 16+1 bytes storage if the ID is stored as string * @param param_value Onboard parameter value - * @param param_type Onboard parameter type: see MAV_VAR enum + * @param param_type Onboard parameter type: see the MAV_PARAM_TYPE enum for supported data types. * @return length of the message in bytes (excluding serial stream start sign) */ static inline uint16_t mavlink_msg_param_set_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, @@ -90,7 +90,7 @@ static inline uint16_t mavlink_msg_param_set_pack_chan(uint8_t system_id, uint8_ _mav_put_uint8_t(buf, 5, target_component); _mav_put_uint8_t(buf, 22, param_type); _mav_put_char_array(buf, 6, param_id, 16); - memcpy(_MAV_PAYLOAD(msg), buf, 23); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 23); #else mavlink_param_set_t packet; packet.param_value = param_value; @@ -98,7 +98,7 @@ static inline uint16_t mavlink_msg_param_set_pack_chan(uint8_t system_id, uint8_ packet.target_component = target_component; packet.param_type = param_type; mav_array_memcpy(packet.param_id, param_id, sizeof(char)*16); - memcpy(_MAV_PAYLOAD(msg), &packet, 23); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 23); #endif msg->msgid = MAVLINK_MSG_ID_PARAM_SET; @@ -124,9 +124,9 @@ static inline uint16_t mavlink_msg_param_set_encode(uint8_t system_id, uint8_t c * * @param target_system System ID * @param target_component Component ID - * @param param_id Onboard parameter id + * @param param_id Onboard parameter id, terminated by NULL if the length is less than 16 human-readable chars and WITHOUT null termination (NULL) byte if the length is exactly 16 chars - applications have to provide 16+1 bytes storage if the ID is stored as string * @param param_value Onboard parameter value - * @param param_type Onboard parameter type: see MAV_VAR enum + * @param param_type Onboard parameter type: see the MAV_PARAM_TYPE enum for supported data types. */ #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS @@ -179,7 +179,7 @@ static inline uint8_t mavlink_msg_param_set_get_target_component(const mavlink_m /** * @brief Get field param_id from param_set message * - * @return Onboard parameter id + * @return Onboard parameter id, terminated by NULL if the length is less than 16 human-readable chars and WITHOUT null termination (NULL) byte if the length is exactly 16 chars - applications have to provide 16+1 bytes storage if the ID is stored as string */ static inline uint16_t mavlink_msg_param_set_get_param_id(const mavlink_message_t* msg, char *param_id) { @@ -199,7 +199,7 @@ static inline float mavlink_msg_param_set_get_param_value(const mavlink_message_ /** * @brief Get field param_type from param_set message * - * @return Onboard parameter type: see MAV_VAR enum + * @return Onboard parameter type: see the MAV_PARAM_TYPE enum for supported data types. */ static inline uint8_t mavlink_msg_param_set_get_param_type(const mavlink_message_t* msg) { diff --git a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_param_value.h b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_param_value.h index c972ebaa3..03a631984 100644 --- a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_param_value.h +++ b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_param_value.h @@ -7,8 +7,8 @@ typedef struct __mavlink_param_value_t float param_value; ///< Onboard parameter value uint16_t param_count; ///< Total number of onboard parameters uint16_t param_index; ///< Index of this onboard parameter - char param_id[16]; ///< Onboard parameter id - uint8_t param_type; ///< Onboard parameter type: see MAV_VAR enum + char param_id[16]; ///< Onboard parameter id, terminated by NULL if the length is less than 16 human-readable chars and WITHOUT null termination (NULL) byte if the length is exactly 16 chars - applications have to provide 16+1 bytes storage if the ID is stored as string + uint8_t param_type; ///< Onboard parameter type: see the MAV_PARAM_TYPE enum for supported data types. } mavlink_param_value_t; #define MAVLINK_MSG_ID_PARAM_VALUE_LEN 25 @@ -34,9 +34,9 @@ typedef struct __mavlink_param_value_t * @param component_id ID of this component (e.g. 200 for IMU) * @param msg The MAVLink message to compress the data into * - * @param param_id Onboard parameter id + * @param param_id Onboard parameter id, terminated by NULL if the length is less than 16 human-readable chars and WITHOUT null termination (NULL) byte if the length is exactly 16 chars - applications have to provide 16+1 bytes storage if the ID is stored as string * @param param_value Onboard parameter value - * @param param_type Onboard parameter type: see MAV_VAR enum + * @param param_type Onboard parameter type: see the MAV_PARAM_TYPE enum for supported data types. * @param param_count Total number of onboard parameters * @param param_index Index of this onboard parameter * @return length of the message in bytes (excluding serial stream start sign) @@ -51,7 +51,7 @@ static inline uint16_t mavlink_msg_param_value_pack(uint8_t system_id, uint8_t c _mav_put_uint16_t(buf, 6, param_index); _mav_put_uint8_t(buf, 24, param_type); _mav_put_char_array(buf, 8, param_id, 16); - memcpy(_MAV_PAYLOAD(msg), buf, 25); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 25); #else mavlink_param_value_t packet; packet.param_value = param_value; @@ -59,7 +59,7 @@ static inline uint16_t mavlink_msg_param_value_pack(uint8_t system_id, uint8_t c packet.param_index = param_index; packet.param_type = param_type; mav_array_memcpy(packet.param_id, param_id, sizeof(char)*16); - memcpy(_MAV_PAYLOAD(msg), &packet, 25); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 25); #endif msg->msgid = MAVLINK_MSG_ID_PARAM_VALUE; @@ -72,9 +72,9 @@ static inline uint16_t mavlink_msg_param_value_pack(uint8_t system_id, uint8_t c * @param component_id ID of this component (e.g. 200 for IMU) * @param chan The MAVLink channel this message was sent over * @param msg The MAVLink message to compress the data into - * @param param_id Onboard parameter id + * @param param_id Onboard parameter id, terminated by NULL if the length is less than 16 human-readable chars and WITHOUT null termination (NULL) byte if the length is exactly 16 chars - applications have to provide 16+1 bytes storage if the ID is stored as string * @param param_value Onboard parameter value - * @param param_type Onboard parameter type: see MAV_VAR enum + * @param param_type Onboard parameter type: see the MAV_PARAM_TYPE enum for supported data types. * @param param_count Total number of onboard parameters * @param param_index Index of this onboard parameter * @return length of the message in bytes (excluding serial stream start sign) @@ -90,7 +90,7 @@ static inline uint16_t mavlink_msg_param_value_pack_chan(uint8_t system_id, uint _mav_put_uint16_t(buf, 6, param_index); _mav_put_uint8_t(buf, 24, param_type); _mav_put_char_array(buf, 8, param_id, 16); - memcpy(_MAV_PAYLOAD(msg), buf, 25); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 25); #else mavlink_param_value_t packet; packet.param_value = param_value; @@ -98,7 +98,7 @@ static inline uint16_t mavlink_msg_param_value_pack_chan(uint8_t system_id, uint packet.param_index = param_index; packet.param_type = param_type; mav_array_memcpy(packet.param_id, param_id, sizeof(char)*16); - memcpy(_MAV_PAYLOAD(msg), &packet, 25); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 25); #endif msg->msgid = MAVLINK_MSG_ID_PARAM_VALUE; @@ -122,9 +122,9 @@ static inline uint16_t mavlink_msg_param_value_encode(uint8_t system_id, uint8_t * @brief Send a param_value message * @param chan MAVLink channel to send the message * - * @param param_id Onboard parameter id + * @param param_id Onboard parameter id, terminated by NULL if the length is less than 16 human-readable chars and WITHOUT null termination (NULL) byte if the length is exactly 16 chars - applications have to provide 16+1 bytes storage if the ID is stored as string * @param param_value Onboard parameter value - * @param param_type Onboard parameter type: see MAV_VAR enum + * @param param_type Onboard parameter type: see the MAV_PARAM_TYPE enum for supported data types. * @param param_count Total number of onboard parameters * @param param_index Index of this onboard parameter */ @@ -159,7 +159,7 @@ static inline void mavlink_msg_param_value_send(mavlink_channel_t chan, const ch /** * @brief Get field param_id from param_value message * - * @return Onboard parameter id + * @return Onboard parameter id, terminated by NULL if the length is less than 16 human-readable chars and WITHOUT null termination (NULL) byte if the length is exactly 16 chars - applications have to provide 16+1 bytes storage if the ID is stored as string */ static inline uint16_t mavlink_msg_param_value_get_param_id(const mavlink_message_t* msg, char *param_id) { @@ -179,7 +179,7 @@ static inline float mavlink_msg_param_value_get_param_value(const mavlink_messag /** * @brief Get field param_type from param_value message * - * @return Onboard parameter type: see MAV_VAR enum + * @return Onboard parameter type: see the MAV_PARAM_TYPE enum for supported data types. */ static inline uint8_t mavlink_msg_param_value_get_param_type(const mavlink_message_t* msg) { diff --git a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_ping.h b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_ping.h index 8c4bf0cc8..3ed1b9d7c 100644 --- a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_ping.h +++ b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_ping.h @@ -48,7 +48,7 @@ static inline uint16_t mavlink_msg_ping_pack(uint8_t system_id, uint8_t componen _mav_put_uint8_t(buf, 12, target_system); _mav_put_uint8_t(buf, 13, target_component); - memcpy(_MAV_PAYLOAD(msg), buf, 14); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 14); #else mavlink_ping_t packet; packet.time_usec = time_usec; @@ -56,7 +56,7 @@ static inline uint16_t mavlink_msg_ping_pack(uint8_t system_id, uint8_t componen packet.target_system = target_system; packet.target_component = target_component; - memcpy(_MAV_PAYLOAD(msg), &packet, 14); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 14); #endif msg->msgid = MAVLINK_MSG_ID_PING; @@ -86,7 +86,7 @@ static inline uint16_t mavlink_msg_ping_pack_chan(uint8_t system_id, uint8_t com _mav_put_uint8_t(buf, 12, target_system); _mav_put_uint8_t(buf, 13, target_component); - memcpy(_MAV_PAYLOAD(msg), buf, 14); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 14); #else mavlink_ping_t packet; packet.time_usec = time_usec; @@ -94,7 +94,7 @@ static inline uint16_t mavlink_msg_ping_pack_chan(uint8_t system_id, uint8_t com packet.target_system = target_system; packet.target_component = target_component; - memcpy(_MAV_PAYLOAD(msg), &packet, 14); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 14); #endif msg->msgid = MAVLINK_MSG_ID_PING; diff --git a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_raw_imu.h b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_raw_imu.h index a8c398889..1c1d48388 100644 --- a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_raw_imu.h +++ b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_raw_imu.h @@ -72,7 +72,7 @@ static inline uint16_t mavlink_msg_raw_imu_pack(uint8_t system_id, uint8_t compo _mav_put_int16_t(buf, 22, ymag); _mav_put_int16_t(buf, 24, zmag); - memcpy(_MAV_PAYLOAD(msg), buf, 26); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 26); #else mavlink_raw_imu_t packet; packet.time_usec = time_usec; @@ -86,7 +86,7 @@ static inline uint16_t mavlink_msg_raw_imu_pack(uint8_t system_id, uint8_t compo packet.ymag = ymag; packet.zmag = zmag; - memcpy(_MAV_PAYLOAD(msg), &packet, 26); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 26); #endif msg->msgid = MAVLINK_MSG_ID_RAW_IMU; @@ -128,7 +128,7 @@ static inline uint16_t mavlink_msg_raw_imu_pack_chan(uint8_t system_id, uint8_t _mav_put_int16_t(buf, 22, ymag); _mav_put_int16_t(buf, 24, zmag); - memcpy(_MAV_PAYLOAD(msg), buf, 26); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 26); #else mavlink_raw_imu_t packet; packet.time_usec = time_usec; @@ -142,7 +142,7 @@ static inline uint16_t mavlink_msg_raw_imu_pack_chan(uint8_t system_id, uint8_t packet.ymag = ymag; packet.zmag = zmag; - memcpy(_MAV_PAYLOAD(msg), &packet, 26); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 26); #endif msg->msgid = MAVLINK_MSG_ID_RAW_IMU; diff --git a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_raw_pressure.h b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_raw_pressure.h index 29e631f39..f3e4e8404 100644 --- a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_raw_pressure.h +++ b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_raw_pressure.h @@ -52,7 +52,7 @@ static inline uint16_t mavlink_msg_raw_pressure_pack(uint8_t system_id, uint8_t _mav_put_int16_t(buf, 12, press_diff2); _mav_put_int16_t(buf, 14, temperature); - memcpy(_MAV_PAYLOAD(msg), buf, 16); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 16); #else mavlink_raw_pressure_t packet; packet.time_usec = time_usec; @@ -61,7 +61,7 @@ static inline uint16_t mavlink_msg_raw_pressure_pack(uint8_t system_id, uint8_t packet.press_diff2 = press_diff2; packet.temperature = temperature; - memcpy(_MAV_PAYLOAD(msg), &packet, 16); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 16); #endif msg->msgid = MAVLINK_MSG_ID_RAW_PRESSURE; @@ -93,7 +93,7 @@ static inline uint16_t mavlink_msg_raw_pressure_pack_chan(uint8_t system_id, uin _mav_put_int16_t(buf, 12, press_diff2); _mav_put_int16_t(buf, 14, temperature); - memcpy(_MAV_PAYLOAD(msg), buf, 16); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 16); #else mavlink_raw_pressure_t packet; packet.time_usec = time_usec; @@ -102,7 +102,7 @@ static inline uint16_t mavlink_msg_raw_pressure_pack_chan(uint8_t system_id, uin packet.press_diff2 = press_diff2; packet.temperature = temperature; - memcpy(_MAV_PAYLOAD(msg), &packet, 16); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 16); #endif msg->msgid = MAVLINK_MSG_ID_RAW_PRESSURE; diff --git a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_rc_channels_override.h b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_rc_channels_override.h index 6eccf7ae8..d719c7fca 100644 --- a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_rc_channels_override.h +++ b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_rc_channels_override.h @@ -72,7 +72,7 @@ static inline uint16_t mavlink_msg_rc_channels_override_pack(uint8_t system_id, _mav_put_uint8_t(buf, 16, target_system); _mav_put_uint8_t(buf, 17, target_component); - memcpy(_MAV_PAYLOAD(msg), buf, 18); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 18); #else mavlink_rc_channels_override_t packet; packet.chan1_raw = chan1_raw; @@ -86,7 +86,7 @@ static inline uint16_t mavlink_msg_rc_channels_override_pack(uint8_t system_id, packet.target_system = target_system; packet.target_component = target_component; - memcpy(_MAV_PAYLOAD(msg), &packet, 18); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 18); #endif msg->msgid = MAVLINK_MSG_ID_RC_CHANNELS_OVERRIDE; @@ -128,7 +128,7 @@ static inline uint16_t mavlink_msg_rc_channels_override_pack_chan(uint8_t system _mav_put_uint8_t(buf, 16, target_system); _mav_put_uint8_t(buf, 17, target_component); - memcpy(_MAV_PAYLOAD(msg), buf, 18); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 18); #else mavlink_rc_channels_override_t packet; packet.chan1_raw = chan1_raw; @@ -142,7 +142,7 @@ static inline uint16_t mavlink_msg_rc_channels_override_pack_chan(uint8_t system packet.target_system = target_system; packet.target_component = target_component; - memcpy(_MAV_PAYLOAD(msg), &packet, 18); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 18); #endif msg->msgid = MAVLINK_MSG_ID_RC_CHANNELS_OVERRIDE; diff --git a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_rc_channels_raw.h b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_rc_channels_raw.h index 1c25d1a3b..a4d40da38 100644 --- a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_rc_channels_raw.h +++ b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_rc_channels_raw.h @@ -5,16 +5,16 @@ typedef struct __mavlink_rc_channels_raw_t { uint32_t time_boot_ms; ///< Timestamp (milliseconds since system boot) - uint16_t chan1_raw; ///< RC channel 1 value, in microseconds - uint16_t chan2_raw; ///< RC channel 2 value, in microseconds - uint16_t chan3_raw; ///< RC channel 3 value, in microseconds - uint16_t chan4_raw; ///< RC channel 4 value, in microseconds - uint16_t chan5_raw; ///< RC channel 5 value, in microseconds - uint16_t chan6_raw; ///< RC channel 6 value, in microseconds - uint16_t chan7_raw; ///< RC channel 7 value, in microseconds - uint16_t chan8_raw; ///< RC channel 8 value, in microseconds - uint8_t port; ///< Servo output port (set of 8 outputs = 1 port). Most MAVs will just use one, but this allows to encode more than 8 servos. - uint8_t rssi; ///< Receive signal strength indicator, 0: 0%, 255: 100% + uint16_t chan1_raw; ///< RC channel 1 value, in microseconds. A value of 65535 implies the channel is unused. + uint16_t chan2_raw; ///< RC channel 2 value, in microseconds. A value of 65535 implies the channel is unused. + uint16_t chan3_raw; ///< RC channel 3 value, in microseconds. A value of 65535 implies the channel is unused. + uint16_t chan4_raw; ///< RC channel 4 value, in microseconds. A value of 65535 implies the channel is unused. + uint16_t chan5_raw; ///< RC channel 5 value, in microseconds. A value of 65535 implies the channel is unused. + uint16_t chan6_raw; ///< RC channel 6 value, in microseconds. A value of 65535 implies the channel is unused. + uint16_t chan7_raw; ///< RC channel 7 value, in microseconds. A value of 65535 implies the channel is unused. + uint16_t chan8_raw; ///< RC channel 8 value, in microseconds. A value of 65535 implies the channel is unused. + uint8_t port; ///< Servo output port (set of 8 outputs = 1 port). Most MAVs will just use one, but this allows for more than 8 servos. + uint8_t rssi; ///< Receive signal strength indicator, 0: 0%, 100: 100%, 255: invalid/unknown. } mavlink_rc_channels_raw_t; #define MAVLINK_MSG_ID_RC_CHANNELS_RAW_LEN 22 @@ -47,16 +47,16 @@ typedef struct __mavlink_rc_channels_raw_t * @param msg The MAVLink message to compress the data into * * @param time_boot_ms Timestamp (milliseconds since system boot) - * @param port Servo output port (set of 8 outputs = 1 port). Most MAVs will just use one, but this allows to encode more than 8 servos. - * @param chan1_raw RC channel 1 value, in microseconds - * @param chan2_raw RC channel 2 value, in microseconds - * @param chan3_raw RC channel 3 value, in microseconds - * @param chan4_raw RC channel 4 value, in microseconds - * @param chan5_raw RC channel 5 value, in microseconds - * @param chan6_raw RC channel 6 value, in microseconds - * @param chan7_raw RC channel 7 value, in microseconds - * @param chan8_raw RC channel 8 value, in microseconds - * @param rssi Receive signal strength indicator, 0: 0%, 255: 100% + * @param port Servo output port (set of 8 outputs = 1 port). Most MAVs will just use one, but this allows for more than 8 servos. + * @param chan1_raw RC channel 1 value, in microseconds. A value of 65535 implies the channel is unused. + * @param chan2_raw RC channel 2 value, in microseconds. A value of 65535 implies the channel is unused. + * @param chan3_raw RC channel 3 value, in microseconds. A value of 65535 implies the channel is unused. + * @param chan4_raw RC channel 4 value, in microseconds. A value of 65535 implies the channel is unused. + * @param chan5_raw RC channel 5 value, in microseconds. A value of 65535 implies the channel is unused. + * @param chan6_raw RC channel 6 value, in microseconds. A value of 65535 implies the channel is unused. + * @param chan7_raw RC channel 7 value, in microseconds. A value of 65535 implies the channel is unused. + * @param chan8_raw RC channel 8 value, in microseconds. A value of 65535 implies the channel is unused. + * @param rssi Receive signal strength indicator, 0: 0%, 100: 100%, 255: invalid/unknown. * @return length of the message in bytes (excluding serial stream start sign) */ static inline uint16_t mavlink_msg_rc_channels_raw_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, @@ -76,7 +76,7 @@ static inline uint16_t mavlink_msg_rc_channels_raw_pack(uint8_t system_id, uint8 _mav_put_uint8_t(buf, 20, port); _mav_put_uint8_t(buf, 21, rssi); - memcpy(_MAV_PAYLOAD(msg), buf, 22); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 22); #else mavlink_rc_channels_raw_t packet; packet.time_boot_ms = time_boot_ms; @@ -91,7 +91,7 @@ static inline uint16_t mavlink_msg_rc_channels_raw_pack(uint8_t system_id, uint8 packet.port = port; packet.rssi = rssi; - memcpy(_MAV_PAYLOAD(msg), &packet, 22); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 22); #endif msg->msgid = MAVLINK_MSG_ID_RC_CHANNELS_RAW; @@ -105,16 +105,16 @@ static inline uint16_t mavlink_msg_rc_channels_raw_pack(uint8_t system_id, uint8 * @param chan The MAVLink channel this message was sent over * @param msg The MAVLink message to compress the data into * @param time_boot_ms Timestamp (milliseconds since system boot) - * @param port Servo output port (set of 8 outputs = 1 port). Most MAVs will just use one, but this allows to encode more than 8 servos. - * @param chan1_raw RC channel 1 value, in microseconds - * @param chan2_raw RC channel 2 value, in microseconds - * @param chan3_raw RC channel 3 value, in microseconds - * @param chan4_raw RC channel 4 value, in microseconds - * @param chan5_raw RC channel 5 value, in microseconds - * @param chan6_raw RC channel 6 value, in microseconds - * @param chan7_raw RC channel 7 value, in microseconds - * @param chan8_raw RC channel 8 value, in microseconds - * @param rssi Receive signal strength indicator, 0: 0%, 255: 100% + * @param port Servo output port (set of 8 outputs = 1 port). Most MAVs will just use one, but this allows for more than 8 servos. + * @param chan1_raw RC channel 1 value, in microseconds. A value of 65535 implies the channel is unused. + * @param chan2_raw RC channel 2 value, in microseconds. A value of 65535 implies the channel is unused. + * @param chan3_raw RC channel 3 value, in microseconds. A value of 65535 implies the channel is unused. + * @param chan4_raw RC channel 4 value, in microseconds. A value of 65535 implies the channel is unused. + * @param chan5_raw RC channel 5 value, in microseconds. A value of 65535 implies the channel is unused. + * @param chan6_raw RC channel 6 value, in microseconds. A value of 65535 implies the channel is unused. + * @param chan7_raw RC channel 7 value, in microseconds. A value of 65535 implies the channel is unused. + * @param chan8_raw RC channel 8 value, in microseconds. A value of 65535 implies the channel is unused. + * @param rssi Receive signal strength indicator, 0: 0%, 100: 100%, 255: invalid/unknown. * @return length of the message in bytes (excluding serial stream start sign) */ static inline uint16_t mavlink_msg_rc_channels_raw_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, @@ -135,7 +135,7 @@ static inline uint16_t mavlink_msg_rc_channels_raw_pack_chan(uint8_t system_id, _mav_put_uint8_t(buf, 20, port); _mav_put_uint8_t(buf, 21, rssi); - memcpy(_MAV_PAYLOAD(msg), buf, 22); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 22); #else mavlink_rc_channels_raw_t packet; packet.time_boot_ms = time_boot_ms; @@ -150,7 +150,7 @@ static inline uint16_t mavlink_msg_rc_channels_raw_pack_chan(uint8_t system_id, packet.port = port; packet.rssi = rssi; - memcpy(_MAV_PAYLOAD(msg), &packet, 22); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 22); #endif msg->msgid = MAVLINK_MSG_ID_RC_CHANNELS_RAW; @@ -175,16 +175,16 @@ static inline uint16_t mavlink_msg_rc_channels_raw_encode(uint8_t system_id, uin * @param chan MAVLink channel to send the message * * @param time_boot_ms Timestamp (milliseconds since system boot) - * @param port Servo output port (set of 8 outputs = 1 port). Most MAVs will just use one, but this allows to encode more than 8 servos. - * @param chan1_raw RC channel 1 value, in microseconds - * @param chan2_raw RC channel 2 value, in microseconds - * @param chan3_raw RC channel 3 value, in microseconds - * @param chan4_raw RC channel 4 value, in microseconds - * @param chan5_raw RC channel 5 value, in microseconds - * @param chan6_raw RC channel 6 value, in microseconds - * @param chan7_raw RC channel 7 value, in microseconds - * @param chan8_raw RC channel 8 value, in microseconds - * @param rssi Receive signal strength indicator, 0: 0%, 255: 100% + * @param port Servo output port (set of 8 outputs = 1 port). Most MAVs will just use one, but this allows for more than 8 servos. + * @param chan1_raw RC channel 1 value, in microseconds. A value of 65535 implies the channel is unused. + * @param chan2_raw RC channel 2 value, in microseconds. A value of 65535 implies the channel is unused. + * @param chan3_raw RC channel 3 value, in microseconds. A value of 65535 implies the channel is unused. + * @param chan4_raw RC channel 4 value, in microseconds. A value of 65535 implies the channel is unused. + * @param chan5_raw RC channel 5 value, in microseconds. A value of 65535 implies the channel is unused. + * @param chan6_raw RC channel 6 value, in microseconds. A value of 65535 implies the channel is unused. + * @param chan7_raw RC channel 7 value, in microseconds. A value of 65535 implies the channel is unused. + * @param chan8_raw RC channel 8 value, in microseconds. A value of 65535 implies the channel is unused. + * @param rssi Receive signal strength indicator, 0: 0%, 100: 100%, 255: invalid/unknown. */ #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS @@ -241,7 +241,7 @@ static inline uint32_t mavlink_msg_rc_channels_raw_get_time_boot_ms(const mavlin /** * @brief Get field port from rc_channels_raw message * - * @return Servo output port (set of 8 outputs = 1 port). Most MAVs will just use one, but this allows to encode more than 8 servos. + * @return Servo output port (set of 8 outputs = 1 port). Most MAVs will just use one, but this allows for more than 8 servos. */ static inline uint8_t mavlink_msg_rc_channels_raw_get_port(const mavlink_message_t* msg) { @@ -251,7 +251,7 @@ static inline uint8_t mavlink_msg_rc_channels_raw_get_port(const mavlink_message /** * @brief Get field chan1_raw from rc_channels_raw message * - * @return RC channel 1 value, in microseconds + * @return RC channel 1 value, in microseconds. A value of 65535 implies the channel is unused. */ static inline uint16_t mavlink_msg_rc_channels_raw_get_chan1_raw(const mavlink_message_t* msg) { @@ -261,7 +261,7 @@ static inline uint16_t mavlink_msg_rc_channels_raw_get_chan1_raw(const mavlink_m /** * @brief Get field chan2_raw from rc_channels_raw message * - * @return RC channel 2 value, in microseconds + * @return RC channel 2 value, in microseconds. A value of 65535 implies the channel is unused. */ static inline uint16_t mavlink_msg_rc_channels_raw_get_chan2_raw(const mavlink_message_t* msg) { @@ -271,7 +271,7 @@ static inline uint16_t mavlink_msg_rc_channels_raw_get_chan2_raw(const mavlink_m /** * @brief Get field chan3_raw from rc_channels_raw message * - * @return RC channel 3 value, in microseconds + * @return RC channel 3 value, in microseconds. A value of 65535 implies the channel is unused. */ static inline uint16_t mavlink_msg_rc_channels_raw_get_chan3_raw(const mavlink_message_t* msg) { @@ -281,7 +281,7 @@ static inline uint16_t mavlink_msg_rc_channels_raw_get_chan3_raw(const mavlink_m /** * @brief Get field chan4_raw from rc_channels_raw message * - * @return RC channel 4 value, in microseconds + * @return RC channel 4 value, in microseconds. A value of 65535 implies the channel is unused. */ static inline uint16_t mavlink_msg_rc_channels_raw_get_chan4_raw(const mavlink_message_t* msg) { @@ -291,7 +291,7 @@ static inline uint16_t mavlink_msg_rc_channels_raw_get_chan4_raw(const mavlink_m /** * @brief Get field chan5_raw from rc_channels_raw message * - * @return RC channel 5 value, in microseconds + * @return RC channel 5 value, in microseconds. A value of 65535 implies the channel is unused. */ static inline uint16_t mavlink_msg_rc_channels_raw_get_chan5_raw(const mavlink_message_t* msg) { @@ -301,7 +301,7 @@ static inline uint16_t mavlink_msg_rc_channels_raw_get_chan5_raw(const mavlink_m /** * @brief Get field chan6_raw from rc_channels_raw message * - * @return RC channel 6 value, in microseconds + * @return RC channel 6 value, in microseconds. A value of 65535 implies the channel is unused. */ static inline uint16_t mavlink_msg_rc_channels_raw_get_chan6_raw(const mavlink_message_t* msg) { @@ -311,7 +311,7 @@ static inline uint16_t mavlink_msg_rc_channels_raw_get_chan6_raw(const mavlink_m /** * @brief Get field chan7_raw from rc_channels_raw message * - * @return RC channel 7 value, in microseconds + * @return RC channel 7 value, in microseconds. A value of 65535 implies the channel is unused. */ static inline uint16_t mavlink_msg_rc_channels_raw_get_chan7_raw(const mavlink_message_t* msg) { @@ -321,7 +321,7 @@ static inline uint16_t mavlink_msg_rc_channels_raw_get_chan7_raw(const mavlink_m /** * @brief Get field chan8_raw from rc_channels_raw message * - * @return RC channel 8 value, in microseconds + * @return RC channel 8 value, in microseconds. A value of 65535 implies the channel is unused. */ static inline uint16_t mavlink_msg_rc_channels_raw_get_chan8_raw(const mavlink_message_t* msg) { @@ -331,7 +331,7 @@ static inline uint16_t mavlink_msg_rc_channels_raw_get_chan8_raw(const mavlink_m /** * @brief Get field rssi from rc_channels_raw message * - * @return Receive signal strength indicator, 0: 0%, 255: 100% + * @return Receive signal strength indicator, 0: 0%, 100: 100%, 255: invalid/unknown. */ static inline uint8_t mavlink_msg_rc_channels_raw_get_rssi(const mavlink_message_t* msg) { diff --git a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_rc_channels_scaled.h b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_rc_channels_scaled.h index a7a4e5b97..dd21d4162 100644 --- a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_rc_channels_scaled.h +++ b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_rc_channels_scaled.h @@ -5,16 +5,16 @@ typedef struct __mavlink_rc_channels_scaled_t { uint32_t time_boot_ms; ///< Timestamp (milliseconds since system boot) - int16_t chan1_scaled; ///< RC channel 1 value scaled, (-100%) -10000, (0%) 0, (100%) 10000 - int16_t chan2_scaled; ///< RC channel 2 value scaled, (-100%) -10000, (0%) 0, (100%) 10000 - int16_t chan3_scaled; ///< RC channel 3 value scaled, (-100%) -10000, (0%) 0, (100%) 10000 - int16_t chan4_scaled; ///< RC channel 4 value scaled, (-100%) -10000, (0%) 0, (100%) 10000 - int16_t chan5_scaled; ///< RC channel 5 value scaled, (-100%) -10000, (0%) 0, (100%) 10000 - int16_t chan6_scaled; ///< RC channel 6 value scaled, (-100%) -10000, (0%) 0, (100%) 10000 - int16_t chan7_scaled; ///< RC channel 7 value scaled, (-100%) -10000, (0%) 0, (100%) 10000 - int16_t chan8_scaled; ///< RC channel 8 value scaled, (-100%) -10000, (0%) 0, (100%) 10000 - uint8_t port; ///< Servo output port (set of 8 outputs = 1 port). Most MAVs will just use one, but this allows to encode more than 8 servos. - uint8_t rssi; ///< Receive signal strength indicator, 0: 0%, 255: 100% + int16_t chan1_scaled; ///< RC channel 1 value scaled, (-100%) -10000, (0%) 0, (100%) 10000, (invalid) 32767. + int16_t chan2_scaled; ///< RC channel 2 value scaled, (-100%) -10000, (0%) 0, (100%) 10000, (invalid) 32767. + int16_t chan3_scaled; ///< RC channel 3 value scaled, (-100%) -10000, (0%) 0, (100%) 10000, (invalid) 32767. + int16_t chan4_scaled; ///< RC channel 4 value scaled, (-100%) -10000, (0%) 0, (100%) 10000, (invalid) 32767. + int16_t chan5_scaled; ///< RC channel 5 value scaled, (-100%) -10000, (0%) 0, (100%) 10000, (invalid) 32767. + int16_t chan6_scaled; ///< RC channel 6 value scaled, (-100%) -10000, (0%) 0, (100%) 10000, (invalid) 32767. + int16_t chan7_scaled; ///< RC channel 7 value scaled, (-100%) -10000, (0%) 0, (100%) 10000, (invalid) 32767. + int16_t chan8_scaled; ///< RC channel 8 value scaled, (-100%) -10000, (0%) 0, (100%) 10000, (invalid) 32767. + uint8_t port; ///< Servo output port (set of 8 outputs = 1 port). Most MAVs will just use one, but this allows for more than 8 servos. + uint8_t rssi; ///< Receive signal strength indicator, 0: 0%, 100: 100%, 255: invalid/unknown. } mavlink_rc_channels_scaled_t; #define MAVLINK_MSG_ID_RC_CHANNELS_SCALED_LEN 22 @@ -47,16 +47,16 @@ typedef struct __mavlink_rc_channels_scaled_t * @param msg The MAVLink message to compress the data into * * @param time_boot_ms Timestamp (milliseconds since system boot) - * @param port Servo output port (set of 8 outputs = 1 port). Most MAVs will just use one, but this allows to encode more than 8 servos. - * @param chan1_scaled RC channel 1 value scaled, (-100%) -10000, (0%) 0, (100%) 10000 - * @param chan2_scaled RC channel 2 value scaled, (-100%) -10000, (0%) 0, (100%) 10000 - * @param chan3_scaled RC channel 3 value scaled, (-100%) -10000, (0%) 0, (100%) 10000 - * @param chan4_scaled RC channel 4 value scaled, (-100%) -10000, (0%) 0, (100%) 10000 - * @param chan5_scaled RC channel 5 value scaled, (-100%) -10000, (0%) 0, (100%) 10000 - * @param chan6_scaled RC channel 6 value scaled, (-100%) -10000, (0%) 0, (100%) 10000 - * @param chan7_scaled RC channel 7 value scaled, (-100%) -10000, (0%) 0, (100%) 10000 - * @param chan8_scaled RC channel 8 value scaled, (-100%) -10000, (0%) 0, (100%) 10000 - * @param rssi Receive signal strength indicator, 0: 0%, 255: 100% + * @param port Servo output port (set of 8 outputs = 1 port). Most MAVs will just use one, but this allows for more than 8 servos. + * @param chan1_scaled RC channel 1 value scaled, (-100%) -10000, (0%) 0, (100%) 10000, (invalid) 32767. + * @param chan2_scaled RC channel 2 value scaled, (-100%) -10000, (0%) 0, (100%) 10000, (invalid) 32767. + * @param chan3_scaled RC channel 3 value scaled, (-100%) -10000, (0%) 0, (100%) 10000, (invalid) 32767. + * @param chan4_scaled RC channel 4 value scaled, (-100%) -10000, (0%) 0, (100%) 10000, (invalid) 32767. + * @param chan5_scaled RC channel 5 value scaled, (-100%) -10000, (0%) 0, (100%) 10000, (invalid) 32767. + * @param chan6_scaled RC channel 6 value scaled, (-100%) -10000, (0%) 0, (100%) 10000, (invalid) 32767. + * @param chan7_scaled RC channel 7 value scaled, (-100%) -10000, (0%) 0, (100%) 10000, (invalid) 32767. + * @param chan8_scaled RC channel 8 value scaled, (-100%) -10000, (0%) 0, (100%) 10000, (invalid) 32767. + * @param rssi Receive signal strength indicator, 0: 0%, 100: 100%, 255: invalid/unknown. * @return length of the message in bytes (excluding serial stream start sign) */ static inline uint16_t mavlink_msg_rc_channels_scaled_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, @@ -76,7 +76,7 @@ static inline uint16_t mavlink_msg_rc_channels_scaled_pack(uint8_t system_id, ui _mav_put_uint8_t(buf, 20, port); _mav_put_uint8_t(buf, 21, rssi); - memcpy(_MAV_PAYLOAD(msg), buf, 22); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 22); #else mavlink_rc_channels_scaled_t packet; packet.time_boot_ms = time_boot_ms; @@ -91,7 +91,7 @@ static inline uint16_t mavlink_msg_rc_channels_scaled_pack(uint8_t system_id, ui packet.port = port; packet.rssi = rssi; - memcpy(_MAV_PAYLOAD(msg), &packet, 22); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 22); #endif msg->msgid = MAVLINK_MSG_ID_RC_CHANNELS_SCALED; @@ -105,16 +105,16 @@ static inline uint16_t mavlink_msg_rc_channels_scaled_pack(uint8_t system_id, ui * @param chan The MAVLink channel this message was sent over * @param msg The MAVLink message to compress the data into * @param time_boot_ms Timestamp (milliseconds since system boot) - * @param port Servo output port (set of 8 outputs = 1 port). Most MAVs will just use one, but this allows to encode more than 8 servos. - * @param chan1_scaled RC channel 1 value scaled, (-100%) -10000, (0%) 0, (100%) 10000 - * @param chan2_scaled RC channel 2 value scaled, (-100%) -10000, (0%) 0, (100%) 10000 - * @param chan3_scaled RC channel 3 value scaled, (-100%) -10000, (0%) 0, (100%) 10000 - * @param chan4_scaled RC channel 4 value scaled, (-100%) -10000, (0%) 0, (100%) 10000 - * @param chan5_scaled RC channel 5 value scaled, (-100%) -10000, (0%) 0, (100%) 10000 - * @param chan6_scaled RC channel 6 value scaled, (-100%) -10000, (0%) 0, (100%) 10000 - * @param chan7_scaled RC channel 7 value scaled, (-100%) -10000, (0%) 0, (100%) 10000 - * @param chan8_scaled RC channel 8 value scaled, (-100%) -10000, (0%) 0, (100%) 10000 - * @param rssi Receive signal strength indicator, 0: 0%, 255: 100% + * @param port Servo output port (set of 8 outputs = 1 port). Most MAVs will just use one, but this allows for more than 8 servos. + * @param chan1_scaled RC channel 1 value scaled, (-100%) -10000, (0%) 0, (100%) 10000, (invalid) 32767. + * @param chan2_scaled RC channel 2 value scaled, (-100%) -10000, (0%) 0, (100%) 10000, (invalid) 32767. + * @param chan3_scaled RC channel 3 value scaled, (-100%) -10000, (0%) 0, (100%) 10000, (invalid) 32767. + * @param chan4_scaled RC channel 4 value scaled, (-100%) -10000, (0%) 0, (100%) 10000, (invalid) 32767. + * @param chan5_scaled RC channel 5 value scaled, (-100%) -10000, (0%) 0, (100%) 10000, (invalid) 32767. + * @param chan6_scaled RC channel 6 value scaled, (-100%) -10000, (0%) 0, (100%) 10000, (invalid) 32767. + * @param chan7_scaled RC channel 7 value scaled, (-100%) -10000, (0%) 0, (100%) 10000, (invalid) 32767. + * @param chan8_scaled RC channel 8 value scaled, (-100%) -10000, (0%) 0, (100%) 10000, (invalid) 32767. + * @param rssi Receive signal strength indicator, 0: 0%, 100: 100%, 255: invalid/unknown. * @return length of the message in bytes (excluding serial stream start sign) */ static inline uint16_t mavlink_msg_rc_channels_scaled_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, @@ -135,7 +135,7 @@ static inline uint16_t mavlink_msg_rc_channels_scaled_pack_chan(uint8_t system_i _mav_put_uint8_t(buf, 20, port); _mav_put_uint8_t(buf, 21, rssi); - memcpy(_MAV_PAYLOAD(msg), buf, 22); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 22); #else mavlink_rc_channels_scaled_t packet; packet.time_boot_ms = time_boot_ms; @@ -150,7 +150,7 @@ static inline uint16_t mavlink_msg_rc_channels_scaled_pack_chan(uint8_t system_i packet.port = port; packet.rssi = rssi; - memcpy(_MAV_PAYLOAD(msg), &packet, 22); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 22); #endif msg->msgid = MAVLINK_MSG_ID_RC_CHANNELS_SCALED; @@ -175,16 +175,16 @@ static inline uint16_t mavlink_msg_rc_channels_scaled_encode(uint8_t system_id, * @param chan MAVLink channel to send the message * * @param time_boot_ms Timestamp (milliseconds since system boot) - * @param port Servo output port (set of 8 outputs = 1 port). Most MAVs will just use one, but this allows to encode more than 8 servos. - * @param chan1_scaled RC channel 1 value scaled, (-100%) -10000, (0%) 0, (100%) 10000 - * @param chan2_scaled RC channel 2 value scaled, (-100%) -10000, (0%) 0, (100%) 10000 - * @param chan3_scaled RC channel 3 value scaled, (-100%) -10000, (0%) 0, (100%) 10000 - * @param chan4_scaled RC channel 4 value scaled, (-100%) -10000, (0%) 0, (100%) 10000 - * @param chan5_scaled RC channel 5 value scaled, (-100%) -10000, (0%) 0, (100%) 10000 - * @param chan6_scaled RC channel 6 value scaled, (-100%) -10000, (0%) 0, (100%) 10000 - * @param chan7_scaled RC channel 7 value scaled, (-100%) -10000, (0%) 0, (100%) 10000 - * @param chan8_scaled RC channel 8 value scaled, (-100%) -10000, (0%) 0, (100%) 10000 - * @param rssi Receive signal strength indicator, 0: 0%, 255: 100% + * @param port Servo output port (set of 8 outputs = 1 port). Most MAVs will just use one, but this allows for more than 8 servos. + * @param chan1_scaled RC channel 1 value scaled, (-100%) -10000, (0%) 0, (100%) 10000, (invalid) 32767. + * @param chan2_scaled RC channel 2 value scaled, (-100%) -10000, (0%) 0, (100%) 10000, (invalid) 32767. + * @param chan3_scaled RC channel 3 value scaled, (-100%) -10000, (0%) 0, (100%) 10000, (invalid) 32767. + * @param chan4_scaled RC channel 4 value scaled, (-100%) -10000, (0%) 0, (100%) 10000, (invalid) 32767. + * @param chan5_scaled RC channel 5 value scaled, (-100%) -10000, (0%) 0, (100%) 10000, (invalid) 32767. + * @param chan6_scaled RC channel 6 value scaled, (-100%) -10000, (0%) 0, (100%) 10000, (invalid) 32767. + * @param chan7_scaled RC channel 7 value scaled, (-100%) -10000, (0%) 0, (100%) 10000, (invalid) 32767. + * @param chan8_scaled RC channel 8 value scaled, (-100%) -10000, (0%) 0, (100%) 10000, (invalid) 32767. + * @param rssi Receive signal strength indicator, 0: 0%, 100: 100%, 255: invalid/unknown. */ #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS @@ -241,7 +241,7 @@ static inline uint32_t mavlink_msg_rc_channels_scaled_get_time_boot_ms(const mav /** * @brief Get field port from rc_channels_scaled message * - * @return Servo output port (set of 8 outputs = 1 port). Most MAVs will just use one, but this allows to encode more than 8 servos. + * @return Servo output port (set of 8 outputs = 1 port). Most MAVs will just use one, but this allows for more than 8 servos. */ static inline uint8_t mavlink_msg_rc_channels_scaled_get_port(const mavlink_message_t* msg) { @@ -251,7 +251,7 @@ static inline uint8_t mavlink_msg_rc_channels_scaled_get_port(const mavlink_mess /** * @brief Get field chan1_scaled from rc_channels_scaled message * - * @return RC channel 1 value scaled, (-100%) -10000, (0%) 0, (100%) 10000 + * @return RC channel 1 value scaled, (-100%) -10000, (0%) 0, (100%) 10000, (invalid) 32767. */ static inline int16_t mavlink_msg_rc_channels_scaled_get_chan1_scaled(const mavlink_message_t* msg) { @@ -261,7 +261,7 @@ static inline int16_t mavlink_msg_rc_channels_scaled_get_chan1_scaled(const mavl /** * @brief Get field chan2_scaled from rc_channels_scaled message * - * @return RC channel 2 value scaled, (-100%) -10000, (0%) 0, (100%) 10000 + * @return RC channel 2 value scaled, (-100%) -10000, (0%) 0, (100%) 10000, (invalid) 32767. */ static inline int16_t mavlink_msg_rc_channels_scaled_get_chan2_scaled(const mavlink_message_t* msg) { @@ -271,7 +271,7 @@ static inline int16_t mavlink_msg_rc_channels_scaled_get_chan2_scaled(const mavl /** * @brief Get field chan3_scaled from rc_channels_scaled message * - * @return RC channel 3 value scaled, (-100%) -10000, (0%) 0, (100%) 10000 + * @return RC channel 3 value scaled, (-100%) -10000, (0%) 0, (100%) 10000, (invalid) 32767. */ static inline int16_t mavlink_msg_rc_channels_scaled_get_chan3_scaled(const mavlink_message_t* msg) { @@ -281,7 +281,7 @@ static inline int16_t mavlink_msg_rc_channels_scaled_get_chan3_scaled(const mavl /** * @brief Get field chan4_scaled from rc_channels_scaled message * - * @return RC channel 4 value scaled, (-100%) -10000, (0%) 0, (100%) 10000 + * @return RC channel 4 value scaled, (-100%) -10000, (0%) 0, (100%) 10000, (invalid) 32767. */ static inline int16_t mavlink_msg_rc_channels_scaled_get_chan4_scaled(const mavlink_message_t* msg) { @@ -291,7 +291,7 @@ static inline int16_t mavlink_msg_rc_channels_scaled_get_chan4_scaled(const mavl /** * @brief Get field chan5_scaled from rc_channels_scaled message * - * @return RC channel 5 value scaled, (-100%) -10000, (0%) 0, (100%) 10000 + * @return RC channel 5 value scaled, (-100%) -10000, (0%) 0, (100%) 10000, (invalid) 32767. */ static inline int16_t mavlink_msg_rc_channels_scaled_get_chan5_scaled(const mavlink_message_t* msg) { @@ -301,7 +301,7 @@ static inline int16_t mavlink_msg_rc_channels_scaled_get_chan5_scaled(const mavl /** * @brief Get field chan6_scaled from rc_channels_scaled message * - * @return RC channel 6 value scaled, (-100%) -10000, (0%) 0, (100%) 10000 + * @return RC channel 6 value scaled, (-100%) -10000, (0%) 0, (100%) 10000, (invalid) 32767. */ static inline int16_t mavlink_msg_rc_channels_scaled_get_chan6_scaled(const mavlink_message_t* msg) { @@ -311,7 +311,7 @@ static inline int16_t mavlink_msg_rc_channels_scaled_get_chan6_scaled(const mavl /** * @brief Get field chan7_scaled from rc_channels_scaled message * - * @return RC channel 7 value scaled, (-100%) -10000, (0%) 0, (100%) 10000 + * @return RC channel 7 value scaled, (-100%) -10000, (0%) 0, (100%) 10000, (invalid) 32767. */ static inline int16_t mavlink_msg_rc_channels_scaled_get_chan7_scaled(const mavlink_message_t* msg) { @@ -321,7 +321,7 @@ static inline int16_t mavlink_msg_rc_channels_scaled_get_chan7_scaled(const mavl /** * @brief Get field chan8_scaled from rc_channels_scaled message * - * @return RC channel 8 value scaled, (-100%) -10000, (0%) 0, (100%) 10000 + * @return RC channel 8 value scaled, (-100%) -10000, (0%) 0, (100%) 10000, (invalid) 32767. */ static inline int16_t mavlink_msg_rc_channels_scaled_get_chan8_scaled(const mavlink_message_t* msg) { @@ -331,7 +331,7 @@ static inline int16_t mavlink_msg_rc_channels_scaled_get_chan8_scaled(const mavl /** * @brief Get field rssi from rc_channels_scaled message * - * @return Receive signal strength indicator, 0: 0%, 255: 100% + * @return Receive signal strength indicator, 0: 0%, 100: 100%, 255: invalid/unknown. */ static inline uint8_t mavlink_msg_rc_channels_scaled_get_rssi(const mavlink_message_t* msg) { diff --git a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_request_data_stream.h b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_request_data_stream.h index 9889bfc08..d8653ad10 100644 --- a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_request_data_stream.h +++ b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_request_data_stream.h @@ -52,7 +52,7 @@ static inline uint16_t mavlink_msg_request_data_stream_pack(uint8_t system_id, u _mav_put_uint8_t(buf, 4, req_stream_id); _mav_put_uint8_t(buf, 5, start_stop); - memcpy(_MAV_PAYLOAD(msg), buf, 6); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 6); #else mavlink_request_data_stream_t packet; packet.req_message_rate = req_message_rate; @@ -61,7 +61,7 @@ static inline uint16_t mavlink_msg_request_data_stream_pack(uint8_t system_id, u packet.req_stream_id = req_stream_id; packet.start_stop = start_stop; - memcpy(_MAV_PAYLOAD(msg), &packet, 6); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 6); #endif msg->msgid = MAVLINK_MSG_ID_REQUEST_DATA_STREAM; @@ -93,7 +93,7 @@ static inline uint16_t mavlink_msg_request_data_stream_pack_chan(uint8_t system_ _mav_put_uint8_t(buf, 4, req_stream_id); _mav_put_uint8_t(buf, 5, start_stop); - memcpy(_MAV_PAYLOAD(msg), buf, 6); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 6); #else mavlink_request_data_stream_t packet; packet.req_message_rate = req_message_rate; @@ -102,7 +102,7 @@ static inline uint16_t mavlink_msg_request_data_stream_pack_chan(uint8_t system_ packet.req_stream_id = req_stream_id; packet.start_stop = start_stop; - memcpy(_MAV_PAYLOAD(msg), &packet, 6); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 6); #endif msg->msgid = MAVLINK_MSG_ID_REQUEST_DATA_STREAM; diff --git a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_roll_pitch_yaw_rates_thrust_setpoint.h b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_roll_pitch_yaw_rates_thrust_setpoint.h new file mode 100644 index 000000000..47772e004 --- /dev/null +++ b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_roll_pitch_yaw_rates_thrust_setpoint.h @@ -0,0 +1,232 @@ +// MESSAGE ROLL_PITCH_YAW_RATES_THRUST_SETPOINT PACKING + +#define MAVLINK_MSG_ID_ROLL_PITCH_YAW_RATES_THRUST_SETPOINT 80 + +typedef struct __mavlink_roll_pitch_yaw_rates_thrust_setpoint_t +{ + uint32_t time_boot_ms; ///< Timestamp in milliseconds since system boot + float roll_rate; ///< Desired roll rate in radians per second + float pitch_rate; ///< Desired pitch rate in radians per second + float yaw_rate; ///< Desired yaw rate in radians per second + float thrust; ///< Collective thrust, normalized to 0 .. 1 +} mavlink_roll_pitch_yaw_rates_thrust_setpoint_t; + +#define MAVLINK_MSG_ID_ROLL_PITCH_YAW_RATES_THRUST_SETPOINT_LEN 20 +#define MAVLINK_MSG_ID_80_LEN 20 + + + +#define MAVLINK_MESSAGE_INFO_ROLL_PITCH_YAW_RATES_THRUST_SETPOINT { \ + "ROLL_PITCH_YAW_RATES_THRUST_SETPOINT", \ + 5, \ + { { "time_boot_ms", NULL, MAVLINK_TYPE_UINT32_T, 0, 0, offsetof(mavlink_roll_pitch_yaw_rates_thrust_setpoint_t, time_boot_ms) }, \ + { "roll_rate", NULL, MAVLINK_TYPE_FLOAT, 0, 4, offsetof(mavlink_roll_pitch_yaw_rates_thrust_setpoint_t, roll_rate) }, \ + { "pitch_rate", NULL, MAVLINK_TYPE_FLOAT, 0, 8, offsetof(mavlink_roll_pitch_yaw_rates_thrust_setpoint_t, pitch_rate) }, \ + { "yaw_rate", NULL, MAVLINK_TYPE_FLOAT, 0, 12, offsetof(mavlink_roll_pitch_yaw_rates_thrust_setpoint_t, yaw_rate) }, \ + { "thrust", NULL, MAVLINK_TYPE_FLOAT, 0, 16, offsetof(mavlink_roll_pitch_yaw_rates_thrust_setpoint_t, thrust) }, \ + } \ +} + + +/** + * @brief Pack a roll_pitch_yaw_rates_thrust_setpoint message + * @param system_id ID of this system + * @param component_id ID of this component (e.g. 200 for IMU) + * @param msg The MAVLink message to compress the data into + * + * @param time_boot_ms Timestamp in milliseconds since system boot + * @param roll_rate Desired roll rate in radians per second + * @param pitch_rate Desired pitch rate in radians per second + * @param yaw_rate Desired yaw rate in radians per second + * @param thrust Collective thrust, normalized to 0 .. 1 + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_roll_pitch_yaw_rates_thrust_setpoint_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, + uint32_t time_boot_ms, float roll_rate, float pitch_rate, float yaw_rate, float thrust) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[20]; + _mav_put_uint32_t(buf, 0, time_boot_ms); + _mav_put_float(buf, 4, roll_rate); + _mav_put_float(buf, 8, pitch_rate); + _mav_put_float(buf, 12, yaw_rate); + _mav_put_float(buf, 16, thrust); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 20); +#else + mavlink_roll_pitch_yaw_rates_thrust_setpoint_t packet; + packet.time_boot_ms = time_boot_ms; + packet.roll_rate = roll_rate; + packet.pitch_rate = pitch_rate; + packet.yaw_rate = yaw_rate; + packet.thrust = thrust; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 20); +#endif + + msg->msgid = MAVLINK_MSG_ID_ROLL_PITCH_YAW_RATES_THRUST_SETPOINT; + return mavlink_finalize_message(msg, system_id, component_id, 20, 127); +} + +/** + * @brief Pack a roll_pitch_yaw_rates_thrust_setpoint message on a channel + * @param system_id ID of this system + * @param component_id ID of this component (e.g. 200 for IMU) + * @param chan The MAVLink channel this message was sent over + * @param msg The MAVLink message to compress the data into + * @param time_boot_ms Timestamp in milliseconds since system boot + * @param roll_rate Desired roll rate in radians per second + * @param pitch_rate Desired pitch rate in radians per second + * @param yaw_rate Desired yaw rate in radians per second + * @param thrust Collective thrust, normalized to 0 .. 1 + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_roll_pitch_yaw_rates_thrust_setpoint_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, + mavlink_message_t* msg, + uint32_t time_boot_ms,float roll_rate,float pitch_rate,float yaw_rate,float thrust) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[20]; + _mav_put_uint32_t(buf, 0, time_boot_ms); + _mav_put_float(buf, 4, roll_rate); + _mav_put_float(buf, 8, pitch_rate); + _mav_put_float(buf, 12, yaw_rate); + _mav_put_float(buf, 16, thrust); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 20); +#else + mavlink_roll_pitch_yaw_rates_thrust_setpoint_t packet; + packet.time_boot_ms = time_boot_ms; + packet.roll_rate = roll_rate; + packet.pitch_rate = pitch_rate; + packet.yaw_rate = yaw_rate; + packet.thrust = thrust; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 20); +#endif + + msg->msgid = MAVLINK_MSG_ID_ROLL_PITCH_YAW_RATES_THRUST_SETPOINT; + return mavlink_finalize_message_chan(msg, system_id, component_id, chan, 20, 127); +} + +/** + * @brief Encode a roll_pitch_yaw_rates_thrust_setpoint struct into a message + * + * @param system_id ID of this system + * @param component_id ID of this component (e.g. 200 for IMU) + * @param msg The MAVLink message to compress the data into + * @param roll_pitch_yaw_rates_thrust_setpoint C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_roll_pitch_yaw_rates_thrust_setpoint_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_roll_pitch_yaw_rates_thrust_setpoint_t* roll_pitch_yaw_rates_thrust_setpoint) +{ + return mavlink_msg_roll_pitch_yaw_rates_thrust_setpoint_pack(system_id, component_id, msg, roll_pitch_yaw_rates_thrust_setpoint->time_boot_ms, roll_pitch_yaw_rates_thrust_setpoint->roll_rate, roll_pitch_yaw_rates_thrust_setpoint->pitch_rate, roll_pitch_yaw_rates_thrust_setpoint->yaw_rate, roll_pitch_yaw_rates_thrust_setpoint->thrust); +} + +/** + * @brief Send a roll_pitch_yaw_rates_thrust_setpoint message + * @param chan MAVLink channel to send the message + * + * @param time_boot_ms Timestamp in milliseconds since system boot + * @param roll_rate Desired roll rate in radians per second + * @param pitch_rate Desired pitch rate in radians per second + * @param yaw_rate Desired yaw rate in radians per second + * @param thrust Collective thrust, normalized to 0 .. 1 + */ +#ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS + +static inline void mavlink_msg_roll_pitch_yaw_rates_thrust_setpoint_send(mavlink_channel_t chan, uint32_t time_boot_ms, float roll_rate, float pitch_rate, float yaw_rate, float thrust) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[20]; + _mav_put_uint32_t(buf, 0, time_boot_ms); + _mav_put_float(buf, 4, roll_rate); + _mav_put_float(buf, 8, pitch_rate); + _mav_put_float(buf, 12, yaw_rate); + _mav_put_float(buf, 16, thrust); + + _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_ROLL_PITCH_YAW_RATES_THRUST_SETPOINT, buf, 20, 127); +#else + mavlink_roll_pitch_yaw_rates_thrust_setpoint_t packet; + packet.time_boot_ms = time_boot_ms; + packet.roll_rate = roll_rate; + packet.pitch_rate = pitch_rate; + packet.yaw_rate = yaw_rate; + packet.thrust = thrust; + + _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_ROLL_PITCH_YAW_RATES_THRUST_SETPOINT, (const char *)&packet, 20, 127); +#endif +} + +#endif + +// MESSAGE ROLL_PITCH_YAW_RATES_THRUST_SETPOINT UNPACKING + + +/** + * @brief Get field time_boot_ms from roll_pitch_yaw_rates_thrust_setpoint message + * + * @return Timestamp in milliseconds since system boot + */ +static inline uint32_t mavlink_msg_roll_pitch_yaw_rates_thrust_setpoint_get_time_boot_ms(const mavlink_message_t* msg) +{ + return _MAV_RETURN_uint32_t(msg, 0); +} + +/** + * @brief Get field roll_rate from roll_pitch_yaw_rates_thrust_setpoint message + * + * @return Desired roll rate in radians per second + */ +static inline float mavlink_msg_roll_pitch_yaw_rates_thrust_setpoint_get_roll_rate(const mavlink_message_t* msg) +{ + return _MAV_RETURN_float(msg, 4); +} + +/** + * @brief Get field pitch_rate from roll_pitch_yaw_rates_thrust_setpoint message + * + * @return Desired pitch rate in radians per second + */ +static inline float mavlink_msg_roll_pitch_yaw_rates_thrust_setpoint_get_pitch_rate(const mavlink_message_t* msg) +{ + return _MAV_RETURN_float(msg, 8); +} + +/** + * @brief Get field yaw_rate from roll_pitch_yaw_rates_thrust_setpoint message + * + * @return Desired yaw rate in radians per second + */ +static inline float mavlink_msg_roll_pitch_yaw_rates_thrust_setpoint_get_yaw_rate(const mavlink_message_t* msg) +{ + return _MAV_RETURN_float(msg, 12); +} + +/** + * @brief Get field thrust from roll_pitch_yaw_rates_thrust_setpoint message + * + * @return Collective thrust, normalized to 0 .. 1 + */ +static inline float mavlink_msg_roll_pitch_yaw_rates_thrust_setpoint_get_thrust(const mavlink_message_t* msg) +{ + return _MAV_RETURN_float(msg, 16); +} + +/** + * @brief Decode a roll_pitch_yaw_rates_thrust_setpoint message into a struct + * + * @param msg The message to decode + * @param roll_pitch_yaw_rates_thrust_setpoint C-struct to decode the message contents into + */ +static inline void mavlink_msg_roll_pitch_yaw_rates_thrust_setpoint_decode(const mavlink_message_t* msg, mavlink_roll_pitch_yaw_rates_thrust_setpoint_t* roll_pitch_yaw_rates_thrust_setpoint) +{ +#if MAVLINK_NEED_BYTE_SWAP + roll_pitch_yaw_rates_thrust_setpoint->time_boot_ms = mavlink_msg_roll_pitch_yaw_rates_thrust_setpoint_get_time_boot_ms(msg); + roll_pitch_yaw_rates_thrust_setpoint->roll_rate = mavlink_msg_roll_pitch_yaw_rates_thrust_setpoint_get_roll_rate(msg); + roll_pitch_yaw_rates_thrust_setpoint->pitch_rate = mavlink_msg_roll_pitch_yaw_rates_thrust_setpoint_get_pitch_rate(msg); + roll_pitch_yaw_rates_thrust_setpoint->yaw_rate = mavlink_msg_roll_pitch_yaw_rates_thrust_setpoint_get_yaw_rate(msg); + roll_pitch_yaw_rates_thrust_setpoint->thrust = mavlink_msg_roll_pitch_yaw_rates_thrust_setpoint_get_thrust(msg); +#else + memcpy(roll_pitch_yaw_rates_thrust_setpoint, _MAV_PAYLOAD(msg), 20); +#endif +} diff --git a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_roll_pitch_yaw_speed_thrust_setpoint.h b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_roll_pitch_yaw_speed_thrust_setpoint.h index 80a88cca2..5751badc3 100644 --- a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_roll_pitch_yaw_speed_thrust_setpoint.h +++ b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_roll_pitch_yaw_speed_thrust_setpoint.h @@ -52,7 +52,7 @@ static inline uint16_t mavlink_msg_roll_pitch_yaw_speed_thrust_setpoint_pack(uin _mav_put_float(buf, 12, yaw_speed); _mav_put_float(buf, 16, thrust); - memcpy(_MAV_PAYLOAD(msg), buf, 20); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 20); #else mavlink_roll_pitch_yaw_speed_thrust_setpoint_t packet; packet.time_boot_ms = time_boot_ms; @@ -61,7 +61,7 @@ static inline uint16_t mavlink_msg_roll_pitch_yaw_speed_thrust_setpoint_pack(uin packet.yaw_speed = yaw_speed; packet.thrust = thrust; - memcpy(_MAV_PAYLOAD(msg), &packet, 20); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 20); #endif msg->msgid = MAVLINK_MSG_ID_ROLL_PITCH_YAW_SPEED_THRUST_SETPOINT; @@ -93,7 +93,7 @@ static inline uint16_t mavlink_msg_roll_pitch_yaw_speed_thrust_setpoint_pack_cha _mav_put_float(buf, 12, yaw_speed); _mav_put_float(buf, 16, thrust); - memcpy(_MAV_PAYLOAD(msg), buf, 20); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 20); #else mavlink_roll_pitch_yaw_speed_thrust_setpoint_t packet; packet.time_boot_ms = time_boot_ms; @@ -102,7 +102,7 @@ static inline uint16_t mavlink_msg_roll_pitch_yaw_speed_thrust_setpoint_pack_cha packet.yaw_speed = yaw_speed; packet.thrust = thrust; - memcpy(_MAV_PAYLOAD(msg), &packet, 20); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 20); #endif msg->msgid = MAVLINK_MSG_ID_ROLL_PITCH_YAW_SPEED_THRUST_SETPOINT; diff --git a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_roll_pitch_yaw_thrust_setpoint.h b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_roll_pitch_yaw_thrust_setpoint.h index b8b87028d..a9f6ad0ca 100644 --- a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_roll_pitch_yaw_thrust_setpoint.h +++ b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_roll_pitch_yaw_thrust_setpoint.h @@ -52,7 +52,7 @@ static inline uint16_t mavlink_msg_roll_pitch_yaw_thrust_setpoint_pack(uint8_t s _mav_put_float(buf, 12, yaw); _mav_put_float(buf, 16, thrust); - memcpy(_MAV_PAYLOAD(msg), buf, 20); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 20); #else mavlink_roll_pitch_yaw_thrust_setpoint_t packet; packet.time_boot_ms = time_boot_ms; @@ -61,7 +61,7 @@ static inline uint16_t mavlink_msg_roll_pitch_yaw_thrust_setpoint_pack(uint8_t s packet.yaw = yaw; packet.thrust = thrust; - memcpy(_MAV_PAYLOAD(msg), &packet, 20); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 20); #endif msg->msgid = MAVLINK_MSG_ID_ROLL_PITCH_YAW_THRUST_SETPOINT; @@ -93,7 +93,7 @@ static inline uint16_t mavlink_msg_roll_pitch_yaw_thrust_setpoint_pack_chan(uint _mav_put_float(buf, 12, yaw); _mav_put_float(buf, 16, thrust); - memcpy(_MAV_PAYLOAD(msg), buf, 20); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 20); #else mavlink_roll_pitch_yaw_thrust_setpoint_t packet; packet.time_boot_ms = time_boot_ms; @@ -102,7 +102,7 @@ static inline uint16_t mavlink_msg_roll_pitch_yaw_thrust_setpoint_pack_chan(uint packet.yaw = yaw; packet.thrust = thrust; - memcpy(_MAV_PAYLOAD(msg), &packet, 20); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 20); #endif msg->msgid = MAVLINK_MSG_ID_ROLL_PITCH_YAW_THRUST_SETPOINT; diff --git a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_safety_allowed_area.h b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_safety_allowed_area.h index fee7734d0..aae6fd206 100644 --- a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_safety_allowed_area.h +++ b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_safety_allowed_area.h @@ -60,7 +60,7 @@ static inline uint16_t mavlink_msg_safety_allowed_area_pack(uint8_t system_id, u _mav_put_float(buf, 20, p2z); _mav_put_uint8_t(buf, 24, frame); - memcpy(_MAV_PAYLOAD(msg), buf, 25); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 25); #else mavlink_safety_allowed_area_t packet; packet.p1x = p1x; @@ -71,7 +71,7 @@ static inline uint16_t mavlink_msg_safety_allowed_area_pack(uint8_t system_id, u packet.p2z = p2z; packet.frame = frame; - memcpy(_MAV_PAYLOAD(msg), &packet, 25); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 25); #endif msg->msgid = MAVLINK_MSG_ID_SAFETY_ALLOWED_AREA; @@ -107,7 +107,7 @@ static inline uint16_t mavlink_msg_safety_allowed_area_pack_chan(uint8_t system_ _mav_put_float(buf, 20, p2z); _mav_put_uint8_t(buf, 24, frame); - memcpy(_MAV_PAYLOAD(msg), buf, 25); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 25); #else mavlink_safety_allowed_area_t packet; packet.p1x = p1x; @@ -118,7 +118,7 @@ static inline uint16_t mavlink_msg_safety_allowed_area_pack_chan(uint8_t system_ packet.p2z = p2z; packet.frame = frame; - memcpy(_MAV_PAYLOAD(msg), &packet, 25); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 25); #endif msg->msgid = MAVLINK_MSG_ID_SAFETY_ALLOWED_AREA; diff --git a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_safety_set_allowed_area.h b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_safety_set_allowed_area.h index 35d9b3b25..8fb410c2d 100644 --- a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_safety_set_allowed_area.h +++ b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_safety_set_allowed_area.h @@ -68,7 +68,7 @@ static inline uint16_t mavlink_msg_safety_set_allowed_area_pack(uint8_t system_i _mav_put_uint8_t(buf, 25, target_component); _mav_put_uint8_t(buf, 26, frame); - memcpy(_MAV_PAYLOAD(msg), buf, 27); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 27); #else mavlink_safety_set_allowed_area_t packet; packet.p1x = p1x; @@ -81,7 +81,7 @@ static inline uint16_t mavlink_msg_safety_set_allowed_area_pack(uint8_t system_i packet.target_component = target_component; packet.frame = frame; - memcpy(_MAV_PAYLOAD(msg), &packet, 27); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 27); #endif msg->msgid = MAVLINK_MSG_ID_SAFETY_SET_ALLOWED_AREA; @@ -121,7 +121,7 @@ static inline uint16_t mavlink_msg_safety_set_allowed_area_pack_chan(uint8_t sys _mav_put_uint8_t(buf, 25, target_component); _mav_put_uint8_t(buf, 26, frame); - memcpy(_MAV_PAYLOAD(msg), buf, 27); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 27); #else mavlink_safety_set_allowed_area_t packet; packet.p1x = p1x; @@ -134,7 +134,7 @@ static inline uint16_t mavlink_msg_safety_set_allowed_area_pack_chan(uint8_t sys packet.target_component = target_component; packet.frame = frame; - memcpy(_MAV_PAYLOAD(msg), &packet, 27); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 27); #endif msg->msgid = MAVLINK_MSG_ID_SAFETY_SET_ALLOWED_AREA; diff --git a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_scaled_imu.h b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_scaled_imu.h index 145d959ad..8ff098f39 100644 --- a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_scaled_imu.h +++ b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_scaled_imu.h @@ -72,7 +72,7 @@ static inline uint16_t mavlink_msg_scaled_imu_pack(uint8_t system_id, uint8_t co _mav_put_int16_t(buf, 18, ymag); _mav_put_int16_t(buf, 20, zmag); - memcpy(_MAV_PAYLOAD(msg), buf, 22); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 22); #else mavlink_scaled_imu_t packet; packet.time_boot_ms = time_boot_ms; @@ -86,7 +86,7 @@ static inline uint16_t mavlink_msg_scaled_imu_pack(uint8_t system_id, uint8_t co packet.ymag = ymag; packet.zmag = zmag; - memcpy(_MAV_PAYLOAD(msg), &packet, 22); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 22); #endif msg->msgid = MAVLINK_MSG_ID_SCALED_IMU; @@ -128,7 +128,7 @@ static inline uint16_t mavlink_msg_scaled_imu_pack_chan(uint8_t system_id, uint8 _mav_put_int16_t(buf, 18, ymag); _mav_put_int16_t(buf, 20, zmag); - memcpy(_MAV_PAYLOAD(msg), buf, 22); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 22); #else mavlink_scaled_imu_t packet; packet.time_boot_ms = time_boot_ms; @@ -142,7 +142,7 @@ static inline uint16_t mavlink_msg_scaled_imu_pack_chan(uint8_t system_id, uint8 packet.ymag = ymag; packet.zmag = zmag; - memcpy(_MAV_PAYLOAD(msg), &packet, 22); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 22); #endif msg->msgid = MAVLINK_MSG_ID_SCALED_IMU; diff --git a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_scaled_pressure.h b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_scaled_pressure.h index 428a7af22..d9ddcd47f 100644 --- a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_scaled_pressure.h +++ b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_scaled_pressure.h @@ -4,7 +4,7 @@ typedef struct __mavlink_scaled_pressure_t { - uint32_t time_boot_ms; ///< Timestamp (microseconds since UNIX epoch or microseconds since system boot) + uint32_t time_boot_ms; ///< Timestamp (milliseconds since system boot) float press_abs; ///< Absolute pressure (hectopascal) float press_diff; ///< Differential pressure 1 (hectopascal) int16_t temperature; ///< Temperature measurement (0.01 degrees celsius) @@ -32,7 +32,7 @@ typedef struct __mavlink_scaled_pressure_t * @param component_id ID of this component (e.g. 200 for IMU) * @param msg The MAVLink message to compress the data into * - * @param time_boot_ms Timestamp (microseconds since UNIX epoch or microseconds since system boot) + * @param time_boot_ms Timestamp (milliseconds since system boot) * @param press_abs Absolute pressure (hectopascal) * @param press_diff Differential pressure 1 (hectopascal) * @param temperature Temperature measurement (0.01 degrees celsius) @@ -48,7 +48,7 @@ static inline uint16_t mavlink_msg_scaled_pressure_pack(uint8_t system_id, uint8 _mav_put_float(buf, 8, press_diff); _mav_put_int16_t(buf, 12, temperature); - memcpy(_MAV_PAYLOAD(msg), buf, 14); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 14); #else mavlink_scaled_pressure_t packet; packet.time_boot_ms = time_boot_ms; @@ -56,7 +56,7 @@ static inline uint16_t mavlink_msg_scaled_pressure_pack(uint8_t system_id, uint8 packet.press_diff = press_diff; packet.temperature = temperature; - memcpy(_MAV_PAYLOAD(msg), &packet, 14); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 14); #endif msg->msgid = MAVLINK_MSG_ID_SCALED_PRESSURE; @@ -69,7 +69,7 @@ static inline uint16_t mavlink_msg_scaled_pressure_pack(uint8_t system_id, uint8 * @param component_id ID of this component (e.g. 200 for IMU) * @param chan The MAVLink channel this message was sent over * @param msg The MAVLink message to compress the data into - * @param time_boot_ms Timestamp (microseconds since UNIX epoch or microseconds since system boot) + * @param time_boot_ms Timestamp (milliseconds since system boot) * @param press_abs Absolute pressure (hectopascal) * @param press_diff Differential pressure 1 (hectopascal) * @param temperature Temperature measurement (0.01 degrees celsius) @@ -86,7 +86,7 @@ static inline uint16_t mavlink_msg_scaled_pressure_pack_chan(uint8_t system_id, _mav_put_float(buf, 8, press_diff); _mav_put_int16_t(buf, 12, temperature); - memcpy(_MAV_PAYLOAD(msg), buf, 14); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 14); #else mavlink_scaled_pressure_t packet; packet.time_boot_ms = time_boot_ms; @@ -94,7 +94,7 @@ static inline uint16_t mavlink_msg_scaled_pressure_pack_chan(uint8_t system_id, packet.press_diff = press_diff; packet.temperature = temperature; - memcpy(_MAV_PAYLOAD(msg), &packet, 14); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 14); #endif msg->msgid = MAVLINK_MSG_ID_SCALED_PRESSURE; @@ -118,7 +118,7 @@ static inline uint16_t mavlink_msg_scaled_pressure_encode(uint8_t system_id, uin * @brief Send a scaled_pressure message * @param chan MAVLink channel to send the message * - * @param time_boot_ms Timestamp (microseconds since UNIX epoch or microseconds since system boot) + * @param time_boot_ms Timestamp (milliseconds since system boot) * @param press_abs Absolute pressure (hectopascal) * @param press_diff Differential pressure 1 (hectopascal) * @param temperature Temperature measurement (0.01 degrees celsius) @@ -154,7 +154,7 @@ static inline void mavlink_msg_scaled_pressure_send(mavlink_channel_t chan, uint /** * @brief Get field time_boot_ms from scaled_pressure message * - * @return Timestamp (microseconds since UNIX epoch or microseconds since system boot) + * @return Timestamp (milliseconds since system boot) */ static inline uint32_t mavlink_msg_scaled_pressure_get_time_boot_ms(const mavlink_message_t* msg) { diff --git a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_servo_output_raw.h b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_servo_output_raw.h index dce71fd6e..45c94d8b9 100644 --- a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_servo_output_raw.h +++ b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_servo_output_raw.h @@ -4,7 +4,7 @@ typedef struct __mavlink_servo_output_raw_t { - uint32_t time_usec; ///< Timestamp (since UNIX epoch or microseconds since system boot) + uint32_t time_usec; ///< Timestamp (microseconds since system boot) uint16_t servo1_raw; ///< Servo output 1 value, in microseconds uint16_t servo2_raw; ///< Servo output 2 value, in microseconds uint16_t servo3_raw; ///< Servo output 3 value, in microseconds @@ -44,7 +44,7 @@ typedef struct __mavlink_servo_output_raw_t * @param component_id ID of this component (e.g. 200 for IMU) * @param msg The MAVLink message to compress the data into * - * @param time_usec Timestamp (since UNIX epoch or microseconds since system boot) + * @param time_usec Timestamp (microseconds since system boot) * @param port Servo output port (set of 8 outputs = 1 port). Most MAVs will just use one, but this allows to encode more than 8 servos. * @param servo1_raw Servo output 1 value, in microseconds * @param servo2_raw Servo output 2 value, in microseconds @@ -72,7 +72,7 @@ static inline uint16_t mavlink_msg_servo_output_raw_pack(uint8_t system_id, uint _mav_put_uint16_t(buf, 18, servo8_raw); _mav_put_uint8_t(buf, 20, port); - memcpy(_MAV_PAYLOAD(msg), buf, 21); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 21); #else mavlink_servo_output_raw_t packet; packet.time_usec = time_usec; @@ -86,7 +86,7 @@ static inline uint16_t mavlink_msg_servo_output_raw_pack(uint8_t system_id, uint packet.servo8_raw = servo8_raw; packet.port = port; - memcpy(_MAV_PAYLOAD(msg), &packet, 21); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 21); #endif msg->msgid = MAVLINK_MSG_ID_SERVO_OUTPUT_RAW; @@ -99,7 +99,7 @@ static inline uint16_t mavlink_msg_servo_output_raw_pack(uint8_t system_id, uint * @param component_id ID of this component (e.g. 200 for IMU) * @param chan The MAVLink channel this message was sent over * @param msg The MAVLink message to compress the data into - * @param time_usec Timestamp (since UNIX epoch or microseconds since system boot) + * @param time_usec Timestamp (microseconds since system boot) * @param port Servo output port (set of 8 outputs = 1 port). Most MAVs will just use one, but this allows to encode more than 8 servos. * @param servo1_raw Servo output 1 value, in microseconds * @param servo2_raw Servo output 2 value, in microseconds @@ -128,7 +128,7 @@ static inline uint16_t mavlink_msg_servo_output_raw_pack_chan(uint8_t system_id, _mav_put_uint16_t(buf, 18, servo8_raw); _mav_put_uint8_t(buf, 20, port); - memcpy(_MAV_PAYLOAD(msg), buf, 21); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 21); #else mavlink_servo_output_raw_t packet; packet.time_usec = time_usec; @@ -142,7 +142,7 @@ static inline uint16_t mavlink_msg_servo_output_raw_pack_chan(uint8_t system_id, packet.servo8_raw = servo8_raw; packet.port = port; - memcpy(_MAV_PAYLOAD(msg), &packet, 21); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 21); #endif msg->msgid = MAVLINK_MSG_ID_SERVO_OUTPUT_RAW; @@ -166,7 +166,7 @@ static inline uint16_t mavlink_msg_servo_output_raw_encode(uint8_t system_id, ui * @brief Send a servo_output_raw message * @param chan MAVLink channel to send the message * - * @param time_usec Timestamp (since UNIX epoch or microseconds since system boot) + * @param time_usec Timestamp (microseconds since system boot) * @param port Servo output port (set of 8 outputs = 1 port). Most MAVs will just use one, but this allows to encode more than 8 servos. * @param servo1_raw Servo output 1 value, in microseconds * @param servo2_raw Servo output 2 value, in microseconds @@ -220,7 +220,7 @@ static inline void mavlink_msg_servo_output_raw_send(mavlink_channel_t chan, uin /** * @brief Get field time_usec from servo_output_raw message * - * @return Timestamp (since UNIX epoch or microseconds since system boot) + * @return Timestamp (microseconds since system boot) */ static inline uint32_t mavlink_msg_servo_output_raw_get_time_usec(const mavlink_message_t* msg) { diff --git a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_set_global_position_setpoint_int.h b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_set_global_position_setpoint_int.h index ea34731c9..5b706fb50 100644 --- a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_set_global_position_setpoint_int.h +++ b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_set_global_position_setpoint_int.h @@ -52,7 +52,7 @@ static inline uint16_t mavlink_msg_set_global_position_setpoint_int_pack(uint8_t _mav_put_int16_t(buf, 12, yaw); _mav_put_uint8_t(buf, 14, coordinate_frame); - memcpy(_MAV_PAYLOAD(msg), buf, 15); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 15); #else mavlink_set_global_position_setpoint_int_t packet; packet.latitude = latitude; @@ -61,7 +61,7 @@ static inline uint16_t mavlink_msg_set_global_position_setpoint_int_pack(uint8_t packet.yaw = yaw; packet.coordinate_frame = coordinate_frame; - memcpy(_MAV_PAYLOAD(msg), &packet, 15); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 15); #endif msg->msgid = MAVLINK_MSG_ID_SET_GLOBAL_POSITION_SETPOINT_INT; @@ -93,7 +93,7 @@ static inline uint16_t mavlink_msg_set_global_position_setpoint_int_pack_chan(ui _mav_put_int16_t(buf, 12, yaw); _mav_put_uint8_t(buf, 14, coordinate_frame); - memcpy(_MAV_PAYLOAD(msg), buf, 15); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 15); #else mavlink_set_global_position_setpoint_int_t packet; packet.latitude = latitude; @@ -102,7 +102,7 @@ static inline uint16_t mavlink_msg_set_global_position_setpoint_int_pack_chan(ui packet.yaw = yaw; packet.coordinate_frame = coordinate_frame; - memcpy(_MAV_PAYLOAD(msg), &packet, 15); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 15); #endif msg->msgid = MAVLINK_MSG_ID_SET_GLOBAL_POSITION_SETPOINT_INT; diff --git a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_set_gps_global_origin.h b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_set_gps_global_origin.h index ee6f18af5..af404b110 100644 --- a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_set_gps_global_origin.h +++ b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_set_gps_global_origin.h @@ -48,7 +48,7 @@ static inline uint16_t mavlink_msg_set_gps_global_origin_pack(uint8_t system_id, _mav_put_int32_t(buf, 8, altitude); _mav_put_uint8_t(buf, 12, target_system); - memcpy(_MAV_PAYLOAD(msg), buf, 13); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 13); #else mavlink_set_gps_global_origin_t packet; packet.latitude = latitude; @@ -56,7 +56,7 @@ static inline uint16_t mavlink_msg_set_gps_global_origin_pack(uint8_t system_id, packet.altitude = altitude; packet.target_system = target_system; - memcpy(_MAV_PAYLOAD(msg), &packet, 13); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 13); #endif msg->msgid = MAVLINK_MSG_ID_SET_GPS_GLOBAL_ORIGIN; @@ -86,7 +86,7 @@ static inline uint16_t mavlink_msg_set_gps_global_origin_pack_chan(uint8_t syste _mav_put_int32_t(buf, 8, altitude); _mav_put_uint8_t(buf, 12, target_system); - memcpy(_MAV_PAYLOAD(msg), buf, 13); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 13); #else mavlink_set_gps_global_origin_t packet; packet.latitude = latitude; @@ -94,7 +94,7 @@ static inline uint16_t mavlink_msg_set_gps_global_origin_pack_chan(uint8_t syste packet.altitude = altitude; packet.target_system = target_system; - memcpy(_MAV_PAYLOAD(msg), &packet, 13); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 13); #endif msg->msgid = MAVLINK_MSG_ID_SET_GPS_GLOBAL_ORIGIN; diff --git a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_set_local_position_setpoint.h b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_set_local_position_setpoint.h index 4024c9ef1..233e07d65 100644 --- a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_set_local_position_setpoint.h +++ b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_set_local_position_setpoint.h @@ -60,7 +60,7 @@ static inline uint16_t mavlink_msg_set_local_position_setpoint_pack(uint8_t syst _mav_put_uint8_t(buf, 17, target_component); _mav_put_uint8_t(buf, 18, coordinate_frame); - memcpy(_MAV_PAYLOAD(msg), buf, 19); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 19); #else mavlink_set_local_position_setpoint_t packet; packet.x = x; @@ -71,7 +71,7 @@ static inline uint16_t mavlink_msg_set_local_position_setpoint_pack(uint8_t syst packet.target_component = target_component; packet.coordinate_frame = coordinate_frame; - memcpy(_MAV_PAYLOAD(msg), &packet, 19); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 19); #endif msg->msgid = MAVLINK_MSG_ID_SET_LOCAL_POSITION_SETPOINT; @@ -107,7 +107,7 @@ static inline uint16_t mavlink_msg_set_local_position_setpoint_pack_chan(uint8_t _mav_put_uint8_t(buf, 17, target_component); _mav_put_uint8_t(buf, 18, coordinate_frame); - memcpy(_MAV_PAYLOAD(msg), buf, 19); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 19); #else mavlink_set_local_position_setpoint_t packet; packet.x = x; @@ -118,7 +118,7 @@ static inline uint16_t mavlink_msg_set_local_position_setpoint_pack_chan(uint8_t packet.target_component = target_component; packet.coordinate_frame = coordinate_frame; - memcpy(_MAV_PAYLOAD(msg), &packet, 19); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 19); #endif msg->msgid = MAVLINK_MSG_ID_SET_LOCAL_POSITION_SETPOINT; diff --git a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_set_mode.h b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_set_mode.h index b622de0ea..fec21ab13 100644 --- a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_set_mode.h +++ b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_set_mode.h @@ -44,14 +44,14 @@ static inline uint16_t mavlink_msg_set_mode_pack(uint8_t system_id, uint8_t comp _mav_put_uint8_t(buf, 4, target_system); _mav_put_uint8_t(buf, 5, base_mode); - memcpy(_MAV_PAYLOAD(msg), buf, 6); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 6); #else mavlink_set_mode_t packet; packet.custom_mode = custom_mode; packet.target_system = target_system; packet.base_mode = base_mode; - memcpy(_MAV_PAYLOAD(msg), &packet, 6); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 6); #endif msg->msgid = MAVLINK_MSG_ID_SET_MODE; @@ -79,14 +79,14 @@ static inline uint16_t mavlink_msg_set_mode_pack_chan(uint8_t system_id, uint8_t _mav_put_uint8_t(buf, 4, target_system); _mav_put_uint8_t(buf, 5, base_mode); - memcpy(_MAV_PAYLOAD(msg), buf, 6); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 6); #else mavlink_set_mode_t packet; packet.custom_mode = custom_mode; packet.target_system = target_system; packet.base_mode = base_mode; - memcpy(_MAV_PAYLOAD(msg), &packet, 6); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 6); #endif msg->msgid = MAVLINK_MSG_ID_SET_MODE; diff --git a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_set_quad_motors_setpoint.h b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_set_quad_motors_setpoint.h new file mode 100644 index 000000000..40ff8998e --- /dev/null +++ b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_set_quad_motors_setpoint.h @@ -0,0 +1,232 @@ +// MESSAGE SET_QUAD_MOTORS_SETPOINT PACKING + +#define MAVLINK_MSG_ID_SET_QUAD_MOTORS_SETPOINT 60 + +typedef struct __mavlink_set_quad_motors_setpoint_t +{ + uint16_t motor_front_nw; ///< Front motor in + configuration, front left motor in x configuration + uint16_t motor_right_ne; ///< Right motor in + configuration, front right motor in x configuration + uint16_t motor_back_se; ///< Back motor in + configuration, back right motor in x configuration + uint16_t motor_left_sw; ///< Left motor in + configuration, back left motor in x configuration + uint8_t target_system; ///< System ID of the system that should set these motor commands +} mavlink_set_quad_motors_setpoint_t; + +#define MAVLINK_MSG_ID_SET_QUAD_MOTORS_SETPOINT_LEN 9 +#define MAVLINK_MSG_ID_60_LEN 9 + + + +#define MAVLINK_MESSAGE_INFO_SET_QUAD_MOTORS_SETPOINT { \ + "SET_QUAD_MOTORS_SETPOINT", \ + 5, \ + { { "motor_front_nw", NULL, MAVLINK_TYPE_UINT16_T, 0, 0, offsetof(mavlink_set_quad_motors_setpoint_t, motor_front_nw) }, \ + { "motor_right_ne", NULL, MAVLINK_TYPE_UINT16_T, 0, 2, offsetof(mavlink_set_quad_motors_setpoint_t, motor_right_ne) }, \ + { "motor_back_se", NULL, MAVLINK_TYPE_UINT16_T, 0, 4, offsetof(mavlink_set_quad_motors_setpoint_t, motor_back_se) }, \ + { "motor_left_sw", NULL, MAVLINK_TYPE_UINT16_T, 0, 6, offsetof(mavlink_set_quad_motors_setpoint_t, motor_left_sw) }, \ + { "target_system", NULL, MAVLINK_TYPE_UINT8_T, 0, 8, offsetof(mavlink_set_quad_motors_setpoint_t, target_system) }, \ + } \ +} + + +/** + * @brief Pack a set_quad_motors_setpoint message + * @param system_id ID of this system + * @param component_id ID of this component (e.g. 200 for IMU) + * @param msg The MAVLink message to compress the data into + * + * @param target_system System ID of the system that should set these motor commands + * @param motor_front_nw Front motor in + configuration, front left motor in x configuration + * @param motor_right_ne Right motor in + configuration, front right motor in x configuration + * @param motor_back_se Back motor in + configuration, back right motor in x configuration + * @param motor_left_sw Left motor in + configuration, back left motor in x configuration + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_set_quad_motors_setpoint_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, + uint8_t target_system, uint16_t motor_front_nw, uint16_t motor_right_ne, uint16_t motor_back_se, uint16_t motor_left_sw) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[9]; + _mav_put_uint16_t(buf, 0, motor_front_nw); + _mav_put_uint16_t(buf, 2, motor_right_ne); + _mav_put_uint16_t(buf, 4, motor_back_se); + _mav_put_uint16_t(buf, 6, motor_left_sw); + _mav_put_uint8_t(buf, 8, target_system); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 9); +#else + mavlink_set_quad_motors_setpoint_t packet; + packet.motor_front_nw = motor_front_nw; + packet.motor_right_ne = motor_right_ne; + packet.motor_back_se = motor_back_se; + packet.motor_left_sw = motor_left_sw; + packet.target_system = target_system; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 9); +#endif + + msg->msgid = MAVLINK_MSG_ID_SET_QUAD_MOTORS_SETPOINT; + return mavlink_finalize_message(msg, system_id, component_id, 9, 30); +} + +/** + * @brief Pack a set_quad_motors_setpoint message on a channel + * @param system_id ID of this system + * @param component_id ID of this component (e.g. 200 for IMU) + * @param chan The MAVLink channel this message was sent over + * @param msg The MAVLink message to compress the data into + * @param target_system System ID of the system that should set these motor commands + * @param motor_front_nw Front motor in + configuration, front left motor in x configuration + * @param motor_right_ne Right motor in + configuration, front right motor in x configuration + * @param motor_back_se Back motor in + configuration, back right motor in x configuration + * @param motor_left_sw Left motor in + configuration, back left motor in x configuration + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_set_quad_motors_setpoint_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, + mavlink_message_t* msg, + uint8_t target_system,uint16_t motor_front_nw,uint16_t motor_right_ne,uint16_t motor_back_se,uint16_t motor_left_sw) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[9]; + _mav_put_uint16_t(buf, 0, motor_front_nw); + _mav_put_uint16_t(buf, 2, motor_right_ne); + _mav_put_uint16_t(buf, 4, motor_back_se); + _mav_put_uint16_t(buf, 6, motor_left_sw); + _mav_put_uint8_t(buf, 8, target_system); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 9); +#else + mavlink_set_quad_motors_setpoint_t packet; + packet.motor_front_nw = motor_front_nw; + packet.motor_right_ne = motor_right_ne; + packet.motor_back_se = motor_back_se; + packet.motor_left_sw = motor_left_sw; + packet.target_system = target_system; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 9); +#endif + + msg->msgid = MAVLINK_MSG_ID_SET_QUAD_MOTORS_SETPOINT; + return mavlink_finalize_message_chan(msg, system_id, component_id, chan, 9, 30); +} + +/** + * @brief Encode a set_quad_motors_setpoint struct into a message + * + * @param system_id ID of this system + * @param component_id ID of this component (e.g. 200 for IMU) + * @param msg The MAVLink message to compress the data into + * @param set_quad_motors_setpoint C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_set_quad_motors_setpoint_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_set_quad_motors_setpoint_t* set_quad_motors_setpoint) +{ + return mavlink_msg_set_quad_motors_setpoint_pack(system_id, component_id, msg, set_quad_motors_setpoint->target_system, set_quad_motors_setpoint->motor_front_nw, set_quad_motors_setpoint->motor_right_ne, set_quad_motors_setpoint->motor_back_se, set_quad_motors_setpoint->motor_left_sw); +} + +/** + * @brief Send a set_quad_motors_setpoint message + * @param chan MAVLink channel to send the message + * + * @param target_system System ID of the system that should set these motor commands + * @param motor_front_nw Front motor in + configuration, front left motor in x configuration + * @param motor_right_ne Right motor in + configuration, front right motor in x configuration + * @param motor_back_se Back motor in + configuration, back right motor in x configuration + * @param motor_left_sw Left motor in + configuration, back left motor in x configuration + */ +#ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS + +static inline void mavlink_msg_set_quad_motors_setpoint_send(mavlink_channel_t chan, uint8_t target_system, uint16_t motor_front_nw, uint16_t motor_right_ne, uint16_t motor_back_se, uint16_t motor_left_sw) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[9]; + _mav_put_uint16_t(buf, 0, motor_front_nw); + _mav_put_uint16_t(buf, 2, motor_right_ne); + _mav_put_uint16_t(buf, 4, motor_back_se); + _mav_put_uint16_t(buf, 6, motor_left_sw); + _mav_put_uint8_t(buf, 8, target_system); + + _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_SET_QUAD_MOTORS_SETPOINT, buf, 9, 30); +#else + mavlink_set_quad_motors_setpoint_t packet; + packet.motor_front_nw = motor_front_nw; + packet.motor_right_ne = motor_right_ne; + packet.motor_back_se = motor_back_se; + packet.motor_left_sw = motor_left_sw; + packet.target_system = target_system; + + _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_SET_QUAD_MOTORS_SETPOINT, (const char *)&packet, 9, 30); +#endif +} + +#endif + +// MESSAGE SET_QUAD_MOTORS_SETPOINT UNPACKING + + +/** + * @brief Get field target_system from set_quad_motors_setpoint message + * + * @return System ID of the system that should set these motor commands + */ +static inline uint8_t mavlink_msg_set_quad_motors_setpoint_get_target_system(const mavlink_message_t* msg) +{ + return _MAV_RETURN_uint8_t(msg, 8); +} + +/** + * @brief Get field motor_front_nw from set_quad_motors_setpoint message + * + * @return Front motor in + configuration, front left motor in x configuration + */ +static inline uint16_t mavlink_msg_set_quad_motors_setpoint_get_motor_front_nw(const mavlink_message_t* msg) +{ + return _MAV_RETURN_uint16_t(msg, 0); +} + +/** + * @brief Get field motor_right_ne from set_quad_motors_setpoint message + * + * @return Right motor in + configuration, front right motor in x configuration + */ +static inline uint16_t mavlink_msg_set_quad_motors_setpoint_get_motor_right_ne(const mavlink_message_t* msg) +{ + return _MAV_RETURN_uint16_t(msg, 2); +} + +/** + * @brief Get field motor_back_se from set_quad_motors_setpoint message + * + * @return Back motor in + configuration, back right motor in x configuration + */ +static inline uint16_t mavlink_msg_set_quad_motors_setpoint_get_motor_back_se(const mavlink_message_t* msg) +{ + return _MAV_RETURN_uint16_t(msg, 4); +} + +/** + * @brief Get field motor_left_sw from set_quad_motors_setpoint message + * + * @return Left motor in + configuration, back left motor in x configuration + */ +static inline uint16_t mavlink_msg_set_quad_motors_setpoint_get_motor_left_sw(const mavlink_message_t* msg) +{ + return _MAV_RETURN_uint16_t(msg, 6); +} + +/** + * @brief Decode a set_quad_motors_setpoint message into a struct + * + * @param msg The message to decode + * @param set_quad_motors_setpoint C-struct to decode the message contents into + */ +static inline void mavlink_msg_set_quad_motors_setpoint_decode(const mavlink_message_t* msg, mavlink_set_quad_motors_setpoint_t* set_quad_motors_setpoint) +{ +#if MAVLINK_NEED_BYTE_SWAP + set_quad_motors_setpoint->motor_front_nw = mavlink_msg_set_quad_motors_setpoint_get_motor_front_nw(msg); + set_quad_motors_setpoint->motor_right_ne = mavlink_msg_set_quad_motors_setpoint_get_motor_right_ne(msg); + set_quad_motors_setpoint->motor_back_se = mavlink_msg_set_quad_motors_setpoint_get_motor_back_se(msg); + set_quad_motors_setpoint->motor_left_sw = mavlink_msg_set_quad_motors_setpoint_get_motor_left_sw(msg); + set_quad_motors_setpoint->target_system = mavlink_msg_set_quad_motors_setpoint_get_target_system(msg); +#else + memcpy(set_quad_motors_setpoint, _MAV_PAYLOAD(msg), 9); +#endif +} diff --git a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_set_quad_swarm_led_roll_pitch_yaw_thrust.h b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_set_quad_swarm_led_roll_pitch_yaw_thrust.h new file mode 100644 index 000000000..75a1420a1 --- /dev/null +++ b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_set_quad_swarm_led_roll_pitch_yaw_thrust.h @@ -0,0 +1,320 @@ +// MESSAGE SET_QUAD_SWARM_LED_ROLL_PITCH_YAW_THRUST PACKING + +#define MAVLINK_MSG_ID_SET_QUAD_SWARM_LED_ROLL_PITCH_YAW_THRUST 63 + +typedef struct __mavlink_set_quad_swarm_led_roll_pitch_yaw_thrust_t +{ + int16_t roll[4]; ///< Desired roll angle in radians +-PI (+-32767) + int16_t pitch[4]; ///< Desired pitch angle in radians +-PI (+-32767) + int16_t yaw[4]; ///< Desired yaw angle in radians, scaled to int16 +-PI (+-32767) + uint16_t thrust[4]; ///< Collective thrust, scaled to uint16 (0..65535) + uint8_t group; ///< ID of the quadrotor group (0 - 255, up to 256 groups supported) + uint8_t mode; ///< ID of the flight mode (0 - 255, up to 256 modes supported) + uint8_t led_red[4]; ///< RGB red channel (0-255) + uint8_t led_blue[4]; ///< RGB green channel (0-255) + uint8_t led_green[4]; ///< RGB blue channel (0-255) +} mavlink_set_quad_swarm_led_roll_pitch_yaw_thrust_t; + +#define MAVLINK_MSG_ID_SET_QUAD_SWARM_LED_ROLL_PITCH_YAW_THRUST_LEN 46 +#define MAVLINK_MSG_ID_63_LEN 46 + +#define MAVLINK_MSG_SET_QUAD_SWARM_LED_ROLL_PITCH_YAW_THRUST_FIELD_ROLL_LEN 4 +#define MAVLINK_MSG_SET_QUAD_SWARM_LED_ROLL_PITCH_YAW_THRUST_FIELD_PITCH_LEN 4 +#define MAVLINK_MSG_SET_QUAD_SWARM_LED_ROLL_PITCH_YAW_THRUST_FIELD_YAW_LEN 4 +#define MAVLINK_MSG_SET_QUAD_SWARM_LED_ROLL_PITCH_YAW_THRUST_FIELD_THRUST_LEN 4 +#define MAVLINK_MSG_SET_QUAD_SWARM_LED_ROLL_PITCH_YAW_THRUST_FIELD_LED_RED_LEN 4 +#define MAVLINK_MSG_SET_QUAD_SWARM_LED_ROLL_PITCH_YAW_THRUST_FIELD_LED_BLUE_LEN 4 +#define MAVLINK_MSG_SET_QUAD_SWARM_LED_ROLL_PITCH_YAW_THRUST_FIELD_LED_GREEN_LEN 4 + +#define MAVLINK_MESSAGE_INFO_SET_QUAD_SWARM_LED_ROLL_PITCH_YAW_THRUST { \ + "SET_QUAD_SWARM_LED_ROLL_PITCH_YAW_THRUST", \ + 9, \ + { { "roll", NULL, MAVLINK_TYPE_INT16_T, 4, 0, offsetof(mavlink_set_quad_swarm_led_roll_pitch_yaw_thrust_t, roll) }, \ + { "pitch", NULL, MAVLINK_TYPE_INT16_T, 4, 8, offsetof(mavlink_set_quad_swarm_led_roll_pitch_yaw_thrust_t, pitch) }, \ + { "yaw", NULL, MAVLINK_TYPE_INT16_T, 4, 16, offsetof(mavlink_set_quad_swarm_led_roll_pitch_yaw_thrust_t, yaw) }, \ + { "thrust", NULL, MAVLINK_TYPE_UINT16_T, 4, 24, offsetof(mavlink_set_quad_swarm_led_roll_pitch_yaw_thrust_t, thrust) }, \ + { "group", NULL, MAVLINK_TYPE_UINT8_T, 0, 32, offsetof(mavlink_set_quad_swarm_led_roll_pitch_yaw_thrust_t, group) }, \ + { "mode", NULL, MAVLINK_TYPE_UINT8_T, 0, 33, offsetof(mavlink_set_quad_swarm_led_roll_pitch_yaw_thrust_t, mode) }, \ + { "led_red", NULL, MAVLINK_TYPE_UINT8_T, 4, 34, offsetof(mavlink_set_quad_swarm_led_roll_pitch_yaw_thrust_t, led_red) }, \ + { "led_blue", NULL, MAVLINK_TYPE_UINT8_T, 4, 38, offsetof(mavlink_set_quad_swarm_led_roll_pitch_yaw_thrust_t, led_blue) }, \ + { "led_green", NULL, MAVLINK_TYPE_UINT8_T, 4, 42, offsetof(mavlink_set_quad_swarm_led_roll_pitch_yaw_thrust_t, led_green) }, \ + } \ +} + + +/** + * @brief Pack a set_quad_swarm_led_roll_pitch_yaw_thrust message + * @param system_id ID of this system + * @param component_id ID of this component (e.g. 200 for IMU) + * @param msg The MAVLink message to compress the data into + * + * @param group ID of the quadrotor group (0 - 255, up to 256 groups supported) + * @param mode ID of the flight mode (0 - 255, up to 256 modes supported) + * @param led_red RGB red channel (0-255) + * @param led_blue RGB green channel (0-255) + * @param led_green RGB blue channel (0-255) + * @param roll Desired roll angle in radians +-PI (+-32767) + * @param pitch Desired pitch angle in radians +-PI (+-32767) + * @param yaw Desired yaw angle in radians, scaled to int16 +-PI (+-32767) + * @param thrust Collective thrust, scaled to uint16 (0..65535) + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_set_quad_swarm_led_roll_pitch_yaw_thrust_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, + uint8_t group, uint8_t mode, const uint8_t *led_red, const uint8_t *led_blue, const uint8_t *led_green, const int16_t *roll, const int16_t *pitch, const int16_t *yaw, const uint16_t *thrust) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[46]; + _mav_put_uint8_t(buf, 32, group); + _mav_put_uint8_t(buf, 33, mode); + _mav_put_int16_t_array(buf, 0, roll, 4); + _mav_put_int16_t_array(buf, 8, pitch, 4); + _mav_put_int16_t_array(buf, 16, yaw, 4); + _mav_put_uint16_t_array(buf, 24, thrust, 4); + _mav_put_uint8_t_array(buf, 34, led_red, 4); + _mav_put_uint8_t_array(buf, 38, led_blue, 4); + _mav_put_uint8_t_array(buf, 42, led_green, 4); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 46); +#else + mavlink_set_quad_swarm_led_roll_pitch_yaw_thrust_t packet; + packet.group = group; + packet.mode = mode; + mav_array_memcpy(packet.roll, roll, sizeof(int16_t)*4); + mav_array_memcpy(packet.pitch, pitch, sizeof(int16_t)*4); + mav_array_memcpy(packet.yaw, yaw, sizeof(int16_t)*4); + mav_array_memcpy(packet.thrust, thrust, sizeof(uint16_t)*4); + mav_array_memcpy(packet.led_red, led_red, sizeof(uint8_t)*4); + mav_array_memcpy(packet.led_blue, led_blue, sizeof(uint8_t)*4); + mav_array_memcpy(packet.led_green, led_green, sizeof(uint8_t)*4); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 46); +#endif + + msg->msgid = MAVLINK_MSG_ID_SET_QUAD_SWARM_LED_ROLL_PITCH_YAW_THRUST; + return mavlink_finalize_message(msg, system_id, component_id, 46, 130); +} + +/** + * @brief Pack a set_quad_swarm_led_roll_pitch_yaw_thrust message on a channel + * @param system_id ID of this system + * @param component_id ID of this component (e.g. 200 for IMU) + * @param chan The MAVLink channel this message was sent over + * @param msg The MAVLink message to compress the data into + * @param group ID of the quadrotor group (0 - 255, up to 256 groups supported) + * @param mode ID of the flight mode (0 - 255, up to 256 modes supported) + * @param led_red RGB red channel (0-255) + * @param led_blue RGB green channel (0-255) + * @param led_green RGB blue channel (0-255) + * @param roll Desired roll angle in radians +-PI (+-32767) + * @param pitch Desired pitch angle in radians +-PI (+-32767) + * @param yaw Desired yaw angle in radians, scaled to int16 +-PI (+-32767) + * @param thrust Collective thrust, scaled to uint16 (0..65535) + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_set_quad_swarm_led_roll_pitch_yaw_thrust_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, + mavlink_message_t* msg, + uint8_t group,uint8_t mode,const uint8_t *led_red,const uint8_t *led_blue,const uint8_t *led_green,const int16_t *roll,const int16_t *pitch,const int16_t *yaw,const uint16_t *thrust) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[46]; + _mav_put_uint8_t(buf, 32, group); + _mav_put_uint8_t(buf, 33, mode); + _mav_put_int16_t_array(buf, 0, roll, 4); + _mav_put_int16_t_array(buf, 8, pitch, 4); + _mav_put_int16_t_array(buf, 16, yaw, 4); + _mav_put_uint16_t_array(buf, 24, thrust, 4); + _mav_put_uint8_t_array(buf, 34, led_red, 4); + _mav_put_uint8_t_array(buf, 38, led_blue, 4); + _mav_put_uint8_t_array(buf, 42, led_green, 4); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 46); +#else + mavlink_set_quad_swarm_led_roll_pitch_yaw_thrust_t packet; + packet.group = group; + packet.mode = mode; + mav_array_memcpy(packet.roll, roll, sizeof(int16_t)*4); + mav_array_memcpy(packet.pitch, pitch, sizeof(int16_t)*4); + mav_array_memcpy(packet.yaw, yaw, sizeof(int16_t)*4); + mav_array_memcpy(packet.thrust, thrust, sizeof(uint16_t)*4); + mav_array_memcpy(packet.led_red, led_red, sizeof(uint8_t)*4); + mav_array_memcpy(packet.led_blue, led_blue, sizeof(uint8_t)*4); + mav_array_memcpy(packet.led_green, led_green, sizeof(uint8_t)*4); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 46); +#endif + + msg->msgid = MAVLINK_MSG_ID_SET_QUAD_SWARM_LED_ROLL_PITCH_YAW_THRUST; + return mavlink_finalize_message_chan(msg, system_id, component_id, chan, 46, 130); +} + +/** + * @brief Encode a set_quad_swarm_led_roll_pitch_yaw_thrust struct into a message + * + * @param system_id ID of this system + * @param component_id ID of this component (e.g. 200 for IMU) + * @param msg The MAVLink message to compress the data into + * @param set_quad_swarm_led_roll_pitch_yaw_thrust C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_set_quad_swarm_led_roll_pitch_yaw_thrust_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_set_quad_swarm_led_roll_pitch_yaw_thrust_t* set_quad_swarm_led_roll_pitch_yaw_thrust) +{ + return mavlink_msg_set_quad_swarm_led_roll_pitch_yaw_thrust_pack(system_id, component_id, msg, set_quad_swarm_led_roll_pitch_yaw_thrust->group, set_quad_swarm_led_roll_pitch_yaw_thrust->mode, set_quad_swarm_led_roll_pitch_yaw_thrust->led_red, set_quad_swarm_led_roll_pitch_yaw_thrust->led_blue, set_quad_swarm_led_roll_pitch_yaw_thrust->led_green, set_quad_swarm_led_roll_pitch_yaw_thrust->roll, set_quad_swarm_led_roll_pitch_yaw_thrust->pitch, set_quad_swarm_led_roll_pitch_yaw_thrust->yaw, set_quad_swarm_led_roll_pitch_yaw_thrust->thrust); +} + +/** + * @brief Send a set_quad_swarm_led_roll_pitch_yaw_thrust message + * @param chan MAVLink channel to send the message + * + * @param group ID of the quadrotor group (0 - 255, up to 256 groups supported) + * @param mode ID of the flight mode (0 - 255, up to 256 modes supported) + * @param led_red RGB red channel (0-255) + * @param led_blue RGB green channel (0-255) + * @param led_green RGB blue channel (0-255) + * @param roll Desired roll angle in radians +-PI (+-32767) + * @param pitch Desired pitch angle in radians +-PI (+-32767) + * @param yaw Desired yaw angle in radians, scaled to int16 +-PI (+-32767) + * @param thrust Collective thrust, scaled to uint16 (0..65535) + */ +#ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS + +static inline void mavlink_msg_set_quad_swarm_led_roll_pitch_yaw_thrust_send(mavlink_channel_t chan, uint8_t group, uint8_t mode, const uint8_t *led_red, const uint8_t *led_blue, const uint8_t *led_green, const int16_t *roll, const int16_t *pitch, const int16_t *yaw, const uint16_t *thrust) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[46]; + _mav_put_uint8_t(buf, 32, group); + _mav_put_uint8_t(buf, 33, mode); + _mav_put_int16_t_array(buf, 0, roll, 4); + _mav_put_int16_t_array(buf, 8, pitch, 4); + _mav_put_int16_t_array(buf, 16, yaw, 4); + _mav_put_uint16_t_array(buf, 24, thrust, 4); + _mav_put_uint8_t_array(buf, 34, led_red, 4); + _mav_put_uint8_t_array(buf, 38, led_blue, 4); + _mav_put_uint8_t_array(buf, 42, led_green, 4); + _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_SET_QUAD_SWARM_LED_ROLL_PITCH_YAW_THRUST, buf, 46, 130); +#else + mavlink_set_quad_swarm_led_roll_pitch_yaw_thrust_t packet; + packet.group = group; + packet.mode = mode; + mav_array_memcpy(packet.roll, roll, sizeof(int16_t)*4); + mav_array_memcpy(packet.pitch, pitch, sizeof(int16_t)*4); + mav_array_memcpy(packet.yaw, yaw, sizeof(int16_t)*4); + mav_array_memcpy(packet.thrust, thrust, sizeof(uint16_t)*4); + mav_array_memcpy(packet.led_red, led_red, sizeof(uint8_t)*4); + mav_array_memcpy(packet.led_blue, led_blue, sizeof(uint8_t)*4); + mav_array_memcpy(packet.led_green, led_green, sizeof(uint8_t)*4); + _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_SET_QUAD_SWARM_LED_ROLL_PITCH_YAW_THRUST, (const char *)&packet, 46, 130); +#endif +} + +#endif + +// MESSAGE SET_QUAD_SWARM_LED_ROLL_PITCH_YAW_THRUST UNPACKING + + +/** + * @brief Get field group from set_quad_swarm_led_roll_pitch_yaw_thrust message + * + * @return ID of the quadrotor group (0 - 255, up to 256 groups supported) + */ +static inline uint8_t mavlink_msg_set_quad_swarm_led_roll_pitch_yaw_thrust_get_group(const mavlink_message_t* msg) +{ + return _MAV_RETURN_uint8_t(msg, 32); +} + +/** + * @brief Get field mode from set_quad_swarm_led_roll_pitch_yaw_thrust message + * + * @return ID of the flight mode (0 - 255, up to 256 modes supported) + */ +static inline uint8_t mavlink_msg_set_quad_swarm_led_roll_pitch_yaw_thrust_get_mode(const mavlink_message_t* msg) +{ + return _MAV_RETURN_uint8_t(msg, 33); +} + +/** + * @brief Get field led_red from set_quad_swarm_led_roll_pitch_yaw_thrust message + * + * @return RGB red channel (0-255) + */ +static inline uint16_t mavlink_msg_set_quad_swarm_led_roll_pitch_yaw_thrust_get_led_red(const mavlink_message_t* msg, uint8_t *led_red) +{ + return _MAV_RETURN_uint8_t_array(msg, led_red, 4, 34); +} + +/** + * @brief Get field led_blue from set_quad_swarm_led_roll_pitch_yaw_thrust message + * + * @return RGB green channel (0-255) + */ +static inline uint16_t mavlink_msg_set_quad_swarm_led_roll_pitch_yaw_thrust_get_led_blue(const mavlink_message_t* msg, uint8_t *led_blue) +{ + return _MAV_RETURN_uint8_t_array(msg, led_blue, 4, 38); +} + +/** + * @brief Get field led_green from set_quad_swarm_led_roll_pitch_yaw_thrust message + * + * @return RGB blue channel (0-255) + */ +static inline uint16_t mavlink_msg_set_quad_swarm_led_roll_pitch_yaw_thrust_get_led_green(const mavlink_message_t* msg, uint8_t *led_green) +{ + return _MAV_RETURN_uint8_t_array(msg, led_green, 4, 42); +} + +/** + * @brief Get field roll from set_quad_swarm_led_roll_pitch_yaw_thrust message + * + * @return Desired roll angle in radians +-PI (+-32767) + */ +static inline uint16_t mavlink_msg_set_quad_swarm_led_roll_pitch_yaw_thrust_get_roll(const mavlink_message_t* msg, int16_t *roll) +{ + return _MAV_RETURN_int16_t_array(msg, roll, 4, 0); +} + +/** + * @brief Get field pitch from set_quad_swarm_led_roll_pitch_yaw_thrust message + * + * @return Desired pitch angle in radians +-PI (+-32767) + */ +static inline uint16_t mavlink_msg_set_quad_swarm_led_roll_pitch_yaw_thrust_get_pitch(const mavlink_message_t* msg, int16_t *pitch) +{ + return _MAV_RETURN_int16_t_array(msg, pitch, 4, 8); +} + +/** + * @brief Get field yaw from set_quad_swarm_led_roll_pitch_yaw_thrust message + * + * @return Desired yaw angle in radians, scaled to int16 +-PI (+-32767) + */ +static inline uint16_t mavlink_msg_set_quad_swarm_led_roll_pitch_yaw_thrust_get_yaw(const mavlink_message_t* msg, int16_t *yaw) +{ + return _MAV_RETURN_int16_t_array(msg, yaw, 4, 16); +} + +/** + * @brief Get field thrust from set_quad_swarm_led_roll_pitch_yaw_thrust message + * + * @return Collective thrust, scaled to uint16 (0..65535) + */ +static inline uint16_t mavlink_msg_set_quad_swarm_led_roll_pitch_yaw_thrust_get_thrust(const mavlink_message_t* msg, uint16_t *thrust) +{ + return _MAV_RETURN_uint16_t_array(msg, thrust, 4, 24); +} + +/** + * @brief Decode a set_quad_swarm_led_roll_pitch_yaw_thrust message into a struct + * + * @param msg The message to decode + * @param set_quad_swarm_led_roll_pitch_yaw_thrust C-struct to decode the message contents into + */ +static inline void mavlink_msg_set_quad_swarm_led_roll_pitch_yaw_thrust_decode(const mavlink_message_t* msg, mavlink_set_quad_swarm_led_roll_pitch_yaw_thrust_t* set_quad_swarm_led_roll_pitch_yaw_thrust) +{ +#if MAVLINK_NEED_BYTE_SWAP + mavlink_msg_set_quad_swarm_led_roll_pitch_yaw_thrust_get_roll(msg, set_quad_swarm_led_roll_pitch_yaw_thrust->roll); + mavlink_msg_set_quad_swarm_led_roll_pitch_yaw_thrust_get_pitch(msg, set_quad_swarm_led_roll_pitch_yaw_thrust->pitch); + mavlink_msg_set_quad_swarm_led_roll_pitch_yaw_thrust_get_yaw(msg, set_quad_swarm_led_roll_pitch_yaw_thrust->yaw); + mavlink_msg_set_quad_swarm_led_roll_pitch_yaw_thrust_get_thrust(msg, set_quad_swarm_led_roll_pitch_yaw_thrust->thrust); + set_quad_swarm_led_roll_pitch_yaw_thrust->group = mavlink_msg_set_quad_swarm_led_roll_pitch_yaw_thrust_get_group(msg); + set_quad_swarm_led_roll_pitch_yaw_thrust->mode = mavlink_msg_set_quad_swarm_led_roll_pitch_yaw_thrust_get_mode(msg); + mavlink_msg_set_quad_swarm_led_roll_pitch_yaw_thrust_get_led_red(msg, set_quad_swarm_led_roll_pitch_yaw_thrust->led_red); + mavlink_msg_set_quad_swarm_led_roll_pitch_yaw_thrust_get_led_blue(msg, set_quad_swarm_led_roll_pitch_yaw_thrust->led_blue); + mavlink_msg_set_quad_swarm_led_roll_pitch_yaw_thrust_get_led_green(msg, set_quad_swarm_led_roll_pitch_yaw_thrust->led_green); +#else + memcpy(set_quad_swarm_led_roll_pitch_yaw_thrust, _MAV_PAYLOAD(msg), 46); +#endif +} diff --git a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_set_quad_swarm_roll_pitch_yaw_thrust.h b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_set_quad_swarm_roll_pitch_yaw_thrust.h new file mode 100644 index 000000000..35c5db18c --- /dev/null +++ b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_set_quad_swarm_roll_pitch_yaw_thrust.h @@ -0,0 +1,251 @@ +// MESSAGE SET_QUAD_SWARM_ROLL_PITCH_YAW_THRUST PACKING + +#define MAVLINK_MSG_ID_SET_QUAD_SWARM_ROLL_PITCH_YAW_THRUST 61 + +typedef struct __mavlink_set_quad_swarm_roll_pitch_yaw_thrust_t +{ + int16_t roll[4]; ///< Desired roll angle in radians +-PI (+-32767) + int16_t pitch[4]; ///< Desired pitch angle in radians +-PI (+-32767) + int16_t yaw[4]; ///< Desired yaw angle in radians, scaled to int16 +-PI (+-32767) + uint16_t thrust[4]; ///< Collective thrust, scaled to uint16 (0..65535) + uint8_t group; ///< ID of the quadrotor group (0 - 255, up to 256 groups supported) + uint8_t mode; ///< ID of the flight mode (0 - 255, up to 256 modes supported) +} mavlink_set_quad_swarm_roll_pitch_yaw_thrust_t; + +#define MAVLINK_MSG_ID_SET_QUAD_SWARM_ROLL_PITCH_YAW_THRUST_LEN 34 +#define MAVLINK_MSG_ID_61_LEN 34 + +#define MAVLINK_MSG_SET_QUAD_SWARM_ROLL_PITCH_YAW_THRUST_FIELD_ROLL_LEN 4 +#define MAVLINK_MSG_SET_QUAD_SWARM_ROLL_PITCH_YAW_THRUST_FIELD_PITCH_LEN 4 +#define MAVLINK_MSG_SET_QUAD_SWARM_ROLL_PITCH_YAW_THRUST_FIELD_YAW_LEN 4 +#define MAVLINK_MSG_SET_QUAD_SWARM_ROLL_PITCH_YAW_THRUST_FIELD_THRUST_LEN 4 + +#define MAVLINK_MESSAGE_INFO_SET_QUAD_SWARM_ROLL_PITCH_YAW_THRUST { \ + "SET_QUAD_SWARM_ROLL_PITCH_YAW_THRUST", \ + 6, \ + { { "roll", NULL, MAVLINK_TYPE_INT16_T, 4, 0, offsetof(mavlink_set_quad_swarm_roll_pitch_yaw_thrust_t, roll) }, \ + { "pitch", NULL, MAVLINK_TYPE_INT16_T, 4, 8, offsetof(mavlink_set_quad_swarm_roll_pitch_yaw_thrust_t, pitch) }, \ + { "yaw", NULL, MAVLINK_TYPE_INT16_T, 4, 16, offsetof(mavlink_set_quad_swarm_roll_pitch_yaw_thrust_t, yaw) }, \ + { "thrust", NULL, MAVLINK_TYPE_UINT16_T, 4, 24, offsetof(mavlink_set_quad_swarm_roll_pitch_yaw_thrust_t, thrust) }, \ + { "group", NULL, MAVLINK_TYPE_UINT8_T, 0, 32, offsetof(mavlink_set_quad_swarm_roll_pitch_yaw_thrust_t, group) }, \ + { "mode", NULL, MAVLINK_TYPE_UINT8_T, 0, 33, offsetof(mavlink_set_quad_swarm_roll_pitch_yaw_thrust_t, mode) }, \ + } \ +} + + +/** + * @brief Pack a set_quad_swarm_roll_pitch_yaw_thrust message + * @param system_id ID of this system + * @param component_id ID of this component (e.g. 200 for IMU) + * @param msg The MAVLink message to compress the data into + * + * @param group ID of the quadrotor group (0 - 255, up to 256 groups supported) + * @param mode ID of the flight mode (0 - 255, up to 256 modes supported) + * @param roll Desired roll angle in radians +-PI (+-32767) + * @param pitch Desired pitch angle in radians +-PI (+-32767) + * @param yaw Desired yaw angle in radians, scaled to int16 +-PI (+-32767) + * @param thrust Collective thrust, scaled to uint16 (0..65535) + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_set_quad_swarm_roll_pitch_yaw_thrust_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, + uint8_t group, uint8_t mode, const int16_t *roll, const int16_t *pitch, const int16_t *yaw, const uint16_t *thrust) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[34]; + _mav_put_uint8_t(buf, 32, group); + _mav_put_uint8_t(buf, 33, mode); + _mav_put_int16_t_array(buf, 0, roll, 4); + _mav_put_int16_t_array(buf, 8, pitch, 4); + _mav_put_int16_t_array(buf, 16, yaw, 4); + _mav_put_uint16_t_array(buf, 24, thrust, 4); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 34); +#else + mavlink_set_quad_swarm_roll_pitch_yaw_thrust_t packet; + packet.group = group; + packet.mode = mode; + mav_array_memcpy(packet.roll, roll, sizeof(int16_t)*4); + mav_array_memcpy(packet.pitch, pitch, sizeof(int16_t)*4); + mav_array_memcpy(packet.yaw, yaw, sizeof(int16_t)*4); + mav_array_memcpy(packet.thrust, thrust, sizeof(uint16_t)*4); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 34); +#endif + + msg->msgid = MAVLINK_MSG_ID_SET_QUAD_SWARM_ROLL_PITCH_YAW_THRUST; + return mavlink_finalize_message(msg, system_id, component_id, 34, 240); +} + +/** + * @brief Pack a set_quad_swarm_roll_pitch_yaw_thrust message on a channel + * @param system_id ID of this system + * @param component_id ID of this component (e.g. 200 for IMU) + * @param chan The MAVLink channel this message was sent over + * @param msg The MAVLink message to compress the data into + * @param group ID of the quadrotor group (0 - 255, up to 256 groups supported) + * @param mode ID of the flight mode (0 - 255, up to 256 modes supported) + * @param roll Desired roll angle in radians +-PI (+-32767) + * @param pitch Desired pitch angle in radians +-PI (+-32767) + * @param yaw Desired yaw angle in radians, scaled to int16 +-PI (+-32767) + * @param thrust Collective thrust, scaled to uint16 (0..65535) + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_set_quad_swarm_roll_pitch_yaw_thrust_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, + mavlink_message_t* msg, + uint8_t group,uint8_t mode,const int16_t *roll,const int16_t *pitch,const int16_t *yaw,const uint16_t *thrust) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[34]; + _mav_put_uint8_t(buf, 32, group); + _mav_put_uint8_t(buf, 33, mode); + _mav_put_int16_t_array(buf, 0, roll, 4); + _mav_put_int16_t_array(buf, 8, pitch, 4); + _mav_put_int16_t_array(buf, 16, yaw, 4); + _mav_put_uint16_t_array(buf, 24, thrust, 4); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 34); +#else + mavlink_set_quad_swarm_roll_pitch_yaw_thrust_t packet; + packet.group = group; + packet.mode = mode; + mav_array_memcpy(packet.roll, roll, sizeof(int16_t)*4); + mav_array_memcpy(packet.pitch, pitch, sizeof(int16_t)*4); + mav_array_memcpy(packet.yaw, yaw, sizeof(int16_t)*4); + mav_array_memcpy(packet.thrust, thrust, sizeof(uint16_t)*4); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 34); +#endif + + msg->msgid = MAVLINK_MSG_ID_SET_QUAD_SWARM_ROLL_PITCH_YAW_THRUST; + return mavlink_finalize_message_chan(msg, system_id, component_id, chan, 34, 240); +} + +/** + * @brief Encode a set_quad_swarm_roll_pitch_yaw_thrust struct into a message + * + * @param system_id ID of this system + * @param component_id ID of this component (e.g. 200 for IMU) + * @param msg The MAVLink message to compress the data into + * @param set_quad_swarm_roll_pitch_yaw_thrust C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_set_quad_swarm_roll_pitch_yaw_thrust_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_set_quad_swarm_roll_pitch_yaw_thrust_t* set_quad_swarm_roll_pitch_yaw_thrust) +{ + return mavlink_msg_set_quad_swarm_roll_pitch_yaw_thrust_pack(system_id, component_id, msg, set_quad_swarm_roll_pitch_yaw_thrust->group, set_quad_swarm_roll_pitch_yaw_thrust->mode, set_quad_swarm_roll_pitch_yaw_thrust->roll, set_quad_swarm_roll_pitch_yaw_thrust->pitch, set_quad_swarm_roll_pitch_yaw_thrust->yaw, set_quad_swarm_roll_pitch_yaw_thrust->thrust); +} + +/** + * @brief Send a set_quad_swarm_roll_pitch_yaw_thrust message + * @param chan MAVLink channel to send the message + * + * @param group ID of the quadrotor group (0 - 255, up to 256 groups supported) + * @param mode ID of the flight mode (0 - 255, up to 256 modes supported) + * @param roll Desired roll angle in radians +-PI (+-32767) + * @param pitch Desired pitch angle in radians +-PI (+-32767) + * @param yaw Desired yaw angle in radians, scaled to int16 +-PI (+-32767) + * @param thrust Collective thrust, scaled to uint16 (0..65535) + */ +#ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS + +static inline void mavlink_msg_set_quad_swarm_roll_pitch_yaw_thrust_send(mavlink_channel_t chan, uint8_t group, uint8_t mode, const int16_t *roll, const int16_t *pitch, const int16_t *yaw, const uint16_t *thrust) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[34]; + _mav_put_uint8_t(buf, 32, group); + _mav_put_uint8_t(buf, 33, mode); + _mav_put_int16_t_array(buf, 0, roll, 4); + _mav_put_int16_t_array(buf, 8, pitch, 4); + _mav_put_int16_t_array(buf, 16, yaw, 4); + _mav_put_uint16_t_array(buf, 24, thrust, 4); + _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_SET_QUAD_SWARM_ROLL_PITCH_YAW_THRUST, buf, 34, 240); +#else + mavlink_set_quad_swarm_roll_pitch_yaw_thrust_t packet; + packet.group = group; + packet.mode = mode; + mav_array_memcpy(packet.roll, roll, sizeof(int16_t)*4); + mav_array_memcpy(packet.pitch, pitch, sizeof(int16_t)*4); + mav_array_memcpy(packet.yaw, yaw, sizeof(int16_t)*4); + mav_array_memcpy(packet.thrust, thrust, sizeof(uint16_t)*4); + _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_SET_QUAD_SWARM_ROLL_PITCH_YAW_THRUST, (const char *)&packet, 34, 240); +#endif +} + +#endif + +// MESSAGE SET_QUAD_SWARM_ROLL_PITCH_YAW_THRUST UNPACKING + + +/** + * @brief Get field group from set_quad_swarm_roll_pitch_yaw_thrust message + * + * @return ID of the quadrotor group (0 - 255, up to 256 groups supported) + */ +static inline uint8_t mavlink_msg_set_quad_swarm_roll_pitch_yaw_thrust_get_group(const mavlink_message_t* msg) +{ + return _MAV_RETURN_uint8_t(msg, 32); +} + +/** + * @brief Get field mode from set_quad_swarm_roll_pitch_yaw_thrust message + * + * @return ID of the flight mode (0 - 255, up to 256 modes supported) + */ +static inline uint8_t mavlink_msg_set_quad_swarm_roll_pitch_yaw_thrust_get_mode(const mavlink_message_t* msg) +{ + return _MAV_RETURN_uint8_t(msg, 33); +} + +/** + * @brief Get field roll from set_quad_swarm_roll_pitch_yaw_thrust message + * + * @return Desired roll angle in radians +-PI (+-32767) + */ +static inline uint16_t mavlink_msg_set_quad_swarm_roll_pitch_yaw_thrust_get_roll(const mavlink_message_t* msg, int16_t *roll) +{ + return _MAV_RETURN_int16_t_array(msg, roll, 4, 0); +} + +/** + * @brief Get field pitch from set_quad_swarm_roll_pitch_yaw_thrust message + * + * @return Desired pitch angle in radians +-PI (+-32767) + */ +static inline uint16_t mavlink_msg_set_quad_swarm_roll_pitch_yaw_thrust_get_pitch(const mavlink_message_t* msg, int16_t *pitch) +{ + return _MAV_RETURN_int16_t_array(msg, pitch, 4, 8); +} + +/** + * @brief Get field yaw from set_quad_swarm_roll_pitch_yaw_thrust message + * + * @return Desired yaw angle in radians, scaled to int16 +-PI (+-32767) + */ +static inline uint16_t mavlink_msg_set_quad_swarm_roll_pitch_yaw_thrust_get_yaw(const mavlink_message_t* msg, int16_t *yaw) +{ + return _MAV_RETURN_int16_t_array(msg, yaw, 4, 16); +} + +/** + * @brief Get field thrust from set_quad_swarm_roll_pitch_yaw_thrust message + * + * @return Collective thrust, scaled to uint16 (0..65535) + */ +static inline uint16_t mavlink_msg_set_quad_swarm_roll_pitch_yaw_thrust_get_thrust(const mavlink_message_t* msg, uint16_t *thrust) +{ + return _MAV_RETURN_uint16_t_array(msg, thrust, 4, 24); +} + +/** + * @brief Decode a set_quad_swarm_roll_pitch_yaw_thrust message into a struct + * + * @param msg The message to decode + * @param set_quad_swarm_roll_pitch_yaw_thrust C-struct to decode the message contents into + */ +static inline void mavlink_msg_set_quad_swarm_roll_pitch_yaw_thrust_decode(const mavlink_message_t* msg, mavlink_set_quad_swarm_roll_pitch_yaw_thrust_t* set_quad_swarm_roll_pitch_yaw_thrust) +{ +#if MAVLINK_NEED_BYTE_SWAP + mavlink_msg_set_quad_swarm_roll_pitch_yaw_thrust_get_roll(msg, set_quad_swarm_roll_pitch_yaw_thrust->roll); + mavlink_msg_set_quad_swarm_roll_pitch_yaw_thrust_get_pitch(msg, set_quad_swarm_roll_pitch_yaw_thrust->pitch); + mavlink_msg_set_quad_swarm_roll_pitch_yaw_thrust_get_yaw(msg, set_quad_swarm_roll_pitch_yaw_thrust->yaw); + mavlink_msg_set_quad_swarm_roll_pitch_yaw_thrust_get_thrust(msg, set_quad_swarm_roll_pitch_yaw_thrust->thrust); + set_quad_swarm_roll_pitch_yaw_thrust->group = mavlink_msg_set_quad_swarm_roll_pitch_yaw_thrust_get_group(msg); + set_quad_swarm_roll_pitch_yaw_thrust->mode = mavlink_msg_set_quad_swarm_roll_pitch_yaw_thrust_get_mode(msg); +#else + memcpy(set_quad_swarm_roll_pitch_yaw_thrust, _MAV_PAYLOAD(msg), 34); +#endif +} diff --git a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_set_roll_pitch_yaw_speed_thrust.h b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_set_roll_pitch_yaw_speed_thrust.h index 0141f7752..b79a7e9f2 100644 --- a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_set_roll_pitch_yaw_speed_thrust.h +++ b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_set_roll_pitch_yaw_speed_thrust.h @@ -56,7 +56,7 @@ static inline uint16_t mavlink_msg_set_roll_pitch_yaw_speed_thrust_pack(uint8_t _mav_put_uint8_t(buf, 16, target_system); _mav_put_uint8_t(buf, 17, target_component); - memcpy(_MAV_PAYLOAD(msg), buf, 18); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 18); #else mavlink_set_roll_pitch_yaw_speed_thrust_t packet; packet.roll_speed = roll_speed; @@ -66,7 +66,7 @@ static inline uint16_t mavlink_msg_set_roll_pitch_yaw_speed_thrust_pack(uint8_t packet.target_system = target_system; packet.target_component = target_component; - memcpy(_MAV_PAYLOAD(msg), &packet, 18); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 18); #endif msg->msgid = MAVLINK_MSG_ID_SET_ROLL_PITCH_YAW_SPEED_THRUST; @@ -100,7 +100,7 @@ static inline uint16_t mavlink_msg_set_roll_pitch_yaw_speed_thrust_pack_chan(uin _mav_put_uint8_t(buf, 16, target_system); _mav_put_uint8_t(buf, 17, target_component); - memcpy(_MAV_PAYLOAD(msg), buf, 18); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 18); #else mavlink_set_roll_pitch_yaw_speed_thrust_t packet; packet.roll_speed = roll_speed; @@ -110,7 +110,7 @@ static inline uint16_t mavlink_msg_set_roll_pitch_yaw_speed_thrust_pack_chan(uin packet.target_system = target_system; packet.target_component = target_component; - memcpy(_MAV_PAYLOAD(msg), &packet, 18); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 18); #endif msg->msgid = MAVLINK_MSG_ID_SET_ROLL_PITCH_YAW_SPEED_THRUST; diff --git a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_set_roll_pitch_yaw_thrust.h b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_set_roll_pitch_yaw_thrust.h index 453cf7b9c..8cd573a26 100644 --- a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_set_roll_pitch_yaw_thrust.h +++ b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_set_roll_pitch_yaw_thrust.h @@ -56,7 +56,7 @@ static inline uint16_t mavlink_msg_set_roll_pitch_yaw_thrust_pack(uint8_t system _mav_put_uint8_t(buf, 16, target_system); _mav_put_uint8_t(buf, 17, target_component); - memcpy(_MAV_PAYLOAD(msg), buf, 18); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 18); #else mavlink_set_roll_pitch_yaw_thrust_t packet; packet.roll = roll; @@ -66,7 +66,7 @@ static inline uint16_t mavlink_msg_set_roll_pitch_yaw_thrust_pack(uint8_t system packet.target_system = target_system; packet.target_component = target_component; - memcpy(_MAV_PAYLOAD(msg), &packet, 18); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 18); #endif msg->msgid = MAVLINK_MSG_ID_SET_ROLL_PITCH_YAW_THRUST; @@ -100,7 +100,7 @@ static inline uint16_t mavlink_msg_set_roll_pitch_yaw_thrust_pack_chan(uint8_t s _mav_put_uint8_t(buf, 16, target_system); _mav_put_uint8_t(buf, 17, target_component); - memcpy(_MAV_PAYLOAD(msg), buf, 18); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 18); #else mavlink_set_roll_pitch_yaw_thrust_t packet; packet.roll = roll; @@ -110,7 +110,7 @@ static inline uint16_t mavlink_msg_set_roll_pitch_yaw_thrust_pack_chan(uint8_t s packet.target_system = target_system; packet.target_component = target_component; - memcpy(_MAV_PAYLOAD(msg), &packet, 18); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 18); #endif msg->msgid = MAVLINK_MSG_ID_SET_ROLL_PITCH_YAW_THRUST; diff --git a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_setpoint_6dof.h b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_setpoint_6dof.h new file mode 100644 index 000000000..fec38a6a4 --- /dev/null +++ b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_setpoint_6dof.h @@ -0,0 +1,276 @@ +// MESSAGE SETPOINT_6DOF PACKING + +#define MAVLINK_MSG_ID_SETPOINT_6DOF 149 + +typedef struct __mavlink_setpoint_6dof_t +{ + float trans_x; ///< Translational Component in x + float trans_y; ///< Translational Component in y + float trans_z; ///< Translational Component in z + float rot_x; ///< Rotational Component in x + float rot_y; ///< Rotational Component in y + float rot_z; ///< Rotational Component in z + uint8_t target_system; ///< System ID +} mavlink_setpoint_6dof_t; + +#define MAVLINK_MSG_ID_SETPOINT_6DOF_LEN 25 +#define MAVLINK_MSG_ID_149_LEN 25 + + + +#define MAVLINK_MESSAGE_INFO_SETPOINT_6DOF { \ + "SETPOINT_6DOF", \ + 7, \ + { { "trans_x", NULL, MAVLINK_TYPE_FLOAT, 0, 0, offsetof(mavlink_setpoint_6dof_t, trans_x) }, \ + { "trans_y", NULL, MAVLINK_TYPE_FLOAT, 0, 4, offsetof(mavlink_setpoint_6dof_t, trans_y) }, \ + { "trans_z", NULL, MAVLINK_TYPE_FLOAT, 0, 8, offsetof(mavlink_setpoint_6dof_t, trans_z) }, \ + { "rot_x", NULL, MAVLINK_TYPE_FLOAT, 0, 12, offsetof(mavlink_setpoint_6dof_t, rot_x) }, \ + { "rot_y", NULL, MAVLINK_TYPE_FLOAT, 0, 16, offsetof(mavlink_setpoint_6dof_t, rot_y) }, \ + { "rot_z", NULL, MAVLINK_TYPE_FLOAT, 0, 20, offsetof(mavlink_setpoint_6dof_t, rot_z) }, \ + { "target_system", NULL, MAVLINK_TYPE_UINT8_T, 0, 24, offsetof(mavlink_setpoint_6dof_t, target_system) }, \ + } \ +} + + +/** + * @brief Pack a setpoint_6dof message + * @param system_id ID of this system + * @param component_id ID of this component (e.g. 200 for IMU) + * @param msg The MAVLink message to compress the data into + * + * @param target_system System ID + * @param trans_x Translational Component in x + * @param trans_y Translational Component in y + * @param trans_z Translational Component in z + * @param rot_x Rotational Component in x + * @param rot_y Rotational Component in y + * @param rot_z Rotational Component in z + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_setpoint_6dof_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, + uint8_t target_system, float trans_x, float trans_y, float trans_z, float rot_x, float rot_y, float rot_z) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[25]; + _mav_put_float(buf, 0, trans_x); + _mav_put_float(buf, 4, trans_y); + _mav_put_float(buf, 8, trans_z); + _mav_put_float(buf, 12, rot_x); + _mav_put_float(buf, 16, rot_y); + _mav_put_float(buf, 20, rot_z); + _mav_put_uint8_t(buf, 24, target_system); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 25); +#else + mavlink_setpoint_6dof_t packet; + packet.trans_x = trans_x; + packet.trans_y = trans_y; + packet.trans_z = trans_z; + packet.rot_x = rot_x; + packet.rot_y = rot_y; + packet.rot_z = rot_z; + packet.target_system = target_system; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 25); +#endif + + msg->msgid = MAVLINK_MSG_ID_SETPOINT_6DOF; + return mavlink_finalize_message(msg, system_id, component_id, 25, 15); +} + +/** + * @brief Pack a setpoint_6dof message on a channel + * @param system_id ID of this system + * @param component_id ID of this component (e.g. 200 for IMU) + * @param chan The MAVLink channel this message was sent over + * @param msg The MAVLink message to compress the data into + * @param target_system System ID + * @param trans_x Translational Component in x + * @param trans_y Translational Component in y + * @param trans_z Translational Component in z + * @param rot_x Rotational Component in x + * @param rot_y Rotational Component in y + * @param rot_z Rotational Component in z + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_setpoint_6dof_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, + mavlink_message_t* msg, + uint8_t target_system,float trans_x,float trans_y,float trans_z,float rot_x,float rot_y,float rot_z) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[25]; + _mav_put_float(buf, 0, trans_x); + _mav_put_float(buf, 4, trans_y); + _mav_put_float(buf, 8, trans_z); + _mav_put_float(buf, 12, rot_x); + _mav_put_float(buf, 16, rot_y); + _mav_put_float(buf, 20, rot_z); + _mav_put_uint8_t(buf, 24, target_system); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 25); +#else + mavlink_setpoint_6dof_t packet; + packet.trans_x = trans_x; + packet.trans_y = trans_y; + packet.trans_z = trans_z; + packet.rot_x = rot_x; + packet.rot_y = rot_y; + packet.rot_z = rot_z; + packet.target_system = target_system; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 25); +#endif + + msg->msgid = MAVLINK_MSG_ID_SETPOINT_6DOF; + return mavlink_finalize_message_chan(msg, system_id, component_id, chan, 25, 15); +} + +/** + * @brief Encode a setpoint_6dof struct into a message + * + * @param system_id ID of this system + * @param component_id ID of this component (e.g. 200 for IMU) + * @param msg The MAVLink message to compress the data into + * @param setpoint_6dof C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_setpoint_6dof_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_setpoint_6dof_t* setpoint_6dof) +{ + return mavlink_msg_setpoint_6dof_pack(system_id, component_id, msg, setpoint_6dof->target_system, setpoint_6dof->trans_x, setpoint_6dof->trans_y, setpoint_6dof->trans_z, setpoint_6dof->rot_x, setpoint_6dof->rot_y, setpoint_6dof->rot_z); +} + +/** + * @brief Send a setpoint_6dof message + * @param chan MAVLink channel to send the message + * + * @param target_system System ID + * @param trans_x Translational Component in x + * @param trans_y Translational Component in y + * @param trans_z Translational Component in z + * @param rot_x Rotational Component in x + * @param rot_y Rotational Component in y + * @param rot_z Rotational Component in z + */ +#ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS + +static inline void mavlink_msg_setpoint_6dof_send(mavlink_channel_t chan, uint8_t target_system, float trans_x, float trans_y, float trans_z, float rot_x, float rot_y, float rot_z) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[25]; + _mav_put_float(buf, 0, trans_x); + _mav_put_float(buf, 4, trans_y); + _mav_put_float(buf, 8, trans_z); + _mav_put_float(buf, 12, rot_x); + _mav_put_float(buf, 16, rot_y); + _mav_put_float(buf, 20, rot_z); + _mav_put_uint8_t(buf, 24, target_system); + + _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_SETPOINT_6DOF, buf, 25, 15); +#else + mavlink_setpoint_6dof_t packet; + packet.trans_x = trans_x; + packet.trans_y = trans_y; + packet.trans_z = trans_z; + packet.rot_x = rot_x; + packet.rot_y = rot_y; + packet.rot_z = rot_z; + packet.target_system = target_system; + + _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_SETPOINT_6DOF, (const char *)&packet, 25, 15); +#endif +} + +#endif + +// MESSAGE SETPOINT_6DOF UNPACKING + + +/** + * @brief Get field target_system from setpoint_6dof message + * + * @return System ID + */ +static inline uint8_t mavlink_msg_setpoint_6dof_get_target_system(const mavlink_message_t* msg) +{ + return _MAV_RETURN_uint8_t(msg, 24); +} + +/** + * @brief Get field trans_x from setpoint_6dof message + * + * @return Translational Component in x + */ +static inline float mavlink_msg_setpoint_6dof_get_trans_x(const mavlink_message_t* msg) +{ + return _MAV_RETURN_float(msg, 0); +} + +/** + * @brief Get field trans_y from setpoint_6dof message + * + * @return Translational Component in y + */ +static inline float mavlink_msg_setpoint_6dof_get_trans_y(const mavlink_message_t* msg) +{ + return _MAV_RETURN_float(msg, 4); +} + +/** + * @brief Get field trans_z from setpoint_6dof message + * + * @return Translational Component in z + */ +static inline float mavlink_msg_setpoint_6dof_get_trans_z(const mavlink_message_t* msg) +{ + return _MAV_RETURN_float(msg, 8); +} + +/** + * @brief Get field rot_x from setpoint_6dof message + * + * @return Rotational Component in x + */ +static inline float mavlink_msg_setpoint_6dof_get_rot_x(const mavlink_message_t* msg) +{ + return _MAV_RETURN_float(msg, 12); +} + +/** + * @brief Get field rot_y from setpoint_6dof message + * + * @return Rotational Component in y + */ +static inline float mavlink_msg_setpoint_6dof_get_rot_y(const mavlink_message_t* msg) +{ + return _MAV_RETURN_float(msg, 16); +} + +/** + * @brief Get field rot_z from setpoint_6dof message + * + * @return Rotational Component in z + */ +static inline float mavlink_msg_setpoint_6dof_get_rot_z(const mavlink_message_t* msg) +{ + return _MAV_RETURN_float(msg, 20); +} + +/** + * @brief Decode a setpoint_6dof message into a struct + * + * @param msg The message to decode + * @param setpoint_6dof C-struct to decode the message contents into + */ +static inline void mavlink_msg_setpoint_6dof_decode(const mavlink_message_t* msg, mavlink_setpoint_6dof_t* setpoint_6dof) +{ +#if MAVLINK_NEED_BYTE_SWAP + setpoint_6dof->trans_x = mavlink_msg_setpoint_6dof_get_trans_x(msg); + setpoint_6dof->trans_y = mavlink_msg_setpoint_6dof_get_trans_y(msg); + setpoint_6dof->trans_z = mavlink_msg_setpoint_6dof_get_trans_z(msg); + setpoint_6dof->rot_x = mavlink_msg_setpoint_6dof_get_rot_x(msg); + setpoint_6dof->rot_y = mavlink_msg_setpoint_6dof_get_rot_y(msg); + setpoint_6dof->rot_z = mavlink_msg_setpoint_6dof_get_rot_z(msg); + setpoint_6dof->target_system = mavlink_msg_setpoint_6dof_get_target_system(msg); +#else + memcpy(setpoint_6dof, _MAV_PAYLOAD(msg), 25); +#endif +} diff --git a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_setpoint_8dof.h b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_setpoint_8dof.h new file mode 100644 index 000000000..bc761be08 --- /dev/null +++ b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_setpoint_8dof.h @@ -0,0 +1,320 @@ +// MESSAGE SETPOINT_8DOF PACKING + +#define MAVLINK_MSG_ID_SETPOINT_8DOF 148 + +typedef struct __mavlink_setpoint_8dof_t +{ + float val1; ///< Value 1 + float val2; ///< Value 2 + float val3; ///< Value 3 + float val4; ///< Value 4 + float val5; ///< Value 5 + float val6; ///< Value 6 + float val7; ///< Value 7 + float val8; ///< Value 8 + uint8_t target_system; ///< System ID +} mavlink_setpoint_8dof_t; + +#define MAVLINK_MSG_ID_SETPOINT_8DOF_LEN 33 +#define MAVLINK_MSG_ID_148_LEN 33 + + + +#define MAVLINK_MESSAGE_INFO_SETPOINT_8DOF { \ + "SETPOINT_8DOF", \ + 9, \ + { { "val1", NULL, MAVLINK_TYPE_FLOAT, 0, 0, offsetof(mavlink_setpoint_8dof_t, val1) }, \ + { "val2", NULL, MAVLINK_TYPE_FLOAT, 0, 4, offsetof(mavlink_setpoint_8dof_t, val2) }, \ + { "val3", NULL, MAVLINK_TYPE_FLOAT, 0, 8, offsetof(mavlink_setpoint_8dof_t, val3) }, \ + { "val4", NULL, MAVLINK_TYPE_FLOAT, 0, 12, offsetof(mavlink_setpoint_8dof_t, val4) }, \ + { "val5", NULL, MAVLINK_TYPE_FLOAT, 0, 16, offsetof(mavlink_setpoint_8dof_t, val5) }, \ + { "val6", NULL, MAVLINK_TYPE_FLOAT, 0, 20, offsetof(mavlink_setpoint_8dof_t, val6) }, \ + { "val7", NULL, MAVLINK_TYPE_FLOAT, 0, 24, offsetof(mavlink_setpoint_8dof_t, val7) }, \ + { "val8", NULL, MAVLINK_TYPE_FLOAT, 0, 28, offsetof(mavlink_setpoint_8dof_t, val8) }, \ + { "target_system", NULL, MAVLINK_TYPE_UINT8_T, 0, 32, offsetof(mavlink_setpoint_8dof_t, target_system) }, \ + } \ +} + + +/** + * @brief Pack a setpoint_8dof message + * @param system_id ID of this system + * @param component_id ID of this component (e.g. 200 for IMU) + * @param msg The MAVLink message to compress the data into + * + * @param target_system System ID + * @param val1 Value 1 + * @param val2 Value 2 + * @param val3 Value 3 + * @param val4 Value 4 + * @param val5 Value 5 + * @param val6 Value 6 + * @param val7 Value 7 + * @param val8 Value 8 + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_setpoint_8dof_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, + uint8_t target_system, float val1, float val2, float val3, float val4, float val5, float val6, float val7, float val8) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[33]; + _mav_put_float(buf, 0, val1); + _mav_put_float(buf, 4, val2); + _mav_put_float(buf, 8, val3); + _mav_put_float(buf, 12, val4); + _mav_put_float(buf, 16, val5); + _mav_put_float(buf, 20, val6); + _mav_put_float(buf, 24, val7); + _mav_put_float(buf, 28, val8); + _mav_put_uint8_t(buf, 32, target_system); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 33); +#else + mavlink_setpoint_8dof_t packet; + packet.val1 = val1; + packet.val2 = val2; + packet.val3 = val3; + packet.val4 = val4; + packet.val5 = val5; + packet.val6 = val6; + packet.val7 = val7; + packet.val8 = val8; + packet.target_system = target_system; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 33); +#endif + + msg->msgid = MAVLINK_MSG_ID_SETPOINT_8DOF; + return mavlink_finalize_message(msg, system_id, component_id, 33, 241); +} + +/** + * @brief Pack a setpoint_8dof message on a channel + * @param system_id ID of this system + * @param component_id ID of this component (e.g. 200 for IMU) + * @param chan The MAVLink channel this message was sent over + * @param msg The MAVLink message to compress the data into + * @param target_system System ID + * @param val1 Value 1 + * @param val2 Value 2 + * @param val3 Value 3 + * @param val4 Value 4 + * @param val5 Value 5 + * @param val6 Value 6 + * @param val7 Value 7 + * @param val8 Value 8 + * @return length of the message in bytes (excluding serial stream start sign) + */ +static inline uint16_t mavlink_msg_setpoint_8dof_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, + mavlink_message_t* msg, + uint8_t target_system,float val1,float val2,float val3,float val4,float val5,float val6,float val7,float val8) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[33]; + _mav_put_float(buf, 0, val1); + _mav_put_float(buf, 4, val2); + _mav_put_float(buf, 8, val3); + _mav_put_float(buf, 12, val4); + _mav_put_float(buf, 16, val5); + _mav_put_float(buf, 20, val6); + _mav_put_float(buf, 24, val7); + _mav_put_float(buf, 28, val8); + _mav_put_uint8_t(buf, 32, target_system); + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 33); +#else + mavlink_setpoint_8dof_t packet; + packet.val1 = val1; + packet.val2 = val2; + packet.val3 = val3; + packet.val4 = val4; + packet.val5 = val5; + packet.val6 = val6; + packet.val7 = val7; + packet.val8 = val8; + packet.target_system = target_system; + + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 33); +#endif + + msg->msgid = MAVLINK_MSG_ID_SETPOINT_8DOF; + return mavlink_finalize_message_chan(msg, system_id, component_id, chan, 33, 241); +} + +/** + * @brief Encode a setpoint_8dof struct into a message + * + * @param system_id ID of this system + * @param component_id ID of this component (e.g. 200 for IMU) + * @param msg The MAVLink message to compress the data into + * @param setpoint_8dof C-struct to read the message contents from + */ +static inline uint16_t mavlink_msg_setpoint_8dof_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_setpoint_8dof_t* setpoint_8dof) +{ + return mavlink_msg_setpoint_8dof_pack(system_id, component_id, msg, setpoint_8dof->target_system, setpoint_8dof->val1, setpoint_8dof->val2, setpoint_8dof->val3, setpoint_8dof->val4, setpoint_8dof->val5, setpoint_8dof->val6, setpoint_8dof->val7, setpoint_8dof->val8); +} + +/** + * @brief Send a setpoint_8dof message + * @param chan MAVLink channel to send the message + * + * @param target_system System ID + * @param val1 Value 1 + * @param val2 Value 2 + * @param val3 Value 3 + * @param val4 Value 4 + * @param val5 Value 5 + * @param val6 Value 6 + * @param val7 Value 7 + * @param val8 Value 8 + */ +#ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS + +static inline void mavlink_msg_setpoint_8dof_send(mavlink_channel_t chan, uint8_t target_system, float val1, float val2, float val3, float val4, float val5, float val6, float val7, float val8) +{ +#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS + char buf[33]; + _mav_put_float(buf, 0, val1); + _mav_put_float(buf, 4, val2); + _mav_put_float(buf, 8, val3); + _mav_put_float(buf, 12, val4); + _mav_put_float(buf, 16, val5); + _mav_put_float(buf, 20, val6); + _mav_put_float(buf, 24, val7); + _mav_put_float(buf, 28, val8); + _mav_put_uint8_t(buf, 32, target_system); + + _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_SETPOINT_8DOF, buf, 33, 241); +#else + mavlink_setpoint_8dof_t packet; + packet.val1 = val1; + packet.val2 = val2; + packet.val3 = val3; + packet.val4 = val4; + packet.val5 = val5; + packet.val6 = val6; + packet.val7 = val7; + packet.val8 = val8; + packet.target_system = target_system; + + _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_SETPOINT_8DOF, (const char *)&packet, 33, 241); +#endif +} + +#endif + +// MESSAGE SETPOINT_8DOF UNPACKING + + +/** + * @brief Get field target_system from setpoint_8dof message + * + * @return System ID + */ +static inline uint8_t mavlink_msg_setpoint_8dof_get_target_system(const mavlink_message_t* msg) +{ + return _MAV_RETURN_uint8_t(msg, 32); +} + +/** + * @brief Get field val1 from setpoint_8dof message + * + * @return Value 1 + */ +static inline float mavlink_msg_setpoint_8dof_get_val1(const mavlink_message_t* msg) +{ + return _MAV_RETURN_float(msg, 0); +} + +/** + * @brief Get field val2 from setpoint_8dof message + * + * @return Value 2 + */ +static inline float mavlink_msg_setpoint_8dof_get_val2(const mavlink_message_t* msg) +{ + return _MAV_RETURN_float(msg, 4); +} + +/** + * @brief Get field val3 from setpoint_8dof message + * + * @return Value 3 + */ +static inline float mavlink_msg_setpoint_8dof_get_val3(const mavlink_message_t* msg) +{ + return _MAV_RETURN_float(msg, 8); +} + +/** + * @brief Get field val4 from setpoint_8dof message + * + * @return Value 4 + */ +static inline float mavlink_msg_setpoint_8dof_get_val4(const mavlink_message_t* msg) +{ + return _MAV_RETURN_float(msg, 12); +} + +/** + * @brief Get field val5 from setpoint_8dof message + * + * @return Value 5 + */ +static inline float mavlink_msg_setpoint_8dof_get_val5(const mavlink_message_t* msg) +{ + return _MAV_RETURN_float(msg, 16); +} + +/** + * @brief Get field val6 from setpoint_8dof message + * + * @return Value 6 + */ +static inline float mavlink_msg_setpoint_8dof_get_val6(const mavlink_message_t* msg) +{ + return _MAV_RETURN_float(msg, 20); +} + +/** + * @brief Get field val7 from setpoint_8dof message + * + * @return Value 7 + */ +static inline float mavlink_msg_setpoint_8dof_get_val7(const mavlink_message_t* msg) +{ + return _MAV_RETURN_float(msg, 24); +} + +/** + * @brief Get field val8 from setpoint_8dof message + * + * @return Value 8 + */ +static inline float mavlink_msg_setpoint_8dof_get_val8(const mavlink_message_t* msg) +{ + return _MAV_RETURN_float(msg, 28); +} + +/** + * @brief Decode a setpoint_8dof message into a struct + * + * @param msg The message to decode + * @param setpoint_8dof C-struct to decode the message contents into + */ +static inline void mavlink_msg_setpoint_8dof_decode(const mavlink_message_t* msg, mavlink_setpoint_8dof_t* setpoint_8dof) +{ +#if MAVLINK_NEED_BYTE_SWAP + setpoint_8dof->val1 = mavlink_msg_setpoint_8dof_get_val1(msg); + setpoint_8dof->val2 = mavlink_msg_setpoint_8dof_get_val2(msg); + setpoint_8dof->val3 = mavlink_msg_setpoint_8dof_get_val3(msg); + setpoint_8dof->val4 = mavlink_msg_setpoint_8dof_get_val4(msg); + setpoint_8dof->val5 = mavlink_msg_setpoint_8dof_get_val5(msg); + setpoint_8dof->val6 = mavlink_msg_setpoint_8dof_get_val6(msg); + setpoint_8dof->val7 = mavlink_msg_setpoint_8dof_get_val7(msg); + setpoint_8dof->val8 = mavlink_msg_setpoint_8dof_get_val8(msg); + setpoint_8dof->target_system = mavlink_msg_setpoint_8dof_get_target_system(msg); +#else + memcpy(setpoint_8dof, _MAV_PAYLOAD(msg), 33); +#endif +} diff --git a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_state_correction.h b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_state_correction.h index 7dea690d2..0f4f1f5e2 100644 --- a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_state_correction.h +++ b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_state_correction.h @@ -68,7 +68,7 @@ static inline uint16_t mavlink_msg_state_correction_pack(uint8_t system_id, uint _mav_put_float(buf, 28, vyErr); _mav_put_float(buf, 32, vzErr); - memcpy(_MAV_PAYLOAD(msg), buf, 36); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 36); #else mavlink_state_correction_t packet; packet.xErr = xErr; @@ -81,7 +81,7 @@ static inline uint16_t mavlink_msg_state_correction_pack(uint8_t system_id, uint packet.vyErr = vyErr; packet.vzErr = vzErr; - memcpy(_MAV_PAYLOAD(msg), &packet, 36); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 36); #endif msg->msgid = MAVLINK_MSG_ID_STATE_CORRECTION; @@ -121,7 +121,7 @@ static inline uint16_t mavlink_msg_state_correction_pack_chan(uint8_t system_id, _mav_put_float(buf, 28, vyErr); _mav_put_float(buf, 32, vzErr); - memcpy(_MAV_PAYLOAD(msg), buf, 36); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 36); #else mavlink_state_correction_t packet; packet.xErr = xErr; @@ -134,7 +134,7 @@ static inline uint16_t mavlink_msg_state_correction_pack_chan(uint8_t system_id, packet.vyErr = vyErr; packet.vzErr = vzErr; - memcpy(_MAV_PAYLOAD(msg), &packet, 36); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 36); #endif msg->msgid = MAVLINK_MSG_ID_STATE_CORRECTION; diff --git a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_statustext.h b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_statustext.h index 1e1d38d2c..7c65d448f 100644 --- a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_statustext.h +++ b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_statustext.h @@ -4,7 +4,7 @@ typedef struct __mavlink_statustext_t { - uint8_t severity; ///< Severity of status, 0 = info message, 255 = critical fault + uint8_t severity; ///< Severity of status. Relies on the definitions within RFC-5424. See enum MAV_SEVERITY. char text[50]; ///< Status text message, without null termination character } mavlink_statustext_t; @@ -28,7 +28,7 @@ typedef struct __mavlink_statustext_t * @param component_id ID of this component (e.g. 200 for IMU) * @param msg The MAVLink message to compress the data into * - * @param severity Severity of status, 0 = info message, 255 = critical fault + * @param severity Severity of status. Relies on the definitions within RFC-5424. See enum MAV_SEVERITY. * @param text Status text message, without null termination character * @return length of the message in bytes (excluding serial stream start sign) */ @@ -39,12 +39,12 @@ static inline uint16_t mavlink_msg_statustext_pack(uint8_t system_id, uint8_t co char buf[51]; _mav_put_uint8_t(buf, 0, severity); _mav_put_char_array(buf, 1, text, 50); - memcpy(_MAV_PAYLOAD(msg), buf, 51); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 51); #else mavlink_statustext_t packet; packet.severity = severity; mav_array_memcpy(packet.text, text, sizeof(char)*50); - memcpy(_MAV_PAYLOAD(msg), &packet, 51); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 51); #endif msg->msgid = MAVLINK_MSG_ID_STATUSTEXT; @@ -57,7 +57,7 @@ static inline uint16_t mavlink_msg_statustext_pack(uint8_t system_id, uint8_t co * @param component_id ID of this component (e.g. 200 for IMU) * @param chan The MAVLink channel this message was sent over * @param msg The MAVLink message to compress the data into - * @param severity Severity of status, 0 = info message, 255 = critical fault + * @param severity Severity of status. Relies on the definitions within RFC-5424. See enum MAV_SEVERITY. * @param text Status text message, without null termination character * @return length of the message in bytes (excluding serial stream start sign) */ @@ -69,12 +69,12 @@ static inline uint16_t mavlink_msg_statustext_pack_chan(uint8_t system_id, uint8 char buf[51]; _mav_put_uint8_t(buf, 0, severity); _mav_put_char_array(buf, 1, text, 50); - memcpy(_MAV_PAYLOAD(msg), buf, 51); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 51); #else mavlink_statustext_t packet; packet.severity = severity; mav_array_memcpy(packet.text, text, sizeof(char)*50); - memcpy(_MAV_PAYLOAD(msg), &packet, 51); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 51); #endif msg->msgid = MAVLINK_MSG_ID_STATUSTEXT; @@ -98,7 +98,7 @@ static inline uint16_t mavlink_msg_statustext_encode(uint8_t system_id, uint8_t * @brief Send a statustext message * @param chan MAVLink channel to send the message * - * @param severity Severity of status, 0 = info message, 255 = critical fault + * @param severity Severity of status. Relies on the definitions within RFC-5424. See enum MAV_SEVERITY. * @param text Status text message, without null termination character */ #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS @@ -126,7 +126,7 @@ static inline void mavlink_msg_statustext_send(mavlink_channel_t chan, uint8_t s /** * @brief Get field severity from statustext message * - * @return Severity of status, 0 = info message, 255 = critical fault + * @return Severity of status. Relies on the definitions within RFC-5424. See enum MAV_SEVERITY. */ static inline uint8_t mavlink_msg_statustext_get_severity(const mavlink_message_t* msg) { diff --git a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_sys_status.h b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_sys_status.h index adada471d..ef09a652f 100644 --- a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_sys_status.h +++ b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_sys_status.h @@ -84,7 +84,7 @@ static inline uint16_t mavlink_msg_sys_status_pack(uint8_t system_id, uint8_t co _mav_put_uint16_t(buf, 28, errors_count4); _mav_put_int8_t(buf, 30, battery_remaining); - memcpy(_MAV_PAYLOAD(msg), buf, 31); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 31); #else mavlink_sys_status_t packet; packet.onboard_control_sensors_present = onboard_control_sensors_present; @@ -101,7 +101,7 @@ static inline uint16_t mavlink_msg_sys_status_pack(uint8_t system_id, uint8_t co packet.errors_count4 = errors_count4; packet.battery_remaining = battery_remaining; - memcpy(_MAV_PAYLOAD(msg), &packet, 31); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 31); #endif msg->msgid = MAVLINK_MSG_ID_SYS_STATUS; @@ -149,7 +149,7 @@ static inline uint16_t mavlink_msg_sys_status_pack_chan(uint8_t system_id, uint8 _mav_put_uint16_t(buf, 28, errors_count4); _mav_put_int8_t(buf, 30, battery_remaining); - memcpy(_MAV_PAYLOAD(msg), buf, 31); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 31); #else mavlink_sys_status_t packet; packet.onboard_control_sensors_present = onboard_control_sensors_present; @@ -166,7 +166,7 @@ static inline uint16_t mavlink_msg_sys_status_pack_chan(uint8_t system_id, uint8 packet.errors_count4 = errors_count4; packet.battery_remaining = battery_remaining; - memcpy(_MAV_PAYLOAD(msg), &packet, 31); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 31); #endif msg->msgid = MAVLINK_MSG_ID_SYS_STATUS; diff --git a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_system_time.h b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_system_time.h index a46db49c3..c24808d1a 100644 --- a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_system_time.h +++ b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_system_time.h @@ -40,13 +40,13 @@ static inline uint16_t mavlink_msg_system_time_pack(uint8_t system_id, uint8_t c _mav_put_uint64_t(buf, 0, time_unix_usec); _mav_put_uint32_t(buf, 8, time_boot_ms); - memcpy(_MAV_PAYLOAD(msg), buf, 12); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 12); #else mavlink_system_time_t packet; packet.time_unix_usec = time_unix_usec; packet.time_boot_ms = time_boot_ms; - memcpy(_MAV_PAYLOAD(msg), &packet, 12); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 12); #endif msg->msgid = MAVLINK_MSG_ID_SYSTEM_TIME; @@ -72,13 +72,13 @@ static inline uint16_t mavlink_msg_system_time_pack_chan(uint8_t system_id, uint _mav_put_uint64_t(buf, 0, time_unix_usec); _mav_put_uint32_t(buf, 8, time_boot_ms); - memcpy(_MAV_PAYLOAD(msg), buf, 12); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 12); #else mavlink_system_time_t packet; packet.time_unix_usec = time_unix_usec; packet.time_boot_ms = time_boot_ms; - memcpy(_MAV_PAYLOAD(msg), &packet, 12); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 12); #endif msg->msgid = MAVLINK_MSG_ID_SYSTEM_TIME; diff --git a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_vfr_hud.h b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_vfr_hud.h index 3e4c09acd..d7c1afe41 100644 --- a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_vfr_hud.h +++ b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_vfr_hud.h @@ -56,7 +56,7 @@ static inline uint16_t mavlink_msg_vfr_hud_pack(uint8_t system_id, uint8_t compo _mav_put_int16_t(buf, 16, heading); _mav_put_uint16_t(buf, 18, throttle); - memcpy(_MAV_PAYLOAD(msg), buf, 20); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 20); #else mavlink_vfr_hud_t packet; packet.airspeed = airspeed; @@ -66,7 +66,7 @@ static inline uint16_t mavlink_msg_vfr_hud_pack(uint8_t system_id, uint8_t compo packet.heading = heading; packet.throttle = throttle; - memcpy(_MAV_PAYLOAD(msg), &packet, 20); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 20); #endif msg->msgid = MAVLINK_MSG_ID_VFR_HUD; @@ -100,7 +100,7 @@ static inline uint16_t mavlink_msg_vfr_hud_pack_chan(uint8_t system_id, uint8_t _mav_put_int16_t(buf, 16, heading); _mav_put_uint16_t(buf, 18, throttle); - memcpy(_MAV_PAYLOAD(msg), buf, 20); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 20); #else mavlink_vfr_hud_t packet; packet.airspeed = airspeed; @@ -110,7 +110,7 @@ static inline uint16_t mavlink_msg_vfr_hud_pack_chan(uint8_t system_id, uint8_t packet.heading = heading; packet.throttle = throttle; - memcpy(_MAV_PAYLOAD(msg), &packet, 20); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 20); #endif msg->msgid = MAVLINK_MSG_ID_VFR_HUD; diff --git a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_vicon_position_estimate.h b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_vicon_position_estimate.h index 93db6edef..93ad097f9 100644 --- a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_vicon_position_estimate.h +++ b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_vicon_position_estimate.h @@ -4,7 +4,7 @@ typedef struct __mavlink_vicon_position_estimate_t { - uint64_t usec; ///< Timestamp (milliseconds) + uint64_t usec; ///< Timestamp (microseconds, synced to UNIX time or since system boot) float x; ///< Global X position float y; ///< Global Y position float z; ///< Global Z position @@ -38,7 +38,7 @@ typedef struct __mavlink_vicon_position_estimate_t * @param component_id ID of this component (e.g. 200 for IMU) * @param msg The MAVLink message to compress the data into * - * @param usec Timestamp (milliseconds) + * @param usec Timestamp (microseconds, synced to UNIX time or since system boot) * @param x Global X position * @param y Global Y position * @param z Global Z position @@ -60,7 +60,7 @@ static inline uint16_t mavlink_msg_vicon_position_estimate_pack(uint8_t system_i _mav_put_float(buf, 24, pitch); _mav_put_float(buf, 28, yaw); - memcpy(_MAV_PAYLOAD(msg), buf, 32); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 32); #else mavlink_vicon_position_estimate_t packet; packet.usec = usec; @@ -71,7 +71,7 @@ static inline uint16_t mavlink_msg_vicon_position_estimate_pack(uint8_t system_i packet.pitch = pitch; packet.yaw = yaw; - memcpy(_MAV_PAYLOAD(msg), &packet, 32); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 32); #endif msg->msgid = MAVLINK_MSG_ID_VICON_POSITION_ESTIMATE; @@ -84,7 +84,7 @@ static inline uint16_t mavlink_msg_vicon_position_estimate_pack(uint8_t system_i * @param component_id ID of this component (e.g. 200 for IMU) * @param chan The MAVLink channel this message was sent over * @param msg The MAVLink message to compress the data into - * @param usec Timestamp (milliseconds) + * @param usec Timestamp (microseconds, synced to UNIX time or since system boot) * @param x Global X position * @param y Global Y position * @param z Global Z position @@ -107,7 +107,7 @@ static inline uint16_t mavlink_msg_vicon_position_estimate_pack_chan(uint8_t sys _mav_put_float(buf, 24, pitch); _mav_put_float(buf, 28, yaw); - memcpy(_MAV_PAYLOAD(msg), buf, 32); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 32); #else mavlink_vicon_position_estimate_t packet; packet.usec = usec; @@ -118,7 +118,7 @@ static inline uint16_t mavlink_msg_vicon_position_estimate_pack_chan(uint8_t sys packet.pitch = pitch; packet.yaw = yaw; - memcpy(_MAV_PAYLOAD(msg), &packet, 32); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 32); #endif msg->msgid = MAVLINK_MSG_ID_VICON_POSITION_ESTIMATE; @@ -142,7 +142,7 @@ static inline uint16_t mavlink_msg_vicon_position_estimate_encode(uint8_t system * @brief Send a vicon_position_estimate message * @param chan MAVLink channel to send the message * - * @param usec Timestamp (milliseconds) + * @param usec Timestamp (microseconds, synced to UNIX time or since system boot) * @param x Global X position * @param y Global Y position * @param z Global Z position @@ -187,7 +187,7 @@ static inline void mavlink_msg_vicon_position_estimate_send(mavlink_channel_t ch /** * @brief Get field usec from vicon_position_estimate message * - * @return Timestamp (milliseconds) + * @return Timestamp (microseconds, synced to UNIX time or since system boot) */ static inline uint64_t mavlink_msg_vicon_position_estimate_get_usec(const mavlink_message_t* msg) { diff --git a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_vision_position_estimate.h b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_vision_position_estimate.h index c99fc99ab..ca567c119 100644 --- a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_vision_position_estimate.h +++ b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_vision_position_estimate.h @@ -4,7 +4,7 @@ typedef struct __mavlink_vision_position_estimate_t { - uint64_t usec; ///< Timestamp (milliseconds) + uint64_t usec; ///< Timestamp (microseconds, synced to UNIX time or since system boot) float x; ///< Global X position float y; ///< Global Y position float z; ///< Global Z position @@ -38,7 +38,7 @@ typedef struct __mavlink_vision_position_estimate_t * @param component_id ID of this component (e.g. 200 for IMU) * @param msg The MAVLink message to compress the data into * - * @param usec Timestamp (milliseconds) + * @param usec Timestamp (microseconds, synced to UNIX time or since system boot) * @param x Global X position * @param y Global Y position * @param z Global Z position @@ -60,7 +60,7 @@ static inline uint16_t mavlink_msg_vision_position_estimate_pack(uint8_t system_ _mav_put_float(buf, 24, pitch); _mav_put_float(buf, 28, yaw); - memcpy(_MAV_PAYLOAD(msg), buf, 32); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 32); #else mavlink_vision_position_estimate_t packet; packet.usec = usec; @@ -71,7 +71,7 @@ static inline uint16_t mavlink_msg_vision_position_estimate_pack(uint8_t system_ packet.pitch = pitch; packet.yaw = yaw; - memcpy(_MAV_PAYLOAD(msg), &packet, 32); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 32); #endif msg->msgid = MAVLINK_MSG_ID_VISION_POSITION_ESTIMATE; @@ -84,7 +84,7 @@ static inline uint16_t mavlink_msg_vision_position_estimate_pack(uint8_t system_ * @param component_id ID of this component (e.g. 200 for IMU) * @param chan The MAVLink channel this message was sent over * @param msg The MAVLink message to compress the data into - * @param usec Timestamp (milliseconds) + * @param usec Timestamp (microseconds, synced to UNIX time or since system boot) * @param x Global X position * @param y Global Y position * @param z Global Z position @@ -107,7 +107,7 @@ static inline uint16_t mavlink_msg_vision_position_estimate_pack_chan(uint8_t sy _mav_put_float(buf, 24, pitch); _mav_put_float(buf, 28, yaw); - memcpy(_MAV_PAYLOAD(msg), buf, 32); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 32); #else mavlink_vision_position_estimate_t packet; packet.usec = usec; @@ -118,7 +118,7 @@ static inline uint16_t mavlink_msg_vision_position_estimate_pack_chan(uint8_t sy packet.pitch = pitch; packet.yaw = yaw; - memcpy(_MAV_PAYLOAD(msg), &packet, 32); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 32); #endif msg->msgid = MAVLINK_MSG_ID_VISION_POSITION_ESTIMATE; @@ -142,7 +142,7 @@ static inline uint16_t mavlink_msg_vision_position_estimate_encode(uint8_t syste * @brief Send a vision_position_estimate message * @param chan MAVLink channel to send the message * - * @param usec Timestamp (milliseconds) + * @param usec Timestamp (microseconds, synced to UNIX time or since system boot) * @param x Global X position * @param y Global Y position * @param z Global Z position @@ -187,7 +187,7 @@ static inline void mavlink_msg_vision_position_estimate_send(mavlink_channel_t c /** * @brief Get field usec from vision_position_estimate message * - * @return Timestamp (milliseconds) + * @return Timestamp (microseconds, synced to UNIX time or since system boot) */ static inline uint64_t mavlink_msg_vision_position_estimate_get_usec(const mavlink_message_t* msg) { diff --git a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_vision_speed_estimate.h b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_vision_speed_estimate.h index 71d250c38..10ec1026c 100644 --- a/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_vision_speed_estimate.h +++ b/src/GCS_MAVLink/include_v1.0/common/mavlink_msg_vision_speed_estimate.h @@ -4,7 +4,7 @@ typedef struct __mavlink_vision_speed_estimate_t { - uint64_t usec; ///< Timestamp (milliseconds) + uint64_t usec; ///< Timestamp (microseconds, synced to UNIX time or since system boot) float x; ///< Global X speed float y; ///< Global Y speed float z; ///< Global Z speed @@ -32,7 +32,7 @@ typedef struct __mavlink_vision_speed_estimate_t * @param component_id ID of this component (e.g. 200 for IMU) * @param msg The MAVLink message to compress the data into * - * @param usec Timestamp (milliseconds) + * @param usec Timestamp (microseconds, synced to UNIX time or since system boot) * @param x Global X speed * @param y Global Y speed * @param z Global Z speed @@ -48,7 +48,7 @@ static inline uint16_t mavlink_msg_vision_speed_estimate_pack(uint8_t system_id, _mav_put_float(buf, 12, y); _mav_put_float(buf, 16, z); - memcpy(_MAV_PAYLOAD(msg), buf, 20); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 20); #else mavlink_vision_speed_estimate_t packet; packet.usec = usec; @@ -56,7 +56,7 @@ static inline uint16_t mavlink_msg_vision_speed_estimate_pack(uint8_t system_id, packet.y = y; packet.z = z; - memcpy(_MAV_PAYLOAD(msg), &packet, 20); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 20); #endif msg->msgid = MAVLINK_MSG_ID_VISION_SPEED_ESTIMATE; @@ -69,7 +69,7 @@ static inline uint16_t mavlink_msg_vision_speed_estimate_pack(uint8_t system_id, * @param component_id ID of this component (e.g. 200 for IMU) * @param chan The MAVLink channel this message was sent over * @param msg The MAVLink message to compress the data into - * @param usec Timestamp (milliseconds) + * @param usec Timestamp (microseconds, synced to UNIX time or since system boot) * @param x Global X speed * @param y Global Y speed * @param z Global Z speed @@ -86,7 +86,7 @@ static inline uint16_t mavlink_msg_vision_speed_estimate_pack_chan(uint8_t syste _mav_put_float(buf, 12, y); _mav_put_float(buf, 16, z); - memcpy(_MAV_PAYLOAD(msg), buf, 20); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 20); #else mavlink_vision_speed_estimate_t packet; packet.usec = usec; @@ -94,7 +94,7 @@ static inline uint16_t mavlink_msg_vision_speed_estimate_pack_chan(uint8_t syste packet.y = y; packet.z = z; - memcpy(_MAV_PAYLOAD(msg), &packet, 20); + memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 20); #endif msg->msgid = MAVLINK_MSG_ID_VISION_SPEED_ESTIMATE; @@ -118,7 +118,7 @@ static inline uint16_t mavlink_msg_vision_speed_estimate_encode(uint8_t system_i * @brief Send a vision_speed_estimate message * @param chan MAVLink channel to send the message * - * @param usec Timestamp (milliseconds) + * @param usec Timestamp (microseconds, synced to UNIX time or since system boot) * @param x Global X speed * @param y Global Y speed * @param z Global Z speed @@ -154,7 +154,7 @@ static inline void mavlink_msg_vision_speed_estimate_send(mavlink_channel_t chan /** * @brief Get field usec from vision_speed_estimate message * - * @return Timestamp (milliseconds) + * @return Timestamp (microseconds, synced to UNIX time or since system boot) */ static inline uint64_t mavlink_msg_vision_speed_estimate_get_usec(const mavlink_message_t* msg) { diff --git a/src/GCS_MAVLink/include_v1.0/common/testsuite.h b/src/GCS_MAVLink/include_v1.0/common/testsuite.h index a5089f599..0da36c7d8 100644 --- a/src/GCS_MAVLink/include_v1.0/common/testsuite.h +++ b/src/GCS_MAVLink/include_v1.0/common/testsuite.h @@ -2526,6 +2526,110 @@ static void mavlink_test_roll_pitch_yaw_speed_thrust_setpoint(uint8_t system_id, MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0); } +static void mavlink_test_set_quad_motors_setpoint(uint8_t system_id, uint8_t component_id, mavlink_message_t *last_msg) +{ + mavlink_message_t msg; + uint8_t buffer[MAVLINK_MAX_PACKET_LEN]; + uint16_t i; + mavlink_set_quad_motors_setpoint_t packet_in = { + 17235, + 17339, + 17443, + 17547, + 29, + }; + mavlink_set_quad_motors_setpoint_t packet1, packet2; + memset(&packet1, 0, sizeof(packet1)); + packet1.motor_front_nw = packet_in.motor_front_nw; + packet1.motor_right_ne = packet_in.motor_right_ne; + packet1.motor_back_se = packet_in.motor_back_se; + packet1.motor_left_sw = packet_in.motor_left_sw; + packet1.target_system = packet_in.target_system; + + + + memset(&packet2, 0, sizeof(packet2)); + mavlink_msg_set_quad_motors_setpoint_encode(system_id, component_id, &msg, &packet1); + mavlink_msg_set_quad_motors_setpoint_decode(&msg, &packet2); + MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0); + + memset(&packet2, 0, sizeof(packet2)); + mavlink_msg_set_quad_motors_setpoint_pack(system_id, component_id, &msg , packet1.target_system , packet1.motor_front_nw , packet1.motor_right_ne , packet1.motor_back_se , packet1.motor_left_sw ); + mavlink_msg_set_quad_motors_setpoint_decode(&msg, &packet2); + MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0); + + memset(&packet2, 0, sizeof(packet2)); + mavlink_msg_set_quad_motors_setpoint_pack_chan(system_id, component_id, MAVLINK_COMM_0, &msg , packet1.target_system , packet1.motor_front_nw , packet1.motor_right_ne , packet1.motor_back_se , packet1.motor_left_sw ); + mavlink_msg_set_quad_motors_setpoint_decode(&msg, &packet2); + MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0); + + memset(&packet2, 0, sizeof(packet2)); + mavlink_msg_to_send_buffer(buffer, &msg); + for (i=0; iparse_state = MAVLINK_PARSE_STATE_IDLE; +} /** * @brief Finalize a MAVLink message with channel assignment @@ -113,6 +144,24 @@ MAVLINK_HELPER void _mav_finalize_message_chan_send(mavlink_channel_t chan, uint _mavlink_send_uart(chan, (const char *)ck, 2); MAVLINK_END_UART_SEND(chan, MAVLINK_NUM_NON_PAYLOAD_BYTES + (uint16_t)length); } + +/** + * @brief re-send a message over a uart channel + * this is more stack efficient than re-marshalling the message + */ +MAVLINK_HELPER void _mavlink_resend_uart(mavlink_channel_t chan, const mavlink_message_t *msg) +{ + uint8_t ck[2]; + + ck[0] = (uint8_t)(msg->checksum & 0xFF); + ck[1] = (uint8_t)(msg->checksum >> 8); + + MAVLINK_START_UART_SEND(chan, MAVLINK_NUM_NON_PAYLOAD_BYTES + msg->len); + _mavlink_send_uart(chan, (const char *)&msg->magic, MAVLINK_NUM_HEADER_BYTES); + _mavlink_send_uart(chan, _MAV_PAYLOAD(msg), msg->len); + _mavlink_send_uart(chan, (const char *)ck, 2); + MAVLINK_END_UART_SEND(chan, MAVLINK_NUM_NON_PAYLOAD_BYTES + msg->len); +} #endif // MAVLINK_USE_CONVENIENCE_FUNCTIONS /** @@ -120,7 +169,7 @@ MAVLINK_HELPER void _mav_finalize_message_chan_send(mavlink_channel_t chan, uint */ MAVLINK_HELPER uint16_t mavlink_msg_to_send_buffer(uint8_t *buffer, const mavlink_message_t *msg) { - memcpy(buffer, (uint8_t *)&msg->magic, MAVLINK_NUM_NON_PAYLOAD_BYTES + (uint16_t)msg->len); + memcpy(buffer, (const uint8_t *)&msg->magic, MAVLINK_NUM_NON_PAYLOAD_BYTES + (uint16_t)msg->len); return MAVLINK_NUM_NON_PAYLOAD_BYTES + (uint16_t)msg->len; } @@ -182,8 +231,6 @@ MAVLINK_HELPER void mavlink_update_checksum(mavlink_message_t* msg, uint8_t c) */ MAVLINK_HELPER uint8_t mavlink_parse_char(uint8_t chan, uint8_t c, mavlink_message_t* r_message, mavlink_status_t* r_mavlink_status) { - static mavlink_message_t m_mavlink_message[MAVLINK_COMM_NUM_BUFFERS]; - /* default message crc function. You can override this per-system to put this data in a different memory segment @@ -195,7 +242,20 @@ MAVLINK_HELPER uint8_t mavlink_parse_char(uint8_t chan, uint8_t c, mavlink_messa #endif #endif - mavlink_message_t* rxmsg = &m_mavlink_message[chan]; ///< The currently decoded message +/* Enable this option to check the length of each message. + This allows invalid messages to be caught much sooner. Use if the transmission + medium is prone to missing (or extra) characters (e.g. a radio that fades in + and out). Only use if the channel will only contain messages types listed in + the headers. +*/ +#if MAVLINK_CHECK_MESSAGE_LENGTH +#ifndef MAVLINK_MESSAGE_LENGTH + static const uint8_t mavlink_message_lengths[256] = MAVLINK_MESSAGE_LENGTHS; +#define MAVLINK_MESSAGE_LENGTH(msgid) mavlink_message_lengths[msgid] +#endif +#endif + + mavlink_message_t* rxmsg = mavlink_get_channel_buffer(chan); ///< The currently decoded message mavlink_status_t* status = mavlink_get_channel_status(chan); ///< The current decode status int bufferIndex = 0; @@ -209,6 +269,7 @@ MAVLINK_HELPER uint8_t mavlink_parse_char(uint8_t chan, uint8_t c, mavlink_messa { status->parse_state = MAVLINK_PARSE_STATE_GOT_STX; rxmsg->len = 0; + rxmsg->magic = c; mavlink_start_checksum(rxmsg); } break; @@ -256,6 +317,19 @@ MAVLINK_HELPER uint8_t mavlink_parse_char(uint8_t chan, uint8_t c, mavlink_messa break; case MAVLINK_PARSE_STATE_GOT_COMPID: +#if MAVLINK_CHECK_MESSAGE_LENGTH + if (rxmsg->len != MAVLINK_MESSAGE_LENGTH(c)) + { + status->parse_error++; + status->parse_state = MAVLINK_PARSE_STATE_IDLE; + break; + if (c == MAVLINK_STX) + { + status->parse_state = MAVLINK_PARSE_STATE_GOT_STX; + mavlink_start_checksum(rxmsg); + } + } +#endif rxmsg->msgid = c; mavlink_update_checksum(rxmsg, c); if (rxmsg->len == 0) @@ -269,7 +343,7 @@ MAVLINK_HELPER uint8_t mavlink_parse_char(uint8_t chan, uint8_t c, mavlink_messa break; case MAVLINK_PARSE_STATE_GOT_MSGID: - _MAV_PAYLOAD(rxmsg)[status->packet_idx++] = (char)c; + _MAV_PAYLOAD_NON_CONST(rxmsg)[status->packet_idx++] = (char)c; mavlink_update_checksum(rxmsg, c); if (status->packet_idx == rxmsg->len) { @@ -296,6 +370,7 @@ MAVLINK_HELPER uint8_t mavlink_parse_char(uint8_t chan, uint8_t c, mavlink_messa else { status->parse_state = MAVLINK_PARSE_STATE_GOT_CRC1; + _MAV_PAYLOAD_NON_CONST(rxmsg)[status->packet_idx] = (char)c; } break; @@ -317,6 +392,7 @@ MAVLINK_HELPER uint8_t mavlink_parse_char(uint8_t chan, uint8_t c, mavlink_messa // Successfully got message status->msg_received = 1; status->parse_state = MAVLINK_PARSE_STATE_IDLE; + _MAV_PAYLOAD_NON_CONST(rxmsg)[status->packet_idx+1] = (char)c; memcpy(r_message, rxmsg, sizeof(mavlink_message_t)); } break; diff --git a/src/GCS_MAVLink/include_v1.0/mavlink_protobuf_manager.hpp b/src/GCS_MAVLink/include_v1.0/mavlink_protobuf_manager.hpp new file mode 100644 index 000000000..fd3ddd026 --- /dev/null +++ b/src/GCS_MAVLink/include_v1.0/mavlink_protobuf_manager.hpp @@ -0,0 +1,377 @@ +#ifndef MAVLINKPROTOBUFMANAGER_HPP +#define MAVLINKPROTOBUFMANAGER_HPP + +#include +#include +#include +#include + +#include +#include +#include +#include + +namespace mavlink +{ + +class ProtobufManager +{ +public: + ProtobufManager() + : mRegisteredTypeCount(0) + , mStreamID(0) + , mVerbose(false) + , kExtendedHeaderSize(MAVLINK_EXTENDED_HEADER_LEN) + , kExtendedPayloadMaxSize(MAVLINK_MAX_EXTENDED_PAYLOAD_LEN) + { + // register GLOverlay + { + std::tr1::shared_ptr msg(new px::GLOverlay); + registerType(msg); + } + + // register ObstacleList + { + std::tr1::shared_ptr msg(new px::ObstacleList); + registerType(msg); + } + + // register ObstacleMap + { + std::tr1::shared_ptr msg(new px::ObstacleMap); + registerType(msg); + } + + // register Path + { + std::tr1::shared_ptr msg(new px::Path); + registerType(msg); + } + + // register PointCloudXYZI + { + std::tr1::shared_ptr msg(new px::PointCloudXYZI); + registerType(msg); + } + + // register PointCloudXYZRGB + { + std::tr1::shared_ptr msg(new px::PointCloudXYZRGB); + registerType(msg); + } + + // register RGBDImage + { + std::tr1::shared_ptr msg(new px::RGBDImage); + registerType(msg); + } + + srand(time(NULL)); + mStreamID = rand() + 1; + } + + bool fragmentMessage(uint8_t system_id, uint8_t component_id, + uint8_t target_system, uint8_t target_component, + const google::protobuf::Message& protobuf_msg, + std::vector& fragments) const + { + TypeMap::const_iterator it = mTypeMap.find(protobuf_msg.GetTypeName()); + if (it == mTypeMap.end()) + { + std::cout << "# WARNING: Protobuf message with type " + << protobuf_msg.GetTypeName() << " is not registered." + << std::endl; + return false; + } + + uint8_t typecode = it->second; + + std::string data = protobuf_msg.SerializeAsString(); + + int fragmentCount = (protobuf_msg.ByteSize() + kExtendedPayloadMaxSize - 1) / kExtendedPayloadMaxSize; + unsigned int offset = 0; + + for (int i = 0; i < fragmentCount; ++i) + { + mavlink_extended_message_t fragment; + + // write extended header data + uint8_t* payload = reinterpret_cast(fragment.base_msg.payload64); + unsigned int length = 0; + uint8_t flags = 0; + + if (i < fragmentCount - 1) + { + length = kExtendedPayloadMaxSize; + flags |= 0x1; + } + else + { + length = protobuf_msg.ByteSize() - kExtendedPayloadMaxSize * (fragmentCount - 1); + } + + memcpy(payload, &target_system, 1); + memcpy(payload + 1, &target_component, 1); + memcpy(payload + 2, &typecode, 1); + memcpy(payload + 3, &length, 4); + memcpy(payload + 7, &mStreamID, 2); + memcpy(payload + 9, &offset, 4); + memcpy(payload + 13, &flags, 1); + + fragment.base_msg.msgid = MAVLINK_MSG_ID_EXTENDED_MESSAGE; + mavlink_finalize_message(&fragment.base_msg, system_id, component_id, kExtendedHeaderSize, 0); + + // write extended payload data + fragment.extended_payload_len = length; + memcpy(fragment.extended_payload, &data[offset], length); + + fragments.push_back(fragment); + offset += length; + } + + if (mVerbose) + { + std::cerr << "# INFO: Split extended message with size " + << protobuf_msg.ByteSize() << " into " + << fragmentCount << " fragments." << std::endl; + } + + return true; + } + + bool cacheFragment(mavlink_extended_message_t& msg) + { + if (!validFragment(msg)) + { + if (mVerbose) + { + std::cerr << "# WARNING: Message is not a valid fragment. " + << "Dropping message..." << std::endl; + } + return false; + } + + // read extended header + uint8_t* payload = reinterpret_cast(msg.base_msg.payload64); + uint8_t typecode = 0; + unsigned int length = 0; + unsigned short streamID = 0; + unsigned int offset = 0; + uint8_t flags = 0; + + memcpy(&typecode, payload + 2, 1); + memcpy(&length, payload + 3, 4); + memcpy(&streamID, payload + 7, 2); + memcpy(&offset, payload + 9, 4); + memcpy(&flags, payload + 13, 1); + + if (typecode >= mTypeMap.size()) + { + std::cout << "# WARNING: Protobuf message with type code " + << static_cast(typecode) << " is not registered." << std::endl; + return false; + } + + bool reassemble = false; + + FragmentQueue::iterator it = mFragmentQueue.find(streamID); + if (it == mFragmentQueue.end()) + { + if (offset == 0) + { + mFragmentQueue[streamID].push_back(msg); + + if ((flags & 0x1) != 0x1) + { + reassemble = true; + } + + if (mVerbose) + { + std::cerr << "# INFO: Added fragment to new queue." + << std::endl; + } + } + else + { + if (mVerbose) + { + std::cerr << "# WARNING: Message is not a valid fragment. " + << "Dropping message..." << std::endl; + } + } + } + else + { + std::deque& queue = it->second; + + if (queue.empty()) + { + if (offset == 0) + { + queue.push_back(msg); + + if ((flags & 0x1) != 0x1) + { + reassemble = true; + } + } + else + { + if (mVerbose) + { + std::cerr << "# WARNING: Message is not a valid fragment. " + << "Dropping message..." << std::endl; + } + } + } + else + { + if (fragmentDataSize(queue.back()) + fragmentOffset(queue.back()) != offset) + { + if (mVerbose) + { + std::cerr << "# WARNING: Previous fragment(s) have been lost. " + << "Dropping message and clearing queue..." << std::endl; + } + queue.clear(); + } + else + { + queue.push_back(msg); + + if ((flags & 0x1) != 0x1) + { + reassemble = true; + } + } + } + } + + if (reassemble) + { + std::deque& queue = mFragmentQueue[streamID]; + + std::string data; + for (size_t i = 0; i < queue.size(); ++i) + { + mavlink_extended_message_t& mavlink_msg = queue.at(i); + + data.append(reinterpret_cast(&mavlink_msg.extended_payload[0]), + static_cast(mavlink_msg.extended_payload_len)); + } + + mMessages.at(typecode)->ParseFromString(data); + + mMessageAvailable.at(typecode) = true; + + queue.clear(); + + if (mVerbose) + { + std::cerr << "# INFO: Reassembled fragments for message with typename " + << mMessages.at(typecode)->GetTypeName() << " and size " + << mMessages.at(typecode)->ByteSize() + << "." << std::endl; + } + } + + return true; + } + + bool getMessage(std::tr1::shared_ptr& msg) + { + for (size_t i = 0; i < mMessageAvailable.size(); ++i) + { + if (mMessageAvailable.at(i)) + { + msg = mMessages.at(i); + mMessageAvailable.at(i) = false; + + return true; + } + } + + return false; + } + +private: + void registerType(const std::tr1::shared_ptr& msg) + { + mTypeMap[msg->GetTypeName()] = mRegisteredTypeCount; + ++mRegisteredTypeCount; + mMessages.push_back(msg); + mMessageAvailable.push_back(false); + } + + bool validFragment(const mavlink_extended_message_t& msg) const + { + if (msg.base_msg.magic != MAVLINK_STX || + msg.base_msg.len != kExtendedHeaderSize || + msg.base_msg.msgid != MAVLINK_MSG_ID_EXTENDED_MESSAGE) + { + return false; + } + + uint16_t checksum; + checksum = crc_calculate(reinterpret_cast(&msg.base_msg.len), MAVLINK_CORE_HEADER_LEN); + crc_accumulate_buffer(&checksum, reinterpret_cast(&msg.base_msg.payload64), kExtendedHeaderSize); +#if MAVLINK_CRC_EXTRA + static const uint8_t mavlink_message_crcs[256] = MAVLINK_MESSAGE_CRCS; + crc_accumulate(mavlink_message_crcs[msg.base_msg.msgid], &checksum); +#endif + + if (mavlink_ck_a(&(msg.base_msg)) != (uint8_t)(checksum & 0xFF) && + mavlink_ck_b(&(msg.base_msg)) != (uint8_t)(checksum >> 8)) + { + return false; + } + + return true; + } + + unsigned int fragmentDataSize(const mavlink_extended_message_t& msg) const + { + const uint8_t* payload = reinterpret_cast(msg.base_msg.payload64); + + return *(reinterpret_cast(payload + 3)); + } + + unsigned int fragmentOffset(const mavlink_extended_message_t& msg) const + { + const uint8_t* payload = reinterpret_cast(msg.base_msg.payload64); + + return *(reinterpret_cast(payload + 9)); + } + + int mRegisteredTypeCount; + unsigned short mStreamID; + bool mVerbose; + + typedef std::map TypeMap; + TypeMap mTypeMap; + std::vector< std::tr1::shared_ptr > mMessages; + std::vector mMessageAvailable; + + typedef std::map > FragmentQueue; + FragmentQueue mFragmentQueue; + + const int kExtendedHeaderSize; + /** + * Extended header structure + * ========================= + * byte 0 - target_system + * byte 1 - target_component + * byte 2 - extended message id (type code) + * bytes 3-6 - extended payload size in bytes + * byte 7-8 - stream ID + * byte 9-12 - fragment offset + * byte 13 - fragment flags (bit 0 - 1=more fragments, 0=last fragment) + */ + + const int kExtendedPayloadMaxSize; +}; + +} + +#endif diff --git a/src/GCS_MAVLink/include_v1.0/mavlink_types.h b/src/GCS_MAVLink/include_v1.0/mavlink_types.h index 03faf594f..5fbde97f7 100644 --- a/src/GCS_MAVLink/include_v1.0/mavlink_types.h +++ b/src/GCS_MAVLink/include_v1.0/mavlink_types.h @@ -3,54 +3,6 @@ #include -enum MAV_ACTION -{ - MAV_ACTION_HOLD = 0, - MAV_ACTION_MOTORS_START = 1, - MAV_ACTION_LAUNCH = 2, - MAV_ACTION_RETURN = 3, - MAV_ACTION_EMCY_LAND = 4, - MAV_ACTION_EMCY_KILL = 5, - MAV_ACTION_CONFIRM_KILL = 6, - MAV_ACTION_CONTINUE = 7, - MAV_ACTION_MOTORS_STOP = 8, - MAV_ACTION_HALT = 9, - MAV_ACTION_SHUTDOWN = 10, - MAV_ACTION_REBOOT = 11, - MAV_ACTION_SET_MANUAL = 12, - MAV_ACTION_SET_AUTO = 13, - MAV_ACTION_STORAGE_READ = 14, - MAV_ACTION_STORAGE_WRITE = 15, - MAV_ACTION_CALIBRATE_RC = 16, - MAV_ACTION_CALIBRATE_GYRO = 17, - MAV_ACTION_CALIBRATE_MAG = 18, - MAV_ACTION_CALIBRATE_ACC = 19, - MAV_ACTION_CALIBRATE_PRESSURE = 20, - MAV_ACTION_REC_START = 21, - MAV_ACTION_REC_PAUSE = 22, - MAV_ACTION_REC_STOP = 23, - MAV_ACTION_TAKEOFF = 24, - MAV_ACTION_NAVIGATE = 25, - MAV_ACTION_LAND = 26, - MAV_ACTION_LOITER = 27, - MAV_ACTION_SET_ORIGIN = 28, - MAV_ACTION_RELAY_ON = 29, - MAV_ACTION_RELAY_OFF = 30, - MAV_ACTION_GET_IMAGE = 31, - MAV_ACTION_VIDEO_START = 32, - MAV_ACTION_VIDEO_STOP = 33, - MAV_ACTION_RESET_MAP = 34, - MAV_ACTION_RESET_PLAN = 35, - MAV_ACTION_DELAY_BEFORE_COMMAND = 36, - MAV_ACTION_ASCEND_AT_RATE = 37, - MAV_ACTION_CHANGE_MODE = 38, - MAV_ACTION_LOITER_MAX_TURNS = 39, - MAV_ACTION_LOITER_MAX_TIME = 40, - MAV_ACTION_START_HILSIM = 41, - MAV_ACTION_STOP_HILSIM = 42, - MAV_ACTION_NB ///< Number of MAV actions -}; - #ifndef MAVLINK_MAX_PAYLOAD_LEN // it is possible to override this, but be careful! #define MAVLINK_MAX_PAYLOAD_LEN 255 ///< Maximum payload length @@ -63,11 +15,26 @@ enum MAV_ACTION #define MAVLINK_MAX_PACKET_LEN (MAVLINK_MAX_PAYLOAD_LEN + MAVLINK_NUM_NON_PAYLOAD_BYTES) ///< Maximum packet length +#define MAVLINK_MSG_ID_EXTENDED_MESSAGE 255 +#define MAVLINK_EXTENDED_HEADER_LEN 14 + +#if (defined _MSC_VER) | ((defined __APPLE__) & (defined __MACH__)) | (defined __linux__) + /* full fledged 32bit++ OS */ + #define MAVLINK_MAX_EXTENDED_PACKET_LEN 65507 +#else + /* small microcontrollers */ + #define MAVLINK_MAX_EXTENDED_PACKET_LEN 2048 +#endif + +#define MAVLINK_MAX_EXTENDED_PAYLOAD_LEN (MAVLINK_MAX_EXTENDED_PACKET_LEN - MAVLINK_EXTENDED_HEADER_LEN - MAVLINK_NUM_NON_PAYLOAD_BYTES) + typedef struct param_union { union { float param_float; int32_t param_int32; uint32_t param_uint32; + uint8_t param_uint8; + uint8_t bytes[4]; }; uint8_t type; } mavlink_param_union_t; @@ -92,6 +59,14 @@ typedef struct __mavlink_message { uint64_t payload64[(MAVLINK_MAX_PAYLOAD_LEN+MAVLINK_NUM_CHECKSUM_BYTES+7)/8]; } mavlink_message_t; + +typedef struct __mavlink_extended_message { + mavlink_message_t base_msg; + int32_t extended_payload_len; ///< Length of extended payload if any + uint8_t extended_payload[MAVLINK_MAX_EXTENDED_PAYLOAD_LEN]; +} mavlink_extended_message_t; + + typedef enum { MAVLINK_TYPE_CHAR = 0, MAVLINK_TYPE_UINT8_T = 1, @@ -109,12 +84,12 @@ typedef enum { #define MAVLINK_MAX_FIELDS 64 typedef struct __mavlink_field_info { - const char *name; // name of this field - const char *print_format; // printing format hint, or NULL - mavlink_message_type_t type; // type of this field - unsigned array_length; // if non-zero, field is an array - unsigned wire_offset; // offset of each field in the payload - unsigned structure_offset; // offset in a C structure + const char *name; // name of this field + const char *print_format; // printing format hint, or NULL + mavlink_message_type_t type; // type of this field + unsigned int array_length; // if non-zero, field is an array + unsigned int wire_offset; // offset of each field in the payload + unsigned int structure_offset; // offset in a C structure } mavlink_field_info_t; // note that in this structure the order of fields is the order @@ -125,11 +100,12 @@ typedef struct __mavlink_message_info { mavlink_field_info_t fields[MAVLINK_MAX_FIELDS]; // field information } mavlink_message_info_t; -#define _MAV_PAYLOAD(msg) ((char *)(&(msg)->payload64[0])) +#define _MAV_PAYLOAD(msg) ((const char *)(&((msg)->payload64[0]))) +#define _MAV_PAYLOAD_NON_CONST(msg) ((char *)(&((msg)->payload64[0]))) // checksum is immediately after the payload bytes -#define mavlink_ck_a(msg) *(msg->len + (uint8_t *)_MAV_PAYLOAD(msg)) -#define mavlink_ck_b(msg) *((msg->len+(uint16_t)1) + (uint8_t *)_MAV_PAYLOAD(msg)) +#define mavlink_ck_a(msg) *((msg)->len + (uint8_t *)_MAV_PAYLOAD_NON_CONST(msg)) +#define mavlink_ck_b(msg) *(((msg)->len+(uint16_t)1) + (uint8_t *)_MAV_PAYLOAD_NON_CONST(msg)) typedef enum { MAVLINK_COMM_0, diff --git a/src/GCS_MAVLink/include_v1.0/protocol.h b/src/GCS_MAVLink/include_v1.0/protocol.h index 05195c369..64dc22229 100644 --- a/src/GCS_MAVLink/include_v1.0/protocol.h +++ b/src/GCS_MAVLink/include_v1.0/protocol.h @@ -42,7 +42,10 @@ #endif // MAVLINK_SEPARATE_HELPERS /* always include the prototypes to ensure we don't get out of sync */ +#ifndef MAVLINK_GET_CHANNEL_STATUS MAVLINK_HELPER mavlink_status_t* mavlink_get_channel_status(uint8_t chan); +#endif +MAVLINK_HELPER void mavlink_reset_channel_status(uint8_t chan); #if MAVLINK_CRC_EXTRA MAVLINK_HELPER uint16_t mavlink_finalize_message_chan(mavlink_message_t* msg, uint8_t system_id, uint8_t component_id, uint8_t chan, uint8_t length, uint8_t crc_extra); @@ -67,6 +70,7 @@ MAVLINK_HELPER uint8_t put_bitfield_n_by_index(int32_t b, uint8_t bits, uint8_t uint8_t* r_bit_index, uint8_t* buffer); #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS MAVLINK_HELPER void _mavlink_send_uart(mavlink_channel_t chan, const char *buf, uint16_t len); +MAVLINK_HELPER void _mavlink_resend_uart(mavlink_channel_t chan, const mavlink_message_t *msg); #endif /** @@ -155,7 +159,7 @@ static inline void byte_copy_8(char *dst, const char *src) /* like memcpy(), but if src is NULL, do a memset to zero - */ +*/ static void mav_array_memcpy(void *dest, const void *src, size_t n) { if (src == NULL) { @@ -171,6 +175,7 @@ static void mav_array_memcpy(void *dest, const void *src, size_t n) static inline void _mav_put_char_array(char *buf, uint8_t wire_offset, const char *b, uint8_t array_length) { mav_array_memcpy(&buf[wire_offset], b, array_length); + } /* @@ -179,6 +184,7 @@ static inline void _mav_put_char_array(char *buf, uint8_t wire_offset, const cha static inline void _mav_put_uint8_t_array(char *buf, uint8_t wire_offset, const uint8_t *b, uint8_t array_length) { mav_array_memcpy(&buf[wire_offset], b, array_length); + } /* @@ -187,6 +193,7 @@ static inline void _mav_put_uint8_t_array(char *buf, uint8_t wire_offset, const static inline void _mav_put_int8_t_array(char *buf, uint8_t wire_offset, const int8_t *b, uint8_t array_length) { mav_array_memcpy(&buf[wire_offset], b, array_length); + } #if MAVLINK_NEED_BYTE_SWAP @@ -206,7 +213,7 @@ static inline void _mav_put_ ## TYPE ##_array(char *buf, uint8_t wire_offset, co #define _MAV_PUT_ARRAY(TYPE, V) \ static inline void _mav_put_ ## TYPE ##_array(char *buf, uint8_t wire_offset, const TYPE *b, uint8_t array_length) \ { \ - mav_array_memcpy(&buf[wire_offset], b, array_length*sizeof(TYPE)); \ + mav_array_memcpy(&buf[wire_offset], b, array_length*sizeof(TYPE)); \ } #endif @@ -219,9 +226,9 @@ _MAV_PUT_ARRAY(int64_t, i64) _MAV_PUT_ARRAY(float, f) _MAV_PUT_ARRAY(double, d) -#define _MAV_RETURN_char(msg, wire_offset) _MAV_PAYLOAD(msg)[wire_offset] -#define _MAV_RETURN_int8_t(msg, wire_offset) (int8_t)_MAV_PAYLOAD(msg)[wire_offset] -#define _MAV_RETURN_uint8_t(msg, wire_offset) (uint8_t)_MAV_PAYLOAD(msg)[wire_offset] +#define _MAV_RETURN_char(msg, wire_offset) (const char)_MAV_PAYLOAD(msg)[wire_offset] +#define _MAV_RETURN_int8_t(msg, wire_offset) (const int8_t)_MAV_PAYLOAD(msg)[wire_offset] +#define _MAV_RETURN_uint8_t(msg, wire_offset) (const uint8_t)_MAV_PAYLOAD(msg)[wire_offset] #if MAVLINK_NEED_BYTE_SWAP #define _MAV_MSG_RETURN_TYPE(TYPE, SIZE) \ diff --git a/src/GCS_MAVLink/message_definitions_v1.0/ardupilotmega.xml b/src/GCS_MAVLink/message_definitions_v1.0/ardupilotmega.xml index 3a71c6c7c..965383fef 100644 --- a/src/GCS_MAVLink/message_definitions_v1.0/ardupilotmega.xml +++ b/src/GCS_MAVLink/message_definitions_v1.0/ardupilotmega.xml @@ -9,7 +9,6 @@ is general enough to move into common.xml later --> - @@ -77,6 +76,9 @@ Switched to guided mode to return point (fence point 0) + + Report fence breach, but don't take action + @@ -93,6 +95,23 @@ Breached fence boundary + + + + pre-initialization + disabled + checking limits + a limit has been breached + taking action eg. RTL + we're no longer in breach of a limit + + + + + pre-initialization + disabled + checking limits + @@ -164,7 +183,7 @@ 0: unlock focus or keep unlocked, 1: lock focus or keep locked, 3: re-lock focus 0: ignore, 1: shot or start filming Command Identity (incremental loop: 0 to 255)//A command sent multiple times will be executed or pooled just once - Extra parameters enumeration (0 means ignore) + Extra parameters enumeration (0 means ignore) Correspondent value to given extra_param @@ -202,7 +221,7 @@ A fence point. Used to set a point when from GCS -> MAV. Also used to return a point from MAV -> GCS - System ID + System ID Component ID point index (first point is 1, 0 is for return point) total number of points (for sanity checking) @@ -212,7 +231,7 @@ Request a current fence point from MAV - System ID + System ID Component ID point index (first point is 1, 0 is for return point) @@ -225,5 +244,106 @@ last breach type (see FENCE_BREACH_* enum) time of last breach in milliseconds since boot + + + Status of DCM attitude estimator + X gyro drift estimate rad/s + Y gyro drift estimate rad/s + Z gyro drift estimate rad/s + average accel_weight + average renormalisation value + average error_roll_pitch value + average error_yaw value + + + + Status of simulation environment, if used + Roll angle (rad) + Pitch angle (rad) + Yaw angle (rad) + X acceleration m/s/s + Y acceleration m/s/s + Z acceleration m/s/s + Angular speed around X axis rad/s + Angular speed around Y axis rad/s + Angular speed around Z axis rad/s + Latitude in degrees + Longitude in degrees + + + + Status of key hardware + board voltage (mV) + I2C error count + + + + Status generated by radio + local signal strength + remote signal strength + how full the tx buffer is as a percentage + background noise level + remote background noise level + receive errors + count of error corrected packets + + + + + + Status of AP_Limits. Sent in extended + status stream when AP_Limits is enabled + state of AP_Limits, (see enum LimitState, LIMITS_STATE) + time of last breach in milliseconds since boot + time of last recovery action in milliseconds since boot + time of last successful recovery in milliseconds since boot + time of last all-clear in milliseconds since boot + number of fence breaches + AP_Limit_Module bitfield of enabled modules, (see enum moduleid or LIMIT_MODULE) + AP_Limit_Module bitfield of required modules, (see enum moduleid or LIMIT_MODULE) + AP_Limit_Module bitfield of triggered modules, (see enum moduleid or LIMIT_MODULE) + + + + Wind estimation + wind direction that wind is coming from (degrees) + wind speed in ground plane (m/s) + vertical wind speed (m/s) + + + + Data packet, size 16 + data type + data length + raw data + + + + Data packet, size 32 + data type + data length + raw data + + + + Data packet, size 64 + data type + data length + raw data + + + + Data packet, size 96 + data type + data length + raw data + + + + Rangefinder reporting + distance in meters + raw voltage if available, zero otherwise + + diff --git a/src/GCS_MAVLink/message_definitions_v1.0/common.xml b/src/GCS_MAVLink/message_definitions_v1.0/common.xml index 8af1eaa41..e1f5dd40a 100644 --- a/src/GCS_MAVLink/message_definitions_v1.0/common.xml +++ b/src/GCS_MAVLink/message_definitions_v1.0/common.xml @@ -40,62 +40,123 @@ FlexiPilot + + PX4 Autopilot - http://pixhawk.ethz.ch/px4/ + + + SMACCMPilot - http://smaccmpilot.org + + + + + Generic micro air vehicle. + + + Fixed wing aircraft. + + + Quadrotor + + + Coaxial helicopter + + + Normal helicopter with tail rotor. + + + Ground installation + + + Operator control unit / ground control station + + + Airship, controlled + + + Free balloon, uncontrolled + + + Rocket + + + Ground rover + + + Surface vessel, boat, ship + + + Submarine + + + Hexarotor + + + Octorotor + + + Octorotor + + + Flapping wing + + + Flapping wing + - These flags encode the MAV mode. - - 0b10000000 MAV safety set to armed. Motors are enabled / running / can start. Ready to fly. - + These flags encode the MAV mode. + + 0b10000000 MAV safety set to armed. Motors are enabled / running / can start. Ready to fly. + - 0b01000000 remote control input is enabled. - - - 0b00100000 hardware in the loop simulation. All motors / actuators are blocked, but internal software is full operational. - + 0b01000000 remote control input is enabled. + + + 0b00100000 hardware in the loop simulation. All motors / actuators are blocked, but internal software is full operational. + - 0b00010000 system stabilizes electronically its attitude (and optionally position). It needs however further control inputs to move around. - + 0b00010000 system stabilizes electronically its attitude (and optionally position). It needs however further control inputs to move around. + - 0b00001000 guided mode enabled, system flies MISSIONs / mission items. - + 0b00001000 guided mode enabled, system flies MISSIONs / mission items. + - 0b00000100 autonomous mode enabled, system finds its own goal positions. Guided flag can be set or not, depends on the actual implementation. - + 0b00000100 autonomous mode enabled, system finds its own goal positions. Guided flag can be set or not, depends on the actual implementation. + - 0b00000010 system has a test mode enabled. This flag is intended for temporary system tests and should not be used for stable implementations. - + 0b00000010 system has a test mode enabled. This flag is intended for temporary system tests and should not be used for stable implementations. + - 0b00000001 Reserved for future use. - + 0b00000001 Reserved for future use. + - - These values encode the bit positions of the decode position. These values can be used to read the value of a flag bit by combining the base_mode variable with AND with the flag position value. The result will be either 0 or 1, depending on if the flag is set or not. + These values encode the bit positions of the decode position. These values can be used to read the value of a flag bit by combining the base_mode variable with AND with the flag position value. The result will be either 0 or 1, depending on if the flag is set or not. - First bit: 10000000 - + First bit: 10000000 + - Second bit: 01000000 - - - Third bit: 00100000 - + Second bit: 01000000 + + + Third bit: 00100000 + - Fourth bit: 00010000 - + Fourth bit: 00010000 + - Fifth bit: 00001000 - + Fifth bit: 00001000 + - Sixt bit: 00000100 - + Sixt bit: 00000100 + - Seventh bit: 00000010 - + Seventh bit: 00000010 + - Eighth bit: 00000001 - + Eighth bit: 00000001 + Override command, pauses current mission execution and moves immediately to a position @@ -175,59 +236,6 @@ System just initialized its power-down sequence, will shut down now. - - - Generic micro air vehicle. - - - Fixed wing aircraft. - - - Quadrotor - - - Coaxial helicopter - - - Normal helicopter with tail rotor. - - - Ground installation - - - Operator control unit / ground control station - - - Airship, controlled - - - Free balloon, uncontrolled - - - Rocket - - - Ground rover - - - Surface vessel, boat, ship - - - Submarine - - - Hexarotor - - - Octorotor - - - Octorotor - - - Flapping wing - - @@ -346,11 +354,7 @@ - Commands to be executed by the MAV. They can be executed on user request, - or as part of a mission script. If the action is used in a mission, the parameter mapping - to the waypoint/mission message is as follows: - Param 1, Param 2, Param 3, Param 4, X: Param 5, Y:Param 6, Z:Param 7. This command list is similar what - ARINC 424 is for commercial aircraft: A data format how to interpret waypoint/mission data. + Commands to be executed by the MAV. They can be executed on user request, or as part of a mission script. If the action is used in a mission, the parameter mapping to the waypoint/mission message is as follows: Param 1, Param 2, Param 3, Param 4, X: Param 5, Y:Param 6, Z:Param 7. This command list is similar what ARINC 424 is for commercial aircraft: A data format how to interpret waypoint/mission data. Navigate to MISSION. Hold time in decimal seconds. (ignored by fixed wing, time to stay at MISSION for rotary wing) @@ -422,10 +426,7 @@ Altitude - Sets the region of interest (ROI) for a sensor set or the - vehicle itself. This can then be used by the vehicles control - system to control the vehicle attitude and the attitude of various - sensors such as cameras. + Sets the region of interest (ROI) for a sensor set or the vehicle itself. This can then be used by the vehicles control system to control the vehicle attitude and the attitude of various sensors such as cameras. Region of intereset mode. (see MAV_ROI enum) MISSION index/ target ID. (see MAV_ROI enum) ROI index (allows a vehicle to manage multiple ROI's) @@ -620,7 +621,7 @@ Magnetometer calibration: 0: no, 1: yes Ground pressure: 0: no, 1: yes Radio calibration: 0: no, 1: yes - Empty + Accelerometer calibration: 0: no, 1: yes Empty Empty @@ -669,12 +670,15 @@ first_item: the first mission item to run last_item: the last mission item to run (after this item is run, the mission ends) + + Arms / Disarms a component + 1 to arm, 0 to disarm + Data stream IDs. A data stream is not a fixed set of messages, but rather a recommendation to the autopilot software. Individual autopilots may or may not obey - the recommended messages. - + the recommended messages. Enable all data streams @@ -706,8 +710,7 @@ The ROI (region of interest) for the vehicle. This can be be used by the vehicle for camera/vehicle attitude alignment (see - MAV_CMD_NAV_ROI). - + MAV_CMD_NAV_ROI). No region of interest. @@ -754,32 +757,39 @@ The Z or altitude value is out of range. - - - type of a mavlink parameter - - 32 bit float + + Specifies the datatype of a MAVLink parameter. + + 8-bit unsigned integer - - 8 bit unsigned integer + + 8-bit signed integer - - 8 bit signed integer + + 16-bit unsigned integer - - 16 bit unsigned integer + + 16-bit signed integer - - 16 bit signed integer + + 32-bit unsigned integer - - 32 bit unsigned integer + + 32-bit signed integer - - 32 bit signed integer + + 64-bit unsigned integer - - + + 64-bit signed integer + + + 32-bit floating-point + + + 64-bit floating-point + + result from a mavlink command @@ -797,8 +807,7 @@ Command executed, but failed - - + result in a mavlink mission ack @@ -846,18 +855,44 @@ not accepting any mission commands from this communication partner - - + + + Indicates the severity level, generally used for status messages to indicate their relative urgency. Based on RFC-5424 using expanded definitions at: http://www.kiwisyslog.com/kb/info:-syslog-message-levels/. + + System is unusable. This is a "panic" condition. + + + Action should be taken immediately. Indicates error in non-critical systems. + + + Action must be taken immediately. Indicates failure in a primary system. + + + Indicates an error in secondary/redundant systems. + + + Indicates about a possible future error if this is not resolved within a given timeframe. Example would be a low battery warning. + + + An unusual event has occured, though not an error condition. This should be investigated for the root cause. + + + Normal operational messages. Useful for logging. No action is required for these messages. + + + Useful non-operational messages that can assist in debugging. These should not occur during normal operation. + + 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). Type of the MAV (quadrotor, helicopter, etc., up to 15 types, defined in MAV_TYPE ENUM) - Autopilot type / class. defined in MAV_CLASS ENUM + Autopilot type / class. defined in MAV_AUTOPILOT ENUM System mode bitfield, see MAV_MODE_FLAGS ENUM in mavlink/include/mavlink_types.h - Navigation mode bitfield, see MAV_AUTOPILOT_CUSTOM_MODE ENUM for some examples. This field is autopilot-specific. - System status flag, see MAV_STATUS ENUM - MAVLink version + A bitfield for use for autopilot-specific flags. + System status flag, see MAV_STATE ENUM + MAVLink version, not writable by user, gets added by protocol because of magic data type: uint8_t_mavlink_version The general system state. If the system is following the MAVLink standard, the system state is mainly defined by three orthogonal states/modes: The system mode, which is either LOCKED (motors shut down and locked), MANUAL (system under RC control), GUIDED (system with autonomous position control, position setpoint controlled manually) or AUTO (system guided by path/waypoint planner). The NAV_MODE defined the current flight state: LIFTOFF (often an open-loop maneuver), LANDING, WAYPOINTS or VECTOR. This represents the internal navigation state machine. The system status shows wether the system is currently active or not and if an emergency occured. During the CRITICAL and EMERGENCY states the MAV is still considered to be active, but should start emergency procedures autonomously. After a failure occured it should first move from active to critical to allow manual intervention and then move to emergency after a certain timeout. @@ -875,7 +910,6 @@ Autopilot-specific errors Autopilot-specific errors - The system time is the time of the master clock, typically the computer clock of the main onboard computer. Timestamp of the master clock in microseconds since UNIX epoch. @@ -916,8 +950,8 @@ Request to read the onboard parameter with the param_id string id. Onboard parameters are stored as key[const char*] -> value[float]. This allows to send a parameter to any other component (such as the GCS) without the need of previous knowledge of possible parameter names. Thus the same GCS can store different parameters for different autopilots. See also http://qgroundcontrol.org/parameter_interface for a full documentation of QGroundControl and IMU code. System ID Component ID - Onboard parameter id - Parameter index. Send -1 to use the param ID field as identifier + Onboard parameter id, terminated by NULL if the length is less than 16 human-readable chars and WITHOUT null termination (NULL) byte if the length is exactly 16 chars - applications have to provide 16+1 bytes storage if the ID is stored as string + Parameter index. Send -1 to use the param ID field as identifier (else the param id will be ignored) Request all parameters of this component. After his request, all parameters are emitted. @@ -926,9 +960,9 @@ Emit the value of a onboard parameter. The inclusion of param_count and param_index in the message allows the recipient to keep track of received parameters and allows him to re-request missing parameters after a loss or timeout. - Onboard parameter id + Onboard parameter id, terminated by NULL if the length is less than 16 human-readable chars and WITHOUT null termination (NULL) byte if the length is exactly 16 chars - applications have to provide 16+1 bytes storage if the ID is stored as string Onboard parameter value - Onboard parameter type: see MAV_VAR enum + Onboard parameter type: see the MAV_PARAM_TYPE enum for supported data types. Total number of onboard parameters Index of this onboard parameter @@ -936,14 +970,13 @@ Set a parameter value TEMPORARILY to RAM. It will be reset to default on system reboot. Send the ACTION MAV_ACTION_STORAGE_WRITE to PERMANENTLY write the RAM contents to EEPROM. IMPORTANT: The receiving component should acknowledge the new parameter value by sending a param_value message to all communication partners. This will also ensure that multiple GCS all have an up-to-date list of all parameters. If the sending GCS did not receive a PARAM_VALUE message within its timeout time, it should re-send the PARAM_SET message. System ID Component ID - Onboard parameter id + Onboard parameter id, terminated by NULL if the length is less than 16 human-readable chars and WITHOUT null termination (NULL) byte if the length is exactly 16 chars - applications have to provide 16+1 bytes storage if the ID is stored as string Onboard parameter value - Onboard parameter type: see MAV_VAR enum + Onboard parameter type: see the MAV_PARAM_TYPE enum for supported data types. The global position, as returned by the Global Positioning System (GPS). This is - NOT the global position estimate of the sytem, but rather a RAW sensor value. See message GLOBAL_POSITION for the global position estimate. Coordinate frame is right-handed, Z-axis up (GPS frame) - + NOT the global position estimate of the sytem, but rather a RAW sensor value. See message GLOBAL_POSITION for the global position estimate. Coordinate frame is right-handed, Z-axis up (GPS frame). Timestamp (microseconds since UNIX epoch or microseconds since system boot) 0-1: no fix, 2: 2D fix, 3: 3D fix. Some applications will not use the value of this field unless it is at least two, so always correctly fill in the fix. Latitude in 1E7 degrees @@ -1000,7 +1033,7 @@ The pressure readings for the typical setup of one absolute and differential pressure sensor. The units are as specified in each field. - Timestamp (microseconds since UNIX epoch or microseconds since system boot) + Timestamp (milliseconds since system boot) Absolute pressure (hectopascal) Differential pressure 1 (hectopascal) Temperature measurement (0.01 degrees celsius) @@ -1008,9 +1041,9 @@ The attitude in the aeronautical frame (right-handed, Z-down, X-front, Y-right). Timestamp (milliseconds since system boot) - Roll angle (rad) - Pitch angle (rad) - Yaw angle (rad) + Roll angle (rad, -pi..+pi) + Pitch angle (rad, -pi..+pi) + Yaw angle (rad, -pi..+pi) Roll angular speed (rad/s) Pitch angular speed (rad/s) Yaw angular speed (rad/s) @@ -1050,36 +1083,36 @@ Compass heading in degrees * 100, 0.0..359.99 degrees. If unknown, set to: 65535 - The scaled values of the RC channels received. (-100%) -10000, (0%) 0, (100%) 10000 + The scaled values of the RC channels received. (-100%) -10000, (0%) 0, (100%) 10000. Channels that are inactive should be set to 65535. Timestamp (milliseconds since system boot) - Servo output port (set of 8 outputs = 1 port). Most MAVs will just use one, but this allows to encode more than 8 servos. - RC channel 1 value scaled, (-100%) -10000, (0%) 0, (100%) 10000 - RC channel 2 value scaled, (-100%) -10000, (0%) 0, (100%) 10000 - RC channel 3 value scaled, (-100%) -10000, (0%) 0, (100%) 10000 - RC channel 4 value scaled, (-100%) -10000, (0%) 0, (100%) 10000 - RC channel 5 value scaled, (-100%) -10000, (0%) 0, (100%) 10000 - RC channel 6 value scaled, (-100%) -10000, (0%) 0, (100%) 10000 - RC channel 7 value scaled, (-100%) -10000, (0%) 0, (100%) 10000 - RC channel 8 value scaled, (-100%) -10000, (0%) 0, (100%) 10000 - Receive signal strength indicator, 0: 0%, 255: 100% + Servo output port (set of 8 outputs = 1 port). Most MAVs will just use one, but this allows for more than 8 servos. + RC channel 1 value scaled, (-100%) -10000, (0%) 0, (100%) 10000, (invalid) 32767. + RC channel 2 value scaled, (-100%) -10000, (0%) 0, (100%) 10000, (invalid) 32767. + RC channel 3 value scaled, (-100%) -10000, (0%) 0, (100%) 10000, (invalid) 32767. + RC channel 4 value scaled, (-100%) -10000, (0%) 0, (100%) 10000, (invalid) 32767. + RC channel 5 value scaled, (-100%) -10000, (0%) 0, (100%) 10000, (invalid) 32767. + RC channel 6 value scaled, (-100%) -10000, (0%) 0, (100%) 10000, (invalid) 32767. + RC channel 7 value scaled, (-100%) -10000, (0%) 0, (100%) 10000, (invalid) 32767. + RC channel 8 value scaled, (-100%) -10000, (0%) 0, (100%) 10000, (invalid) 32767. + Receive signal strength indicator, 0: 0%, 100: 100%, 255: invalid/unknown. The RAW values of the RC channels received. The standard PPM modulation is as follows: 1000 microseconds: 0%, 2000 microseconds: 100%. Individual receivers/transmitters might violate this specification. Timestamp (milliseconds since system boot) - Servo output port (set of 8 outputs = 1 port). Most MAVs will just use one, but this allows to encode more than 8 servos. - RC channel 1 value, in microseconds - RC channel 2 value, in microseconds - RC channel 3 value, in microseconds - RC channel 4 value, in microseconds - RC channel 5 value, in microseconds - RC channel 6 value, in microseconds - RC channel 7 value, in microseconds - RC channel 8 value, in microseconds - Receive signal strength indicator, 0: 0%, 255: 100% + Servo output port (set of 8 outputs = 1 port). Most MAVs will just use one, but this allows for more than 8 servos. + RC channel 1 value, in microseconds. A value of 65535 implies the channel is unused. + RC channel 2 value, in microseconds. A value of 65535 implies the channel is unused. + RC channel 3 value, in microseconds. A value of 65535 implies the channel is unused. + RC channel 4 value, in microseconds. A value of 65535 implies the channel is unused. + RC channel 5 value, in microseconds. A value of 65535 implies the channel is unused. + RC channel 6 value, in microseconds. A value of 65535 implies the channel is unused. + RC channel 7 value, in microseconds. A value of 65535 implies the channel is unused. + RC channel 8 value, in microseconds. A value of 65535 implies the channel is unused. + Receive signal strength indicator, 0: 0%, 100: 100%, 255: invalid/unknown. The RAW values of the servo outputs (for RC input from the remote, use the RC_CHANNELS messages). The standard PPM modulation is as follows: 1000 microseconds: 0%, 2000 microseconds: 100%. - Timestamp (since UNIX epoch or microseconds since system boot) + Timestamp (microseconds since system boot) Servo output port (set of 8 outputs = 1 port). Most MAVs will just use one, but this allows to encode more than 8 servos. Servo output 1 value, in microseconds Servo output 2 value, in microseconds @@ -1091,7 +1124,7 @@ Servo output 8 value, in microseconds - Request the overall list of MISSIONs from the system/component. http://qgroundcontrol.org/mavlink/waypoint_protocol + Request a partial list of mission items from the system/component. http://qgroundcontrol.org/mavlink/waypoint_protocol. If start and end index are the same, just send one waypoint. System ID Component ID Start index, 0 by default @@ -1106,8 +1139,7 @@ Message encoding a mission item. This message is emitted to announce - the presence of a mission item and to set a mission item on the system. The mission item can be either in x, y, z meters (type: LOCAL) or x:lat, y:lon, z:altitude. Local frame is Z-down, right handed (NED), global frame is Z-up, right handed (ENU). http://qgroundcontrol.org/mavlink/waypoint_protocol - + the presence of a mission item and to set a mission item on the system. The mission item can be either in x, y, z meters (type: LOCAL) or x:lat, y:lon, z:altitude. Local frame is Z-down, right handed (NED), global frame is Z-up, right handed (ENU). See also http://qgroundcontrol.org/mavlink/waypoint_protocol. System ID Component ID Sequence @@ -1166,7 +1198,7 @@ See MAV_MISSION_RESULT enum - As local MISSIONs exist, the global MISSION reference allows to transform between the local coordinate frame and the global (GPS) coordinate frame. This can be necessary when e.g. in- and outdoor settings are connected and the MAV should move from in- to outdoor. + As local waypoints exist, the global MISSION reference allows to transform between the local coordinate frame and the global (GPS) coordinate frame. This can be necessary when e.g. in- and outdoor settings are connected and the MAV should move from in- to outdoor. System ID global position * 1E7 global position * 1E7 @@ -1268,10 +1300,25 @@ Desired yaw angular speed in rad/s Collective thrust, normalized to 0 .. 1 + + Setpoint in the four motor speeds + System ID of the system that should set these motor commands + Front motor in + configuration, front left motor in x configuration + Right motor in + configuration, front right motor in x configuration + Back motor in + configuration, back right motor in x configuration + Left motor in + configuration, back left motor in x configuration + + + Setpoint for up to four quadrotors in a group / wing + ID of the quadrotor group (0 - 255, up to 256 groups supported) + ID of the flight mode (0 - 255, up to 256 modes supported) + Desired roll angle in radians +-PI (+-32767) + Desired pitch angle in radians +-PI (+-32767) + Desired yaw angle in radians, scaled to int16 +-PI (+-32767) + Collective thrust, scaled to uint16 (0..65535) + - Outputs of the APM navigation controller. The primary use of this message is to check the response and signs - of the controller before actual flight and to assist with tuning controller parameters - + Outputs of the APM navigation controller. The primary use of this message is to check the response and signs of the controller before actual flight and to assist with tuning controller parameters. Current desired roll in degrees Current desired pitch in degrees Current desired heading in degrees @@ -1281,6 +1328,18 @@ Current airspeed error in meters/second Current crosstrack error on x-y plane in meters + + Setpoint for up to four quadrotors in a group / wing + ID of the quadrotor group (0 - 255, up to 256 groups supported) + ID of the flight mode (0 - 255, up to 256 modes supported) + RGB red channel (0-255) + RGB green channel (0-255) + RGB blue channel (0-255) + Desired roll angle in radians +-PI (+-32767) + Desired pitch angle in radians +-PI (+-32767) + Desired yaw angle in radians, scaled to int16 +-PI (+-32767) + Collective thrust, scaled to uint16 (0..65535) + Corrects the systems state by adding an error correction term to the position and velocity, and by rotating the attitude by a correction angle. x position error @@ -1306,15 +1365,13 @@ 1 stream is enabled, 0 stream is stopped. - The system to be controlled - roll - pitch - yaw - thrust - roll control enabled auto:0, manual:1 - pitch auto:0, manual:1 - yaw auto:0, manual:1 - thrust auto:0, manual:1 + This message provides an API for manually controlling the vehicle using standard joystick axes nomenclature, along with a joystick-like input device. Unused axes can be disabled an buttons are also transmit as boolean values of their + The system to be controlled. + X-axis, normalized to the range [-1000,1000]. A value of INT16_MAX indicates that this axis is invalid. Generally corresponds to forward(1000)-backward(-1000) movement on a joystick and the pitch of a vehicle. + Y-axis, normalized to the range [-1000,1000]. A value of INT16_MAX indicates that this axis is invalid. Generally corresponds to left(-1000)-right(1000) movement on a joystick and the roll of a vehicle. + Z-axis, normalized to the range [-1000,1000]. A value of INT16_MAX indicates that this axis is invalid. Generally corresponds to a separate slider movement with maximum being 1000 and minimum being -1000 on a joystick and the thrust of a vehicle. + R-axis, normalized to the range [-1000,1000]. A value of INT16_MAX indicates that this axis is invalid. Generally corresponds to a twisting of the joystick, with counter-clockwise being 1000 and clockwise being -1000, and the yaw of a vehicle. + A bitfield corresponding to the joystick buttons' current state, 1 for pressed, 0 for released. The lowest bit corresponds to Button 1. The RAW values of the RC channels sent to the MAV to override info received from the RC radio. A value of -1 means no change to that channel. A value of 0 means control of that channel should be released back to the RC radio. The standard PPM modulation is as follows: 1000 microseconds: 0%, 2000 microseconds: 100%. Individual receivers/transmitters might violate this specification. @@ -1353,83 +1410,72 @@ Parameter 7, as defined by MAV_CMD enum. - Report status of a command. Includes feedback wether the command was executed + Report status of a command. Includes feedback wether the command was executed. Command ID, as defined by MAV_CMD enum. See MAV_RESULT enum - - - - Sent from simulation to autopilot. This packet is useful for high throughput - applications such as hardware in the loop simulations. - - Timestamp (microseconds since UNIX epoch or microseconds since system boot) - Roll angle (rad) - Pitch angle (rad) - Yaw angle (rad) - Roll angular speed (rad/s) - Pitch angular speed (rad/s) - Yaw angular speed (rad/s) - Latitude, expressed as * 1E7 - Longitude, expressed as * 1E7 - Altitude in meters, expressed as * 1000 (millimeters) - Ground X Speed (Latitude), expressed as m/s * 100 - Ground Y Speed (Longitude), expressed as m/s * 100 - Ground Z Speed (Altitude), expressed as m/s * 100 - X acceleration (mg) - Y acceleration (mg) - Z acceleration (mg) - - - Sent from autopilot to simulation. Hardware in the loop control outputs - Timestamp (microseconds since UNIX epoch or microseconds since system boot) - Control output -1 .. 1 - Control output -1 .. 1 - Control output -1 .. 1 - Throttle 0 .. 1 - Aux 1, -1 .. 1 - Aux 2, -1 .. 1 - Aux 3, -1 .. 1 - Aux 4, -1 .. 1 - System mode (MAV_MODE) - Navigation mode (MAV_NAV_MODE) - - + + Sent from autopilot to simulation. Hardware in the loop control outputs + Timestamp (microseconds since UNIX epoch or microseconds since system boot) + Control output -1 .. 1 + Control output -1 .. 1 + Control output -1 .. 1 + Throttle 0 .. 1 + Aux 1, -1 .. 1 + Aux 2, -1 .. 1 + Aux 3, -1 .. 1 + Aux 4, -1 .. 1 + System mode (MAV_MODE) + Navigation mode (MAV_NAV_MODE) + + Sent from simulation to autopilot. The RAW values of the RC channels received. The standard PPM modulation is as follows: 1000 microseconds: 0%, 2000 microseconds: 100%. Individual receivers/transmitters might violate this specification. Timestamp (microseconds since UNIX epoch or microseconds since system boot) RC channel 1 value, in microseconds @@ -1452,11 +1498,13 @@ Sensor ID Flow in pixels in x-sensor direction Flow in pixels in y-sensor direction + Flow in meters in x-sensor direction, angular-speed compensated + Flow in meters in y-sensor direction, angular-speed compensated Optical flow quality / confidence. 0: bad, 255: maximum quality - Ground distance in meters + Ground distance in meters. Positive value: distance known. Negative value: Unknown distance - Timestamp (milliseconds) + Timestamp (microseconds, synced to UNIX time or since system boot) Global X position Global Y position Global Z position @@ -1465,7 +1513,7 @@ Yaw angle in rad - Timestamp (milliseconds) + Timestamp (microseconds, synced to UNIX time or since system boot) Global X position Global Y position Global Z position @@ -1474,13 +1522,13 @@ Yaw angle in rad - Timestamp (milliseconds) + Timestamp (microseconds, synced to UNIX time or since system boot) Global X speed Global Y speed Global Z speed - Timestamp (milliseconds) + Timestamp (microseconds, synced to UNIX time or since system boot) Global X position Global Y position Global Z position @@ -1488,6 +1536,86 @@ Pitch angle in rad Yaw angle in rad + + The IMU readings in SI units in NED body frame + Timestamp (microseconds, synced to UNIX time or since system boot) + X acceleration (m/s^2) + Y acceleration (m/s^2) + Z acceleration (m/s^2) + Angular speed around X axis (rad / sec) + Angular speed around Y axis (rad / sec) + Angular speed around Z axis (rad / sec) + X Magnetic field (Gauss) + Y Magnetic field (Gauss) + Z Magnetic field (Gauss) + Absolute pressure in millibar + Differential pressure in millibar + Altitude calculated from pressure + Temperature in degrees celsius + Bitmask for fields that have updated since last message, bit 0 = xacc, bit 12: temperature + + + Optical flow from an omnidirectional flow sensor (e.g. PX4FLOW with wide angle lens) + Timestamp (microseconds, synced to UNIX time or since system boot) + Sensor ID + Flow in deci pixels (1 = 0.1 pixel) on left hemisphere + Flow in deci pixels (1 = 0.1 pixel) on right hemisphere + Optical flow quality / confidence. 0: bad, 255: maximum quality + Front distance in meters. Positive value (including zero): distance known. Negative value: Unknown distance + + + Begin file transfer + Unique transfer ID + Destination path + Transfer direction: 0: from requester, 1: to requester + File size in bytes + RESERVED + + + Get directory listing + Unique transfer ID + Directory path to list + RESERVED + + + File transfer result + Unique transfer ID + 0: OK, 1: not permitted, 2: bad path / file name, 3: no space left on device + + + Transmitte battery informations for a accu pack. + Accupack ID + Battery voltage of cell 1, in millivolts (1 = 1 millivolt) + Battery voltage of cell 2, in millivolts (1 = 1 millivolt), -1: no cell + Battery voltage of cell 3, in millivolts (1 = 1 millivolt), -1: no cell + Battery voltage of cell 4, in millivolts (1 = 1 millivolt), -1: no cell + Battery voltage of cell 5, in millivolts (1 = 1 millivolt), -1: no cell + Battery voltage of cell 6, in millivolts (1 = 1 millivolt), -1: no cell + Battery current, in 10*milliamperes (1 = 10 milliampere), -1: autopilot does not measure the current + Remaining battery energy: (0%: 0, 100%: 100), -1: autopilot does not estimate the remaining battery + + + Set the 8 DOF setpoint for a controller. + System ID + Value 1 + Value 2 + Value 3 + Value 4 + Value 5 + Value 6 + Value 7 + Value 8 + + + Set the 6 DOF setpoint for a attitude and position controller. + System ID + Translational Component in x + Translational Component in y + Translational Component in z + Rotational Component in x + Rotational Component in y + Rotational Component in z + Send raw controller memory. The use of this message is discouraged for normal packets, but a quite efficient way for testing new messages and getting experimental debug output. @@ -1517,7 +1645,7 @@ Status text message. These messages are printed in yellow in the COMM console of QGroundControl. WARNING: They consume quite some bandwidth, so use only for important status and error messages. If implemented wisely, these messages are buffered on the MCU and sent only at a limited rate (e.g. 10 Hz). - Severity of status, 0 = info message, 255 = critical fault + Severity of status. Relies on the definitions within RFC-5424. See enum MAV_SEVERITY. Status text message, without null termination character @@ -1526,11 +1654,5 @@ index of debug variable DEBUG value - - Extended message spacer. - System which should execute the command - Component which should execute the command, 0 for all components - Retransmission / ACK flags - diff --git a/src/GCS_MAVLink/message_definitions_v1.0/matrixpilot.xml b/src/GCS_MAVLink/message_definitions_v1.0/matrixpilot.xml index 9e86eaf99..29d368d2a 100644 --- a/src/GCS_MAVLink/message_definitions_v1.0/matrixpilot.xml +++ b/src/GCS_MAVLink/message_definitions_v1.0/matrixpilot.xml @@ -1,14 +1,284 @@ - - - common.xml - - - + + + + + + Action required when performing CMD_PREFLIGHT_STORAGE + + Read all parameters from storage + + + Write all parameters to storage + + + Clear all parameters in storage + + + Read specific parameters from storage + + + Write specific parameters to storage + + + Clear specific parameters in storage + + + do nothing + + + + + + Request storage of different parameter values and logs. This command will be only accepted if in pre-flight mode. + Storage action: Action defined by MAV_PREFLIGHT_STORAGE_ACTION_ADVANCED + Storage area as defined by parameter database + Storage flags as defined by parameter database + Empty + Empty + Empty + Empty + + + + + + + + + Depreciated but used as a compiler flag. Do not remove + System ID + Component ID + + + Reqest reading of flexifunction data + System ID + Component ID + Type of flexifunction data requested + index into data where needed + + + Flexifunction type and parameters for component at function index from buffer + System ID + Component ID + Function index + Total count of functions + Address in the flexifunction data, Set to 0xFFFF to use address in target memory + Size of the + Settings data + + + Flexifunction type and parameters for component at function index from buffer + System ID + Component ID + Function index + result of acknowledge, 0=fail, 1=good + + + Acknowldge sucess or failure of a flexifunction command + System ID + Component ID + 0=inputs, 1=outputs + index of first directory entry to write + count of directory entries to write + Settings data + + + Acknowldge sucess or failure of a flexifunction command + System ID + Component ID + 0=inputs, 1=outputs + index of first directory entry to write + count of directory entries to write + result of acknowledge, 0=fail, 1=good + + + Acknowldge sucess or failure of a flexifunction command + System ID + Component ID + Flexifunction command type + + + Acknowldge sucess or failure of a flexifunction command + Command acknowledged + result of acknowledge + + + Backwards compatible MAVLink version of SERIAL_UDB_EXTRA - F2: Format Part A + Serial UDB Extra Time + Serial UDB Extra Status + Serial UDB Extra Latitude + Serial UDB Extra Longitude + Serial UDB Extra Altitude + Serial UDB Extra Waypoint Index + Serial UDB Extra Rmat 0 + Serial UDB Extra Rmat 1 + Serial UDB Extra Rmat 2 + Serial UDB Extra Rmat 3 + Serial UDB Extra Rmat 4 + Serial UDB Extra Rmat 5 + Serial UDB Extra Rmat 6 + Serial UDB Extra Rmat 7 + Serial UDB Extra Rmat 8 + Serial UDB Extra GPS Course Over Ground + Serial UDB Extra Speed Over Ground + Serial UDB Extra CPU Load + Serial UDB Extra Voltage in MilliVolts + Serial UDB Extra 3D IMU Air Speed + Serial UDB Extra Estimated Wind 0 + Serial UDB Extra Estimated Wind 1 + Serial UDB Extra Estimated Wind 2 + Serial UDB Extra Magnetic Field Earth 0 + Serial UDB Extra Magnetic Field Earth 1 + Serial UDB Extra Magnetic Field Earth 2 + Serial UDB Extra Number of Sattelites in View + Serial UDB Extra GPS Horizontal Dilution of Precision + + + Backwards compatible version of SERIAL_UDB_EXTRA - F2: Part B + Serial UDB Extra Time + Serial UDB Extra PWM Input Channel 1 + Serial UDB Extra PWM Input Channel 2 + Serial UDB Extra PWM Input Channel 3 + Serial UDB Extra PWM Input Channel 4 + Serial UDB Extra PWM Input Channel 5 + Serial UDB Extra PWM Input Channel 6 + Serial UDB Extra PWM Input Channel 7 + Serial UDB Extra PWM Input Channel 8 + Serial UDB Extra PWM Input Channel 9 + Serial UDB Extra PWM Input Channel 10 + Serial UDB Extra PWM Output Channel 1 + Serial UDB Extra PWM Output Channel 2 + Serial UDB Extra PWM Output Channel 3 + Serial UDB Extra PWM Output Channel 4 + Serial UDB Extra PWM Output Channel 5 + Serial UDB Extra PWM Output Channel 6 + Serial UDB Extra PWM Output Channel 7 + Serial UDB Extra PWM Output Channel 8 + Serial UDB Extra PWM Output Channel 9 + Serial UDB Extra PWM Output Channel 10 + Serial UDB Extra IMU Location X + Serial UDB Extra IMU Location Y + Serial UDB Extra IMU Location Z + Serial UDB Extra Status Flags + Serial UDB Extra Oscillator Failure Count + Serial UDB Extra IMU Velocity X + Serial UDB Extra IMU Velocity Y + Serial UDB Extra IMU Velocity Z + Serial UDB Extra Current Waypoint Goal X + Serial UDB Extra Current Waypoint Goal Y + Serial UDB Extra Current Waypoint Goal Z + Serial UDB Extra Stack Memory Free + + + Backwards compatible version of SERIAL_UDB_EXTRA F4: format + Serial UDB Extra Roll Stabilization with Ailerons Enabled + Serial UDB Extra Roll Stabilization with Rudder Enabled + Serial UDB Extra Pitch Stabilization Enabled + Serial UDB Extra Yaw Stabilization using Rudder Enabled + Serial UDB Extra Yaw Stabilization using Ailerons Enabled + Serial UDB Extra Navigation with Ailerons Enabled + Serial UDB Extra Navigation with Rudder Enabled + Serial UDB Extra Type of Alitude Hold when in Stabilized Mode + Serial UDB Extra Type of Alitude Hold when in Waypoint Mode + Serial UDB Extra Firmware racing mode enabled + + + Backwards compatible version of SERIAL_UDB_EXTRA F5: format + Serial UDB YAWKP_AILERON Gain for Proporional control of navigation + Serial UDB YAWKD_AILERON Gain for Rate control of navigation + Serial UDB Extra ROLLKP Gain for Proportional control of roll stabilization + Serial UDB Extra ROLLKD Gain for Rate control of roll stabilization + YAW_STABILIZATION_AILERON Proportional control + Gain For Boosting Manual Aileron control When Plane Stabilized + + + Backwards compatible version of SERIAL_UDB_EXTRA F6: format + Serial UDB Extra PITCHGAIN Proportional Control + Serial UDB Extra Pitch Rate Control + Serial UDB Extra Rudder to Elevator Mix + Serial UDB Extra Roll to Elevator Mix + Gain For Boosting Manual Elevator control When Plane Stabilized + + + Backwards compatible version of SERIAL_UDB_EXTRA F7: format + Serial UDB YAWKP_RUDDER Gain for Proporional control of navigation + Serial UDB YAWKD_RUDDER Gain for Rate control of navigation + Serial UDB Extra ROLLKP_RUDDER Gain for Proportional control of roll stabilization + Serial UDB Extra ROLLKD_RUDDER Gain for Rate control of roll stabilization + SERIAL UDB EXTRA Rudder Boost Gain to Manual Control when stabilized + Serial UDB Extra Return To Landing - Angle to Pitch Plane Down + + + Backwards compatible version of SERIAL_UDB_EXTRA F8: format + Serial UDB Extra HEIGHT_TARGET_MAX + Serial UDB Extra HEIGHT_TARGET_MIN + Serial UDB Extra ALT_HOLD_THROTTLE_MIN + Serial UDB Extra ALT_HOLD_THROTTLE_MAX + Serial UDB Extra ALT_HOLD_PITCH_MIN + Serial UDB Extra ALT_HOLD_PITCH_MAX + Serial UDB Extra ALT_HOLD_PITCH_HIGH + + + Backwards compatible version of SERIAL_UDB_EXTRA F13: format + Serial UDB Extra GPS Week Number + Serial UDB Extra MP Origin Latitude + Serial UDB Extra MP Origin Longitude + Serial UDB Extra MP Origin Altitude Above Sea Level + + + Backwards compatible version of SERIAL_UDB_EXTRA F14: format + Serial UDB Extra Wind Estimation Enabled + Serial UDB Extra Type of GPS Unit + Serial UDB Extra Dead Reckoning Enabled + Serial UDB Extra Type of UDB Hardware + Serial UDB Extra Type of Airframe + Serial UDB Extra Reboot Regitster of DSPIC + Serial UDB Extra Last dspic Trap Flags + Serial UDB Extra Type Program Address of Last Trap + Serial UDB Extra Number of Ocillator Failures + Serial UDB Extra UDB Internal Clock Configuration + Serial UDB Extra Type of Flight Plan + + + Backwards compatible version of SERIAL_UDB_EXTRA F15 and F16: format + Serial UDB Extra Model Name Of Vehicle + Serial UDB Extra Registraton Number of Vehicle + + + Serial UDB Extra Name of Expected Lead Pilot + Serial UDB Extra URL of Lead Pilot or Team + + + The altitude measured by sensors and IMU + Timestamp (milliseconds since system boot) + GPS altitude in meters, expressed as * 1000 (millimeters), above MSL + IMU altitude above ground in meters, expressed as * 1000 (millimeters) + barometeric altitude above ground in meters, expressed as * 1000 (millimeters) + Optical flow altitude above ground in meters, expressed as * 1000 (millimeters) + Rangefinder Altitude above ground in meters, expressed as * 1000 (millimeters) + Extra altitude above ground in meters, expressed as * 1000 (millimeters) + + + The airspeed measured by sensors and IMU + Timestamp (milliseconds since system boot) + Airspeed estimate from IMU, cm/s + Pitot measured forward airpseed, cm/s + Hot wire anenometer measured airspeed, cm/s + Ultrasonic measured airspeed, cm/s + Angle of attack sensor, degrees * 10 + Yaw angle sensor, degrees * 10 + + + diff --git a/src/GCS_MAVLink/message_definitions_v1.0/minimal.xml b/src/GCS_MAVLink/message_definitions_v1.0/minimal.xml index 185a657de..88985a5c9 100644 --- a/src/GCS_MAVLink/message_definitions_v1.0/minimal.xml +++ b/src/GCS_MAVLink/message_definitions_v1.0/minimal.xml @@ -1,15 +1,188 @@ 2 - + + + Micro air vehicle / autopilot classes. This identifies the individual model. + + Generic autopilot, full support for everything + + + PIXHAWK autopilot, http://pixhawk.ethz.ch + + + SLUGS autopilot, http://slugsuav.soe.ucsc.edu + + + ArduPilotMega / ArduCopter, http://diydrones.com + + + OpenPilot, http://openpilot.org + + + Generic autopilot only supporting simple waypoints + + + Generic autopilot supporting waypoints and other simple navigation commands + + + Generic autopilot supporting the full mission command set + + + No valid autopilot, e.g. a GCS or other MAVLink component + + + PPZ UAV - http://nongnu.org/paparazzi + + + UAV Dev Board + + + FlexiPilot + + + + + Generic micro air vehicle. + + + Fixed wing aircraft. + + + Quadrotor + + + Coaxial helicopter + + + Normal helicopter with tail rotor. + + + Ground installation + + + Operator control unit / ground control station + + + Airship, controlled + + + Free balloon, uncontrolled + + + Rocket + + + Ground rover + + + Surface vessel, boat, ship + + + Submarine + + + Hexarotor + + + Octorotor + + + Octorotor + + + Flapping wing + + + + These flags encode the MAV mode. + + 0b10000000 MAV safety set to armed. Motors are enabled / running / can start. Ready to fly. + + + 0b01000000 remote control input is enabled. + + + 0b00100000 hardware in the loop simulation. All motors / actuators are blocked, but internal software is full operational. + + + 0b00010000 system stabilizes electronically its attitude (and optionally position). It needs however further control inputs to move around. + + + 0b00001000 guided mode enabled, system flies MISSIONs / mission items. + + + 0b00000100 autonomous mode enabled, system finds its own goal positions. Guided flag can be set or not, depends on the actual implementation. + + + 0b00000010 system has a test mode enabled. This flag is intended for temporary system tests and should not be used for stable implementations. + + + 0b00000001 Reserved for future use. + + + + These values encode the bit positions of the decode position. These values can be used to read the value of a flag bit by combining the base_mode variable with AND with the flag position value. The result will be either 0 or 1, depending on if the flag is set or not. + + First bit: 10000000 + + + Second bit: 01000000 + + + Third bit: 00100000 + + + Fourth bit: 00010000 + + + Fifth bit: 00001000 + + + Sixt bit: 00000100 + + + Seventh bit: 00000010 + + + Eighth bit: 00000001 + + + + + Uninitialized system, state is unknown. + + + System is booting up. + + + System is calibrating and not flight-ready. + + + System is grounded and on standby. It can be launched any time. + + + System is active and might be already airborne. Motors are engaged. + + + System is in a non-normal flight mode. It can however still navigate. + + + System is in a non-normal flight mode. It lost control over parts or over the whole airframe. It is in mayday and going down. + + + System just initialized its power-down sequence, will shut down now. + + + 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). Type of the MAV (quadrotor, helicopter, etc., up to 15 types, defined in MAV_TYPE ENUM) - Autopilot type / class. defined in MAV_CLASS ENUM + Autopilot type / class. defined in MAV_AUTOPILOT ENUM System mode bitfield, see MAV_MODE_FLAGS ENUM in mavlink/include/mavlink_types.h - Navigation mode bitfield, see MAV_AUTOPILOT_CUSTOM_MODE ENUM for some examples. This field is autopilot-specific. - System status flag, see MAV_STATUS ENUM + A bitfield for use for autopilot-specific flags. + System status flag, see MAV_STATE ENUM MAVLink version diff --git a/src/GCS_MAVLink/message_definitions_v1.0/pixhawk.proto b/src/GCS_MAVLink/message_definitions_v1.0/pixhawk.proto new file mode 100644 index 000000000..991dcee8a --- /dev/null +++ b/src/GCS_MAVLink/message_definitions_v1.0/pixhawk.proto @@ -0,0 +1,163 @@ +package px; + +message HeaderInfo +{ + required int32 source_sysid = 1; + required int32 source_compid = 2; + required double timestamp = 3; // in seconds +} + +message GLOverlay +{ + required HeaderInfo header = 1; + + optional string name = 2; + + enum CoordinateFrameType + { + GLOBAL = 0; + LOCAL = 1; + } + optional CoordinateFrameType coordinateFrameType = 3; + + optional double origin_x = 4; + optional double origin_y = 5; + optional double origin_z = 6; + + optional bytes data = 7; + + enum Mode + { + POINTS = 0; + LINES = 1; + LINE_STRIP = 2; + LINE_LOOP = 3; + TRIANGLES = 4; + TRIANGLE_STRIP = 5; + TRIANGLE_FAN = 6; + QUADS = 7; + QUAD_STRIP = 8; + POLYGON = 9; + SOLID_CIRCLE = 10; + WIRE_CIRCLE = 11; + SOLID_CUBE = 12; + WIRE_CUBE = 13; + } + + enum Identifier + { + END = 14; + VERTEX2F = 15; + VERTEX3F = 16; + ROTATEF = 17; + TRANSLATEF = 18; + SCALEF = 19; + PUSH_MATRIX = 20; + POP_MATRIX = 21; + COLOR3F = 22; + COLOR4F = 23; + POINTSIZE = 24; + LINEWIDTH = 25; + } +} + +message Obstacle +{ + optional float x = 1; + optional float y = 2; + optional float z = 3; + optional float length = 4; + optional float width = 5; + optional float height = 6; +} + +message ObstacleList +{ + required HeaderInfo header = 1; + + repeated Obstacle obstacles = 2; +} + +message ObstacleMap +{ + required HeaderInfo header = 1; + + required int32 type = 2; + + optional float resolution = 3; + optional int32 rows = 4; + optional int32 cols = 5; + optional int32 mapR0 = 6; + optional int32 mapC0 = 7; + optional int32 arrayR0 = 8; + optional int32 arrayC0 = 9; + + optional bytes data = 10; +} + +message Path +{ + required HeaderInfo header = 1; + + repeated Waypoint waypoints = 2; +} + +message PointCloudXYZI { + message PointXYZI { + required float x = 1; + required float y = 2; + required float z = 3; + required float intensity = 4; + } + + required HeaderInfo header = 1; + repeated PointXYZI points = 2; +} + +message PointCloudXYZRGB { + message PointXYZRGB { + required float x = 1; + required float y = 2; + required float z = 3; + required float rgb = 4; + } + + required HeaderInfo header = 1; + repeated PointXYZRGB points = 2; +} + +message RGBDImage +{ + required HeaderInfo header = 1; + + required uint32 cols = 2; ///< Number of columns in image(s) + required uint32 rows = 3; ///< Number of rows in image(s) + required uint32 step1 = 4; ///< Step (stride) of image 1 + required uint32 type1 = 5; ///< Type of image 1 + required bytes imageData1 = 6; + required uint32 step2 = 7; ///< Step (stride) of image 2 + required uint32 type2 = 8; ///< Type of image 2 + required bytes imageData2 = 9; + optional uint32 camera_config = 10; ///< PxSHM::Camera enumeration + optional uint32 camera_type = 11; ///< PxSHM::CameraType enumeration + optional float roll = 12; + optional float pitch = 13; + optional float yaw = 14; + optional float lon = 15; + optional float lat = 16; + optional float alt = 17; + optional float ground_x = 18; + optional float ground_y = 19; + optional float ground_z = 20; + repeated float camera_matrix = 21; +} + +message Waypoint +{ + required double x = 1; + required double y = 2; + optional double z = 3; + optional double roll = 4; + optional double pitch = 5; + optional double yaw = 6; +} diff --git a/src/GCS_MAVLink/message_definitions_v1.0/pixhawk.xml b/src/GCS_MAVLink/message_definitions_v1.0/pixhawk.xml index 75d536a12..3c38b0bc0 100644 --- a/src/GCS_MAVLink/message_definitions_v1.0/pixhawk.xml +++ b/src/GCS_MAVLink/message_definitions_v1.0/pixhawk.xml @@ -8,6 +8,21 @@ + + + + Starts a search + 1 to arm, 0 to disarm + + + Starts a search + 1 to arm, 0 to disarm + + + Starts a search + 1 to arm, 0 to disarm + + @@ -160,6 +175,8 @@ type of requested/acknowledged data (as defined in ENUM DATA_TYPES in mavlink/include/mavlink_types.h) total data size in bytes (set on ACK only) + Width of a matrix or image + Height of a matrix or image number of packets beeing sent (set on ACK only) payload size per packet (normally 253 byte, see DATA field size in message ENCAPSULATED_DATA) (set on ACK only) JPEG quality out of [1,100] diff --git a/src/GCS_MAVLink/message_definitions_v1.0/sensesoar.xml b/src/GCS_MAVLink/message_definitions_v1.0/sensesoar.xml new file mode 100644 index 000000000..0b638b38b --- /dev/null +++ b/src/GCS_MAVLink/message_definitions_v1.0/sensesoar.xml @@ -0,0 +1,143 @@ + + + common.xml + + + Different flight modes + + Gliding mode with motors off + + + Autonomous flight + + + RC controlled + + + + + + Position estimate of the observer in global frame + + Longitude expressed in 1E7 + + + Latitude expressed in 1E7 + + + Altitude expressed in milimeters + + + + velocity estimate of the observer in NED inertial frame + + Velocity + + + + attitude estimate of the observe + + Quaternion re;im + + + + Wind estimate in NED inertial frame + + Wind + + + + Estimate of the air velocity + + Air speed + + + angle of attack + + + slip angle + + + + IMU biases + + accelerometer bias + + + gyroscope bias + + + + estimate of the pressure at sea level + + Wind + + + + ambient air temperature + + Air Temperatur + + + + filtered rotational velocity + + rotational velocity + + + + low level control output + + Servo signal + + + motor signal + + + + Power managment + + current power consumption + + + battery status + + + Power generation from each module + + + + system status + + gps status + + + actuator status + + + module status + + + module status + + + + change commanded air speed + + Target ID + + + commanded airspeed + + + + accept change of airspeed + + commanded airspeed + + + 0:ack, 1:nack + + + + diff --git a/src/GCS_MAVLink/message_definitions_v1.0/slugs.xml b/src/GCS_MAVLink/message_definitions_v1.0/slugs.xml index f8644c5c4..621183072 100644 --- a/src/GCS_MAVLink/message_definitions_v1.0/slugs.xml +++ b/src/GCS_MAVLink/message_definitions_v1.0/slugs.xml @@ -37,21 +37,21 @@ - Sensor and DSC control loads. + Sensor and DSC control loads. Sensor DSC Load Control DSC Load Battery Voltage in millivolts - Air data for altitude and airspeed computation. + Air data for altitude and airspeed computation. Dynamic pressure (Pa) Static pressure (Pa) Board temperature - Accelerometer and gyro biases. + Accelerometer and gyro biases. Accelerometer X bias (m/s) Accelerometer Y bias (m/s) Accelerometer Z bias (m/s) @@ -61,7 +61,7 @@ - Configurable diagnostic messages. + Configurable diagnostic messages. Diagnostic float 1 Diagnostic float 2 Diagnostic float 3 @@ -71,7 +71,7 @@ - Data used in the navigation algorithm. + Data used in the navigation algorithm. Measured Airspeed prior to the Nav Filter Commanded Roll Commanded Pitch @@ -84,7 +84,7 @@ - Configurable data log probes to be used inside Simulink + Configurable data log probes to be used inside Simulink. Log value 1 Log value 2 Log value 3 @@ -94,7 +94,7 @@ - Pilot console PWM messges. + Pilot console PWM messges. Year reported by Gps Month reported by Gps Day reported by Gps @@ -105,7 +105,7 @@ - Mid Level commands sent from the GS to the autopilot. These are only sent when being opperated in mid-level commands mode from the ground; for periodic report of these commands generated from the autopilot see message XXXX. + Mid Level commands sent from the GS to the autopilot. These are only sent when being opperated in mid-level commands mode from the ground; for periodic report of these commands generated from the autopilot see message XXXX. The system setting the commands Commanded Airspeed Log value 2 @@ -114,7 +114,7 @@ - This message configures the Selective Passthrough mode. it allows to select which control surfaces the Pilot can control from his console. It is implemented as a bitfield as follows: + This message configures the Selective Passthrough mode. it allows to select which control surfaces the Pilot can control from his console. It is implemented as a bitfield as follows: Position Bit Code ================================= 15-8 Reserved @@ -126,7 +126,7 @@ 2 dre_pass 4 1 dlf_pass 2 0 drf_pass 1 - Where Bit 15 is the MSb. 0 = AP has control of the surface; 1 = Pilot Console has control of the surface. + Where Bit 15 is the MSb. 0 = AP has control of the surface; 1 = Pilot Console has control of the surface. The system setting the commands Bitfield containing the PT configuration @@ -134,7 +134,7 @@ - Action messages focused on the SLUGS AP. + Action messages focused on the SLUGS AP. The system reporting the action Action ID. See apDefinitions.h in the SLUGS /clib directory for the ID names Value associated with the action diff --git a/src/GCS_MAVLink/message_definitions_v1.0/ualberta.xml b/src/GCS_MAVLink/message_definitions_v1.0/ualberta.xml index 5e53e141e..bb57e8435 100644 --- a/src/GCS_MAVLink/message_definitions_v1.0/ualberta.xml +++ b/src/GCS_MAVLink/message_definitions_v1.0/ualberta.xml @@ -4,24 +4,46 @@ Available autopilot modes for ualberta uav - Raw input pulse widts sent to output - Inputs are normalized using calibration, the converted back to raw pulse widths for output - dfsdfs - dfsfds - dfsdfsdfs + + Raw input pulse widts sent to output + + + Inputs are normalized using calibration, the converted back to raw pulse widths for output + + + dfsdfs + + + dfsfds + + + dfsdfsdfs + Navigation filter mode - AHRS mode - INS/GPS initialization mode - INS/GPS mode + + AHRS mode + + + INS/GPS initialization mode + + + INS/GPS mode + Mode currently commanded by pilot - sdf - dfs - Rotomotion mode + + sdf + + + dfs + + + Rotomotion mode + diff --git a/src/GCS_MAVLink/missionlib/mavlink_missionlib_data.h b/src/GCS_MAVLink/missionlib/mavlink_missionlib_data.h new file mode 100644 index 000000000..c825fbcef --- /dev/null +++ b/src/GCS_MAVLink/missionlib/mavlink_missionlib_data.h @@ -0,0 +1,58 @@ +/******************************************************************************* + + Copyright (C) 2011 Lorenz Meier lm ( a t ) inf.ethz.ch + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + + ****************************************************************************/ + +/* This assumes you have the mavlink headers on your include path + or in the same folder as this source file */ + +// Disable auto-data structures +#ifndef MAVLINK_NO_DATA +#define MAVLINK_NO_DATA +#endif + +#include "mavlink.h" +#include + +/* MISSION LIB DATA STORAGE */ + +enum MAVLINK_PM_PARAMETERS +{ + MAVLINK_PM_PARAM_SYSTEM_ID, + MAVLINK_PM_PARAM_ATT_K_D, + MAVLINK_PM_MAX_PARAM_COUNT // VERY IMPORTANT! KEEP THIS AS LAST ENTRY +}; + + +/* DO NOT EDIT THIS FILE BELOW THIS POINT! */ + +#ifndef MAVLINK_MSG_PARAM_VALUE_FIELD_PARAM_ID_LEN +#define MAVLINK_MSG_PARAM_VALUE_FIELD_PARAM_ID_LEN 16 +#endif + + +//extern void mavlink_pm_queued_send(); +struct mavlink_pm_storage { + char param_names[MAVLINK_PM_MAX_PARAM_COUNT][MAVLINK_MSG_PARAM_VALUE_FIELD_PARAM_ID_LEN]; ///< Parameter names + float param_values[MAVLINK_PM_MAX_PARAM_COUNT]; ///< Parameter values + uint16_t next_param; + uint16_t size; +}; + +typedef struct mavlink_pm_storage mavlink_pm_storage; + +void mavlink_pm_reset_params(mavlink_pm_storage* pm); diff --git a/src/GCS_MAVLink/missionlib/mavlink_parameters.c b/src/GCS_MAVLink/missionlib/mavlink_parameters.c new file mode 100644 index 000000000..18a05b3ec --- /dev/null +++ b/src/GCS_MAVLink/missionlib/mavlink_parameters.c @@ -0,0 +1,150 @@ +/******************************************************************************* + + Copyright (C) 2011 Lorenz Meier lm ( a t ) inf.ethz.ch + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + + ****************************************************************************/ + +#include "mavlink_missionlib_data.h" +#include "mavlink_parameters.h" +#include "math.h" /* isinf / isnan checks */ + +extern mavlink_system_t mavlink_system; +extern mavlink_pm_storage pm; + +extern void mavlink_missionlib_send_message(mavlink_message_t* msg); +extern void mavlink_missionlib_send_gcs_string(const char* string); + +void mavlink_pm_message_handler(const mavlink_channel_t chan, const mavlink_message_t* msg) +{ + switch (msg->msgid) + { + case MAVLINK_MSG_ID_PARAM_REQUEST_LIST: + { + // Start sending parameters + pm.next_param = 0; + mavlink_missionlib_send_gcs_string("PM SENDING LIST"); + } + break; + case MAVLINK_MSG_ID_PARAM_SET: + { + mavlink_param_set_t set; + mavlink_msg_param_set_decode(msg, &set); + + // Check if this message is for this system + if (set.target_system == mavlink_system.sysid && set.target_component == mavlink_system.compid) + { + char* key = set.param_id; + + for (uint16_t i = 0; i < MAVLINK_MSG_PARAM_VALUE_FIELD_PARAM_ID_LEN; i++) + { + bool match = true; + for (uint16_t j = 0; j < MAVLINK_MSG_PARAM_VALUE_FIELD_PARAM_ID_LEN; j++) + { + // Compare + if (pm.param_names[i][j] != key[j]) + { + match = false; + } + + // End matching if null termination is reached + if (pm.param_names[i][j] == '\0') + { + break; + } + } + + // Check if matched + if (match) + { + // Only write and emit changes if there is actually a difference + // AND only write if new value is NOT "not-a-number" + // AND is NOT infinity + if (pm.param_values[i] != set.param_value + && !isnan(set.param_value) + && !isinf(set.param_value)) + { + pm.param_values[i] = set.param_value; + // Report back new value +#ifndef MAVLINK_USE_CONVENIENCE_FUNCTIONS + mavlink_message_t tx_msg; + mavlink_msg_param_value_pack_chan(mavlink_system.sysid, + mavlink_system.compid, + MAVLINK_COMM_0, + &tx_msg, + pm.param_names[i], + pm.param_values[i], + MAVLINK_TYPE_FLOAT, + pm.size, + i); + mavlink_missionlib_send_message(&tx_msg); +#else + mavlink_msg_param_value_send(MAVLINK_COMM_0, + pm.param_names[i], + pm.param_values[i], + MAVLINK_TYPE_FLOAT, + pm.size, + i); +#endif + + mavlink_missionlib_send_gcs_string("PM received param"); + } // End valid value check + } // End match check + } // End for loop + } // End system ID check + + } // End case + break; + + } // End switch + +} + + /** + * @brief Send low-priority messages at a maximum rate of xx Hertz + * + * This function sends messages at a lower rate to not exceed the wireless + * bandwidth. It sends one message each time it is called until the buffer is empty. + * Call this function with xx Hertz to increase/decrease the bandwidth. + */ + void mavlink_pm_queued_send(void) + { + //send parameters one by one + if (pm.next_param < pm.size) + { + //for (int i.. all active comm links) +#ifndef MAVLINK_USE_CONVENIENCE_FUNCTIONS + mavlink_message_t tx_msg; + mavlink_msg_param_value_pack_chan(mavlink_system.sysid, + mavlink_system.compid, + MAVLINK_COMM_0, + &tx_msg, + pm.param_names[pm.next_param], + pm.param_values[pm.next_param], + MAVLINK_TYPE_FLOAT, + pm.size, + pm.next_param); + mavlink_missionlib_send_message(&tx_msg); +#else + mavlink_msg_param_value_send(MAVLINK_COMM_0, + pm.param_names[pm.next_param], + pm.param_values[pm.next_param], + MAV_DATA_TYPE_FLOAT, + pm.size, + pm.next_param); +#endif + pm.next_param++; + } + } diff --git a/src/GCS_MAVLink/missionlib/mavlink_parameters.h b/src/GCS_MAVLink/missionlib/mavlink_parameters.h new file mode 100644 index 000000000..0d7841fcd --- /dev/null +++ b/src/GCS_MAVLink/missionlib/mavlink_parameters.h @@ -0,0 +1,38 @@ +/******************************************************************************* + + Copyright (C) 2011 Lorenz Meier lm ( a t ) inf.ethz.ch + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + + ****************************************************************************/ + +/* This assumes you have the mavlink headers on your include path + or in the same folder as this source file */ + +// Disable auto-data structures +#ifndef MAVLINK_NO_DATA +#define MAVLINK_NO_DATA +#endif + +#include "mavlink.h" +#include + +/* PARAMETER MANAGER - MISSION LIB */ + +#ifndef MAVLINK_PM_TEXT_FEEDBACK +#define MAVLINK_PM_TEXT_FEEDBACK 1 ///< Report back status information as text +#endif + +void mavlink_pm_message_handler(const mavlink_channel_t chan, const mavlink_message_t* msg); +void mavlink_pm_queued_send(void); \ No newline at end of file diff --git a/src/GCS_MAVLink/missionlib/testing/main.c b/src/GCS_MAVLink/missionlib/testing/main.c index 0bec1155a..21aa1f7e1 100644 --- a/src/GCS_MAVLink/missionlib/testing/main.c +++ b/src/GCS_MAVLink/missionlib/testing/main.c @@ -42,6 +42,7 @@ #include #include #include +#include #if (defined __QNX__) | (defined __QNXNTO__) /* QNX specific headers */ #include @@ -52,25 +53,54 @@ #include #endif +/* FIRST: MAVLink setup */ +//#define MAVLINK_CONFIGURED +//#define MAVLINK_NO_DATA +//#define MAVLINK_WPM_VERBOSE + /* 0: Include MAVLink types */ -#include <../mavlink_types.h> +#include "mavlink_types.h" /* 1: Define mavlink system storage */ mavlink_system_t mavlink_system; /* 2: Include actual protocol, REQUIRES mavlink_system */ -#include +#include "mavlink.h" /* 3: Define waypoint helper functions */ void mavlink_wpm_send_message(mavlink_message_t* msg); void mavlink_wpm_send_gcs_string(const char* string); uint64_t mavlink_wpm_get_system_timestamp(); +void mavlink_missionlib_send_message(mavlink_message_t* msg); +void mavlink_missionlib_send_gcs_string(const char* string); +uint64_t mavlink_missionlib_get_system_timestamp(); /* 4: Include waypoint protocol */ #include "waypoints.h" mavlink_wpm_storage wpm; +#include "mavlink_missionlib_data.h" +#include "mavlink_parameters.h" + +mavlink_pm_storage pm; + +/** + * @brief reset all parameters to default + * @warning DO NOT USE THIS IN FLIGHT! + */ +void mavlink_pm_reset_params(mavlink_pm_storage* pm) +{ + pm->size = MAVLINK_PM_MAX_PARAM_COUNT; + // 1) MAVLINK_PM_PARAM_SYSTEM_ID + pm->param_values[MAVLINK_PM_PARAM_SYSTEM_ID] = 12; + strcpy(pm->param_names[MAVLINK_PM_PARAM_SYSTEM_ID], "SYS_ID"); + // 2) MAVLINK_PM_PARAM_ATT_K_D + pm->param_values[MAVLINK_PM_PARAM_ATT_K_D] = 0.3f; + strcpy(pm->param_names[MAVLINK_PM_PARAM_ATT_K_D], "ATT_K_D"); +} + + #define BUFFER_LENGTH 2041 // minimum buffer size that can be used with qnx (I don't know why) char help[] = "--help"; @@ -101,35 +131,58 @@ uint64_t microsSinceEpoch(); /* * @brief Sends a MAVLink message over UDP */ -void mavlink_wpm_send_message(mavlink_message_t* msg) + +void mavlink_missionlib_send_message(mavlink_message_t* msg) { uint8_t buf[MAVLINK_MAX_PACKET_LEN]; uint16_t len = mavlink_msg_to_send_buffer(buf, msg); uint16_t bytes_sent = sendto(sock, buf, len, 0, (struct sockaddr*)&gcAddr, sizeof (struct sockaddr_in)); - printf("SENT %d bytes", bytes_sent); + printf("SENT %d bytes\n", bytes_sent); } -void mavlink_wpm_send_gcs_string(const char* string) +void mavlink_missionlib_send_gcs_string(const char* string) { - printf("%s",string); + const int len = 50; + mavlink_statustext_t status; + int i = 0; + while (i < len - 1) + { + status.text[i] = string[i]; + if (string[i] == '\0') + break; + i++; + } + status.text[i] = '\0'; // Enforce null termination + mavlink_message_t msg; + + mavlink_msg_statustext_encode(mavlink_system.sysid, mavlink_system.compid, &msg, &status); + mavlink_missionlib_send_message(&msg); } -uint64_t mavlink_wpm_get_system_timestamp() +uint64_t mavlink_missionlib_get_system_timestamp() { struct timeval tv; gettimeofday(&tv, NULL); return ((uint64_t)tv.tv_sec) * 1000000 + tv.tv_usec; } - +float roll, pitch, yaw; +uint32_t latitude, longitude, altitude; +uint16_t speedx, speedy, speedz; +float rollspeed, pitchspeed, yawspeed; +bool hilEnabled = false; int main(int argc, char* argv[]) { // Initialize MAVLink mavlink_wpm_init(&wpm); - mavlink_system.sysid = 1; - mavlink_system.compid = MAV_COMP_ID_WAYPOINTPLANNER; + mavlink_system.sysid = 5; + mavlink_system.compid = 20; + mavlink_pm_reset_params(&pm); + + int32_t ground_distance; + uint32_t time_ms; @@ -190,29 +243,46 @@ int main(int argc, char* argv[]) for (;;) { + bytes_sent = 0; - /*Send Heartbeat */ - mavlink_msg_heartbeat_pack(mavlink_system.sysid, 200, &msg, MAV_HELICOPTER, MAV_CLASS_GENERIC); + /* Send Heartbeat */ + mavlink_msg_heartbeat_pack(mavlink_system.sysid, 200, &msg, MAV_TYPE_HELICOPTER, MAV_AUTOPILOT_GENERIC, 0, 0, 0); len = mavlink_msg_to_send_buffer(buf, &msg); - bytes_sent = sendto(sock, buf, len, 0, (struct sockaddr*)&gcAddr, sizeof(struct sockaddr_in)); + bytes_sent += sendto(sock, buf, len, 0, (struct sockaddr*)&gcAddr, sizeof(struct sockaddr_in)); /* Send Status */ - mavlink_msg_sys_status_pack(1, 200, &msg, MAV_MODE_GUIDED, MAV_NAV_HOLD, MAV_STATE_ACTIVE, 500, 7500, 0, 0); + mavlink_msg_sys_status_pack(1, 200, &msg, MAV_MODE_GUIDED_ARMED, 0, MAV_STATE_ACTIVE, 500, 7500, 0, 0, 0, 0, 0, 0, 0, 0); len = mavlink_msg_to_send_buffer(buf, &msg); - bytes_sent = sendto(sock, buf, len, 0, (struct sockaddr*)&gcAddr, sizeof (struct sockaddr_in)); + bytes_sent += sendto(sock, buf, len, 0, (struct sockaddr*)&gcAddr, sizeof (struct sockaddr_in)); /* Send Local Position */ - mavlink_msg_local_position_pack(mavlink_system.sysid, 200, &msg, microsSinceEpoch(), + mavlink_msg_local_position_ned_pack(mavlink_system.sysid, 200, &msg, microsSinceEpoch(), position[0], position[1], position[2], position[3], position[4], position[5]); len = mavlink_msg_to_send_buffer(buf, &msg); - bytes_sent = sendto(sock, buf, len, 0, (struct sockaddr*)&gcAddr, sizeof(struct sockaddr_in)); + bytes_sent += sendto(sock, buf, len, 0, (struct sockaddr*)&gcAddr, sizeof(struct sockaddr_in)); + + /* Send global position */ + if (hilEnabled) + { + mavlink_msg_global_position_int_pack(mavlink_system.sysid, 200, &msg, time_ms, latitude, longitude, altitude, ground_distance, speedx, speedy, speedz, (yaw/M_PI)*180*100); + len = mavlink_msg_to_send_buffer(buf, &msg); + bytes_sent += sendto(sock, buf, len, 0, (struct sockaddr*)&gcAddr, sizeof(struct sockaddr_in)); + } /* Send attitude */ - mavlink_msg_attitude_pack(mavlink_system.sysid, 200, &msg, microsSinceEpoch(), 1.2, 1.7, 3.14, 0.01, 0.02, 0.03); + mavlink_msg_attitude_pack(mavlink_system.sysid, 200, &msg, microsSinceEpoch(), roll, pitch, yaw, rollspeed, pitchspeed, yawspeed); len = mavlink_msg_to_send_buffer(buf, &msg); - bytes_sent = sendto(sock, buf, len, 0, (struct sockaddr*)&gcAddr, sizeof(struct sockaddr_in)); + bytes_sent += sendto(sock, buf, len, 0, (struct sockaddr*)&gcAddr, sizeof(struct sockaddr_in)); + /* Send HIL outputs */ + float roll_ailerons = 0; // -1 .. 1 + float pitch_elevator = 0.2; // -1 .. 1 + float yaw_rudder = 0.1; // -1 .. 1 + float throttle = 0.9; // 0 .. 1 + mavlink_msg_hil_controls_pack_chan(mavlink_system.sysid, mavlink_system.compid, MAVLINK_COMM_0, &msg, microsSinceEpoch(), roll_ailerons, pitch_elevator, yaw_rudder, throttle, mavlink_system.mode, mavlink_system.nav_mode, 0, 0, 0, 0); + len = mavlink_msg_to_send_buffer(buf, &msg); + bytes_sent += sendto(sock, buf, len, 0, (struct sockaddr*)&gcAddr, sizeof(struct sockaddr_in)); memset(buf, 0, BUFFER_LENGTH); recsize = recvfrom(sock, (void *)buf, BUFFER_LENGTH, 0, (struct sockaddr *)&gcAddr, &fromlen); @@ -236,12 +306,39 @@ int main(int argc, char* argv[]) mavlink_wpm_message_handler(&msg); // Handle packet with parameter component + mavlink_pm_message_handler(MAVLINK_COMM_0, &msg); + + // Print HIL values sent to system + if (msg.msgid == MAVLINK_MSG_ID_HIL_STATE) + { + mavlink_hil_state_t hil; + mavlink_msg_hil_state_decode(&msg, &hil); + printf("Received HIL state:\n"); + printf("R: %f P: %f Y: %f\n", hil.roll, hil.pitch, hil.yaw); + roll = hil.roll; + pitch = hil.pitch; + yaw = hil.yaw; + rollspeed = hil.rollspeed; + pitchspeed = hil.pitchspeed; + yawspeed = hil.yawspeed; + speedx = hil.vx; + speedy = hil.vy; + speedz = hil.vz; + latitude = hil.lat; + longitude = hil.lon; + altitude = hil.alt; + hilEnabled = true; + } } } printf("\n"); } memset(buf, 0, BUFFER_LENGTH); - usleep(50000); // Sleep one second + usleep(10000); // Sleep 10 ms + + + // Send one parameter + mavlink_pm_queued_send(); } } diff --git a/src/GCS_MAVLink/missionlib/testing/mavlink_missionlib_data.h b/src/GCS_MAVLink/missionlib/testing/mavlink_missionlib_data.h new file mode 100644 index 000000000..a040941e2 --- /dev/null +++ b/src/GCS_MAVLink/missionlib/testing/mavlink_missionlib_data.h @@ -0,0 +1,54 @@ +/******************************************************************************* + + Copyright (C) 2011 Lorenz Meier lm ( a t ) inf.ethz.ch + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + + ****************************************************************************/ + +/* This assumes you have the mavlink headers on your include path + or in the same folder as this source file */ + +// Disable auto-data structures +#ifndef MAVLINK_NO_DATA +#define MAVLINK_NO_DATA +#endif + +#include "mavlink.h" +#include + +/* MISSION LIB DATA STORAGE */ + +enum MAVLINK_PM_PARAMETERS +{ + MAVLINK_PM_PARAM_SYSTEM_ID, + MAVLINK_PM_PARAM_ATT_K_D, + MAVLINK_PM_MAX_PARAM_COUNT // VERY IMPORTANT! KEEP THIS AS LAST ENTRY +}; + + +/* DO NOT EDIT THIS FILE BELOW THIS POINT! */ + + +//extern void mavlink_pm_queued_send(); +struct mavlink_pm_storage { + char param_names[MAVLINK_PM_MAX_PARAM_COUNT][MAVLINK_MSG_PARAM_VALUE_FIELD_PARAM_ID_LEN]; ///< Parameter names + float param_values[MAVLINK_PM_MAX_PARAM_COUNT]; ///< Parameter values + uint16_t next_param; + uint16_t size; +}; + +typedef struct mavlink_pm_storage mavlink_pm_storage; + +void mavlink_pm_reset_params(mavlink_pm_storage* pm); \ No newline at end of file diff --git a/src/GCS_MAVLink/missionlib/testing/udptest.xcodeproj/project.pbxproj b/src/GCS_MAVLink/missionlib/testing/udptest.xcodeproj/project.pbxproj index ba27d2f32..7bc76570d 100644 --- a/src/GCS_MAVLink/missionlib/testing/udptest.xcodeproj/project.pbxproj +++ b/src/GCS_MAVLink/missionlib/testing/udptest.xcodeproj/project.pbxproj @@ -7,9 +7,9 @@ objects = { /* Begin PBXBuildFile section */ + 348868D013F512010005F759 /* mavlink_parameters.c in Sources */ = {isa = PBXBuildFile; fileRef = 348868CF13F512010005F759 /* mavlink_parameters.c */; }; 34E8AFDB13F5064C001100AA /* waypoints.c in Sources */ = {isa = PBXBuildFile; fileRef = 34E8AFDA13F5064C001100AA /* waypoints.c */; }; 8DD76FAC0486AB0100D96B5E /* main.c in Sources */ = {isa = PBXBuildFile; fileRef = 08FB7796FE84155DC02AAC07 /* main.c */; settings = {ATTRIBUTES = (); }; }; - 8DD76FB00486AB0100D96B5E /* udptest.1 in CopyFiles */ = {isa = PBXBuildFile; fileRef = C6A0FF2C0290799A04C91782 /* udptest.1 */; }; /* End PBXBuildFile section */ /* Begin PBXCopyFilesBuildPhase section */ @@ -19,7 +19,6 @@ dstPath = /usr/share/man/man1/; dstSubfolderSpec = 0; files = ( - 8DD76FB00486AB0100D96B5E /* udptest.1 in CopyFiles */, ); runOnlyForDeploymentPostprocessing = 1; }; @@ -27,10 +26,11 @@ /* Begin PBXFileReference section */ 08FB7796FE84155DC02AAC07 /* main.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = main.c; sourceTree = ""; }; + 348868CF13F512010005F759 /* mavlink_parameters.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = mavlink_parameters.c; path = ../mavlink_parameters.c; sourceTree = SOURCE_ROOT; }; + 348868D113F512080005F759 /* mavlink_parameters.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = mavlink_parameters.h; path = ../mavlink_parameters.h; sourceTree = SOURCE_ROOT; }; 34E8AFDA13F5064C001100AA /* waypoints.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = waypoints.c; path = ../waypoints.c; sourceTree = SOURCE_ROOT; }; 34E8AFDC13F50659001100AA /* waypoints.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = waypoints.h; path = ../waypoints.h; sourceTree = SOURCE_ROOT; }; 8DD76FB20486AB0100D96B5E /* udptest */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = udptest; sourceTree = BUILT_PRODUCTS_DIR; }; - C6A0FF2C0290799A04C91782 /* udptest.1 */ = {isa = PBXFileReference; lastKnownFileType = text.man; path = udptest.1; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -58,6 +58,8 @@ 08FB7795FE84155DC02AAC07 /* Source */ = { isa = PBXGroup; children = ( + 348868D113F512080005F759 /* mavlink_parameters.h */, + 348868CF13F512010005F759 /* mavlink_parameters.c */, 34E8AFDA13F5064C001100AA /* waypoints.c */, 08FB7796FE84155DC02AAC07 /* main.c */, ); @@ -75,7 +77,6 @@ C6A0FF2B0290797F04C91782 /* Documentation */ = { isa = PBXGroup; children = ( - C6A0FF2C0290799A04C91782 /* udptest.1 */, ); name = Documentation; sourceTree = ""; @@ -132,6 +133,7 @@ files = ( 8DD76FAC0486AB0100D96B5E /* main.c in Sources */, 34E8AFDB13F5064C001100AA /* waypoints.c in Sources */, + 348868D013F512010005F759 /* mavlink_parameters.c in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -171,7 +173,10 @@ GCC_OPTIMIZATION_LEVEL = 0; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; - HEADER_SEARCH_PATHS = ../../include/common/; + HEADER_SEARCH_PATHS = ( + ../../include/, + ../../include/common/, + ); ONLY_ACTIVE_ARCH = YES; PREBINDING = NO; SDKROOT = macosx10.6; diff --git a/src/GCS_MAVLink/missionlib/waypoints.c b/src/GCS_MAVLink/missionlib/waypoints.c index a7b8ee5f5..44bddb6f5 100644 --- a/src/GCS_MAVLink/missionlib/waypoints.c +++ b/src/GCS_MAVLink/missionlib/waypoints.c @@ -23,16 +23,20 @@ bool debug = true; bool verbose = true; -extern mavlink_system_t mavlink_system; extern mavlink_wpm_storage wpm; -extern void mavlink_wpm_send_message(mavlink_message_t* msg); -extern void mavlink_wpm_send_gcs_string(const char* string); -extern uint64_t mavlink_wpm_get_system_timestamp(); +extern void mavlink_missionlib_send_message(mavlink_message_t* msg); +extern void mavlink_missionlib_send_gcs_string(const char* string); +extern uint64_t mavlink_missionlib_get_system_timestamp(); +extern void mavlink_missionlib_current_waypoint_changed(uint16_t index, float param1, + float param2, float param3, float param4, float param5_lat_x, + float param6_lon_y, float param7_alt_z, uint8_t frame, uint16_t command); #define MAVLINK_WPM_NO_PRINTF +uint8_t mavlink_wpm_comp_id = MAV_COMP_ID_MISSIONPLANNER; + void mavlink_wpm_init(mavlink_wpm_storage* state) { // Set all waypoints to zero @@ -62,25 +66,25 @@ void mavlink_wpm_init(mavlink_wpm_storage* state) void mavlink_wpm_send_waypoint_ack(uint8_t sysid, uint8_t compid, uint8_t type) { mavlink_message_t msg; - mavlink_waypoint_ack_t wpa; + mavlink_mission_ack_t wpa; wpa.target_system = wpm.current_partner_sysid; wpa.target_component = wpm.current_partner_compid; wpa.type = type; - mavlink_msg_waypoint_ack_encode(mavlink_system.sysid, mavlink_system.compid, &msg, &wpa); - mavlink_wpm_send_message(&msg); + mavlink_msg_mission_ack_encode(mavlink_system.sysid, mavlink_wpm_comp_id, &msg, &wpa); + mavlink_missionlib_send_message(&msg); // FIXME TIMING usleep(paramClient->getParamValue("PROTOCOLDELAY")); if (MAVLINK_WPM_TEXT_FEEDBACK) { #ifdef MAVLINK_WPM_NO_PRINTF - mavlink_wpm_send_gcs_string("Sent waypoint ACK"); + mavlink_missionlib_send_gcs_string("Sent waypoint ACK"); #else if (MAVLINK_WPM_VERBOSE) printf("Sent waypoint ack (%u) to ID %u\n", wpa.type, wpa.target_system); #endif - mavlink_wpm_send_gcs_string("Sent waypoint ACK"); + mavlink_missionlib_send_gcs_string("Sent waypoint ACK"); } } @@ -97,23 +101,23 @@ void mavlink_wpm_send_waypoint_current(uint16_t seq) { if(seq < wpm.size) { - mavlink_waypoint_t *cur = &(wpm.waypoints[seq]); + mavlink_mission_item_t *cur = &(wpm.waypoints[seq]); mavlink_message_t msg; - mavlink_waypoint_current_t wpc; + mavlink_mission_current_t wpc; wpc.seq = cur->seq; - mavlink_msg_waypoint_current_encode(mavlink_system.sysid, mavlink_system.compid, &msg, &wpc); - mavlink_wpm_send_message(&msg); + mavlink_msg_mission_current_encode(mavlink_system.sysid, mavlink_wpm_comp_id, &msg, &wpc); + mavlink_missionlib_send_message(&msg); // FIXME TIMING usleep(paramClient->getParamValue("PROTOCOLDELAY")); - if (MAVLINK_WPM_TEXT_FEEDBACK) mavlink_wpm_send_gcs_string("Broadcasted new current waypoint\n"); //// printf("Broadcasted new current waypoint %u\n", wpc.seq); + if (MAVLINK_WPM_TEXT_FEEDBACK) mavlink_missionlib_send_gcs_string("Set current waypoint\n"); //// printf("Broadcasted new current waypoint %u\n", wpc.seq); } else { - if (MAVLINK_WPM_TEXT_FEEDBACK) mavlink_wpm_send_gcs_string("ERROR: index out of bounds\n"); + if (MAVLINK_WPM_TEXT_FEEDBACK) mavlink_missionlib_send_gcs_string("ERROR: wp index out of bounds\n"); } } @@ -129,52 +133,32 @@ void mavlink_wpm_send_setpoint(uint16_t seq) { if(seq < wpm.size) { - mavlink_waypoint_t *cur = &(wpm.waypoints[seq]); - - mavlink_message_t msg; - mavlink_local_position_setpoint_set_t position_control_set_point; - - // Send new NED or ENU setpoint to onbaord autopilot - if (cur->frame == MAV_FRAME_LOCAL_NED || cur->frame == MAV_FRAME_LOCAL_ENU) - { - position_control_set_point.target_system = mavlink_system.sysid; - position_control_set_point.target_component = MAV_COMP_ID_IMU; - position_control_set_point.x = cur->x; - position_control_set_point.y = cur->y; - position_control_set_point.z = cur->z; - position_control_set_point.yaw = cur->param4; - - mavlink_msg_local_position_setpoint_set_encode(mavlink_system.sysid, mavlink_system.compid, &msg, &position_control_set_point); - mavlink_wpm_send_message(&msg); - - // FIXME TIMING usleep(paramClient->getParamValue("PROTOCOLDELAY")); - } - else - { - if (MAVLINK_WPM_TEXT_FEEDBACK) mavlink_wpm_send_gcs_string("No new setpoint set because of invalid coordinate frame of waypoint");//// if (verbose) // printf("No new set point sent to IMU because the new waypoint %u had no local coordinates\n", cur->seq); - } - - wpm.timestamp_last_send_setpoint = mavlink_wpm_get_system_timestamp(); + mavlink_mission_item_t *cur = &(wpm.waypoints[seq]); + mavlink_missionlib_current_waypoint_changed(cur->seq, cur->param1, + cur->param2, cur->param3, cur->param4, cur->x, + cur->y, cur->z, cur->frame, cur->command); + + wpm.timestamp_last_send_setpoint = mavlink_missionlib_get_system_timestamp(); } else { - if (MAVLINK_WPM_TEXT_FEEDBACK) mavlink_wpm_send_gcs_string("ERROR: Waypoint index out of bounds\n"); //// if (verbose) // printf("ERROR: index out of bounds\n"); + if (MAVLINK_WPM_TEXT_FEEDBACK) mavlink_missionlib_send_gcs_string("ERROR: Waypoint index out of bounds\n"); //// if (verbose) // printf("ERROR: index out of bounds\n"); } } void mavlink_wpm_send_waypoint_count(uint8_t sysid, uint8_t compid, uint16_t count) { mavlink_message_t msg; - mavlink_waypoint_count_t wpc; + mavlink_mission_count_t wpc; wpc.target_system = wpm.current_partner_sysid; wpc.target_component = wpm.current_partner_compid; wpc.count = count; - mavlink_msg_waypoint_count_encode(mavlink_system.sysid, mavlink_system.compid, &msg, &wpc); - mavlink_wpm_send_message(&msg); + mavlink_msg_mission_count_encode(mavlink_system.sysid, mavlink_wpm_comp_id, &msg, &wpc); + mavlink_missionlib_send_message(&msg); - if (MAVLINK_WPM_TEXT_FEEDBACK) mavlink_wpm_send_gcs_string("Sent waypoint count"); //// if (verbose) // printf("Sent waypoint count (%u) to ID %u\n", wpc.count, wpc.target_system); + if (MAVLINK_WPM_TEXT_FEEDBACK) mavlink_missionlib_send_gcs_string("Sent waypoint count"); //// if (verbose) // printf("Sent waypoint count (%u) to ID %u\n", wpc.count, wpc.target_system); // FIXME TIMING usleep(paramClient->getParamValue("PROTOCOLDELAY")); } @@ -184,18 +168,18 @@ void mavlink_wpm_send_waypoint(uint8_t sysid, uint8_t compid, uint16_t seq) if (seq < wpm.size) { mavlink_message_t msg; - mavlink_waypoint_t *wp = &(wpm.waypoints[seq]); + mavlink_mission_item_t *wp = &(wpm.waypoints[seq]); wp->target_system = wpm.current_partner_sysid; wp->target_component = wpm.current_partner_compid; - mavlink_msg_waypoint_encode(mavlink_system.sysid, mavlink_system.compid, &msg, wp); - mavlink_wpm_send_message(&msg); - if (MAVLINK_WPM_TEXT_FEEDBACK) mavlink_wpm_send_gcs_string("Sent waypoint"); //// if (verbose) // printf("Sent waypoint %u to ID %u\n", wp->seq, wp->target_system); + mavlink_msg_mission_item_encode(mavlink_system.sysid, mavlink_wpm_comp_id, &msg, wp); + mavlink_missionlib_send_message(&msg); + if (MAVLINK_WPM_TEXT_FEEDBACK) mavlink_missionlib_send_gcs_string("Sent waypoint"); //// if (verbose) // printf("Sent waypoint %u to ID %u\n", wp->seq, wp->target_system); // FIXME TIMING usleep(paramClient->getParamValue("PROTOCOLDELAY")); } else { - if (MAVLINK_WPM_TEXT_FEEDBACK) mavlink_wpm_send_gcs_string("ERROR: Waypoint index out of bounds\n"); + if (MAVLINK_WPM_TEXT_FEEDBACK) mavlink_missionlib_send_gcs_string("ERROR: Waypoint index out of bounds\n"); } } @@ -204,19 +188,19 @@ void mavlink_wpm_send_waypoint_request(uint8_t sysid, uint8_t compid, uint16_t s if (seq < wpm.max_size) { mavlink_message_t msg; - mavlink_waypoint_request_t wpr; + mavlink_mission_request_t wpr; wpr.target_system = wpm.current_partner_sysid; wpr.target_component = wpm.current_partner_compid; wpr.seq = seq; - mavlink_msg_waypoint_request_encode(mavlink_system.sysid, mavlink_system.compid, &msg, &wpr); - mavlink_wpm_send_message(&msg); - if (MAVLINK_WPM_TEXT_FEEDBACK) mavlink_wpm_send_gcs_string("Sent waypoint request"); //// if (verbose) // printf("Sent waypoint request %u to ID %u\n", wpr.seq, wpr.target_system); + mavlink_msg_mission_request_encode(mavlink_system.sysid, mavlink_wpm_comp_id, &msg, &wpr); + mavlink_missionlib_send_message(&msg); + if (MAVLINK_WPM_TEXT_FEEDBACK) mavlink_missionlib_send_gcs_string("Sent waypoint request"); //// if (verbose) // printf("Sent waypoint request %u to ID %u\n", wpr.seq, wpr.target_system); // FIXME TIMING usleep(paramClient->getParamValue("PROTOCOLDELAY")); } else { - if (MAVLINK_WPM_TEXT_FEEDBACK) mavlink_wpm_send_gcs_string("ERROR: Waypoint index exceeds list capacity\n"); + if (MAVLINK_WPM_TEXT_FEEDBACK) mavlink_missionlib_send_gcs_string("ERROR: Waypoint index exceeds list capacity\n"); } } @@ -230,14 +214,14 @@ void mavlink_wpm_send_waypoint_request(uint8_t sysid, uint8_t compid, uint16_t s void mavlink_wpm_send_waypoint_reached(uint16_t seq) { mavlink_message_t msg; - mavlink_waypoint_reached_t wp_reached; + mavlink_mission_item_reached_t wp_reached; wp_reached.seq = seq; - mavlink_msg_waypoint_reached_encode(mavlink_system.sysid, mavlink_system.compid, &msg, &wp_reached); - mavlink_wpm_send_message(&msg); + mavlink_msg_mission_item_reached_encode(mavlink_system.sysid, mavlink_wpm_comp_id, &msg, &wp_reached); + mavlink_missionlib_send_message(&msg); - if (MAVLINK_WPM_TEXT_FEEDBACK) mavlink_wpm_send_gcs_string("Sent waypoint reached message"); //// if (verbose) // printf("Sent waypoint %u reached message\n", wp_reached.seq); + if (MAVLINK_WPM_TEXT_FEEDBACK) mavlink_missionlib_send_gcs_string("Sent waypoint reached message"); //// if (verbose) // printf("Sent waypoint %u reached message\n", wp_reached.seq); // FIXME TIMING usleep(paramClient->getParamValue("PROTOCOLDELAY")); } @@ -246,7 +230,7 @@ void mavlink_wpm_send_waypoint_reached(uint16_t seq) //{ // if (seq < wpm.size) // { -// mavlink_waypoint_t *cur = waypoints->at(seq); +// mavlink_mission_item_t *cur = waypoints->at(seq); // // const PxVector3 A(cur->x, cur->y, cur->z); // const PxVector3 C(x, y, z); @@ -254,7 +238,7 @@ void mavlink_wpm_send_waypoint_reached(uint16_t seq) // // seq not the second last waypoint // if ((uint16_t)(seq+1) < wpm.size) // { -// mavlink_waypoint_t *next = waypoints->at(seq+1); +// mavlink_mission_item_t *next = waypoints->at(seq+1); // const PxVector3 B(next->x, next->y, next->z); // const float r = (B-A).dot(C-A) / (B-A).lengthSquared(); // if (r >= 0 && r <= 1) @@ -285,34 +269,30 @@ void mavlink_wpm_send_waypoint_reached(uint16_t seq) float mavlink_wpm_distance_to_point(uint16_t seq, float x, float y, float z) { - // if (seq < wpm.size) - // { - // mavlink_waypoint_t *cur = waypoints->at(seq); - // - // const PxVector3 A(cur->x, cur->y, cur->z); - // const PxVector3 C(x, y, z); - // - // return (C-A).length(); - // } - // else - // { - // // if (verbose) // printf("ERROR: index out of bounds\n"); - // } +// if (seq < wpm.size) +// { +// mavlink_mission_item_t *cur = waypoints->at(seq); +// +// const PxVector3 A(cur->x, cur->y, cur->z); +// const PxVector3 C(x, y, z); +// +// return (C-A).length(); +// } +// else +// { +// // if (verbose) // printf("ERROR: index out of bounds\n"); +// } return -1.f; } - -void mavlink_wpm_message_handler(const mavlink_message_t* msg) +void mavlink_wpm_loop() { - // Handle param messages - //paramClient->handleMAVLinkPacket(msg); - //check for timed-out operations - uint64_t now = mavlink_wpm_get_system_timestamp(); + uint64_t now = mavlink_missionlib_get_system_timestamp(); if (now-wpm.timestamp_lastaction > wpm.timeout && wpm.current_state != MAVLINK_WPM_STATE_IDLE) { #ifdef MAVLINK_WPM_NO_PRINTF - mavlink_wpm_send_gcs_string("Operation timeout switching -> IDLE"); + mavlink_missionlib_send_gcs_string("Operation timeout switching -> IDLE"); #else if (MAVLINK_WPM_VERBOSE) printf("Last operation (state=%u) timed out, changing state to MAVLINK_WPM_STATE_IDLE\n", wpm.current_state); #endif @@ -332,14 +312,18 @@ void mavlink_wpm_message_handler(const mavlink_message_t* msg) { mavlink_wpm_send_setpoint(wpm.current_active_wp_id); } - +} + +void mavlink_wpm_message_handler(const mavlink_message_t* msg) +{ + uint64_t now = mavlink_missionlib_get_system_timestamp(); switch(msg->msgid) { case MAVLINK_MSG_ID_ATTITUDE: { if(msg->sysid == mavlink_system.sysid && wpm.current_active_wp_id < wpm.size) { - mavlink_waypoint_t *wp = &(wpm.waypoints[wpm.current_active_wp_id]); + mavlink_mission_item_t *wp = &(wpm.waypoints[wpm.current_active_wp_id]); if(wp->frame == MAV_FRAME_LOCAL_ENU || wp->frame == MAV_FRAME_LOCAL_NED) { mavlink_attitude_t att; @@ -368,16 +352,16 @@ void mavlink_wpm_message_handler(const mavlink_message_t* msg) break; } - case MAVLINK_MSG_ID_LOCAL_POSITION: + case MAVLINK_MSG_ID_LOCAL_POSITION_NED: { if(msg->sysid == mavlink_system.sysid && wpm.current_active_wp_id < wpm.size) { - mavlink_waypoint_t *wp = &(wpm.waypoints[wpm.current_active_wp_id]); + mavlink_mission_item_t *wp = &(wpm.waypoints[wpm.current_active_wp_id]); if(wp->frame == MAV_FRAME_LOCAL_ENU || MAV_FRAME_LOCAL_NED) { - mavlink_local_position_t pos; - mavlink_msg_local_position_decode(msg, &pos); + mavlink_local_position_ned_t pos; + mavlink_msg_local_position_ned_decode(msg, &pos); //// if (debug) // printf("Received new position: x: %f | y: %f | z: %f\n", pos.x, pos.y, pos.z); wpm.pos_reached = false; @@ -386,15 +370,15 @@ void mavlink_wpm_message_handler(const mavlink_message_t* msg) float orbit = wp->param1; float dist; - if (wp->param2 == 0) - { - // FIXME segment distance - //dist = mavlink_wpm_distance_to_segment(current_active_wp_id, pos.x, pos.y, pos.z); - } - else - { +// if (wp->param2 == 0) +// { +// // FIXME segment distance +// //dist = mavlink_wpm_distance_to_segment(current_active_wp_id, pos.x, pos.y, pos.z); +// } +// else +// { dist = mavlink_wpm_distance_to_point(wpm.current_active_wp_id, pos.x, pos.y, pos.z); - } +// } if (dist >= 0.f && dist <= orbit && wpm.yaw_reached) { @@ -405,52 +389,52 @@ void mavlink_wpm_message_handler(const mavlink_message_t* msg) break; } - // case MAVLINK_MSG_ID_CMD: // special action from ground station - // { - // mavlink_cmd_t action; - // mavlink_msg_cmd_decode(msg, &action); - // if(action.target == mavlink_system.sysid) - // { - // // if (verbose) std::cerr << "Waypoint: received message with action " << action.action << std::endl; - // switch (action.action) - // { - // // case MAV_ACTION_LAUNCH: - // // // if (verbose) std::cerr << "Launch received" << std::endl; - // // current_active_wp_id = 0; - // // if (wpm.size>0) - // // { - // // setActive(waypoints[current_active_wp_id]); - // // } - // // else - // // // if (verbose) std::cerr << "No launch, waypointList empty" << std::endl; - // // break; - // - // // case MAV_ACTION_CONTINUE: - // // // if (verbose) std::c - // // err << "Continue received" << std::endl; - // // idle = false; - // // setActive(waypoints[current_active_wp_id]); - // // break; - // - // // case MAV_ACTION_HALT: - // // // if (verbose) std::cerr << "Halt received" << std::endl; - // // idle = true; - // // break; - // - // // default: - // // // if (verbose) std::cerr << "Unknown action received with id " << action.action << ", no action taken" << std::endl; - // // break; - // } - // } - // break; - // } +// case MAVLINK_MSG_ID_CMD: // special action from ground station +// { +// mavlink_cmd_t action; +// mavlink_msg_cmd_decode(msg, &action); +// if(action.target == mavlink_system.sysid) +// { +// // if (verbose) std::cerr << "Waypoint: received message with action " << action.action << std::endl; +// switch (action.action) +// { +// // case MAV_ACTION_LAUNCH: +// // // if (verbose) std::cerr << "Launch received" << std::endl; +// // current_active_wp_id = 0; +// // if (wpm.size>0) +// // { +// // setActive(waypoints[current_active_wp_id]); +// // } +// // else +// // // if (verbose) std::cerr << "No launch, waypointList empty" << std::endl; +// // break; +// +// // case MAV_ACTION_CONTINUE: +// // // if (verbose) std::c +// // err << "Continue received" << std::endl; +// // idle = false; +// // setActive(waypoints[current_active_wp_id]); +// // break; +// +// // case MAV_ACTION_HALT: +// // // if (verbose) std::cerr << "Halt received" << std::endl; +// // idle = true; +// // break; +// +// // default: +// // // if (verbose) std::cerr << "Unknown action received with id " << action.action << ", no action taken" << std::endl; +// // break; +// } +// } +// break; +// } - case MAVLINK_MSG_ID_WAYPOINT_ACK: + case MAVLINK_MSG_ID_MISSION_ACK: { - mavlink_waypoint_ack_t wpa; - mavlink_msg_waypoint_ack_decode(msg, &wpa); + mavlink_mission_ack_t wpa; + mavlink_msg_mission_ack_decode(msg, &wpa); - if((msg->sysid == wpm.current_partner_sysid && msg->compid == wpm.current_partner_compid) && (wpa.target_system == mavlink_system.sysid /*&& wpa.target_component == mavlink_system.compid*/)) + if((msg->sysid == wpm.current_partner_sysid && msg->compid == wpm.current_partner_compid) && (wpa.target_system == mavlink_system.sysid /*&& wpa.target_component == mavlink_wpm_comp_id*/)) { wpm.timestamp_lastaction = now; @@ -459,9 +443,9 @@ void mavlink_wpm_message_handler(const mavlink_message_t* msg) if (wpm.current_wp_id == wpm.size-1) { #ifdef MAVLINK_WPM_NO_PRINTF - mavlink_wpm_send_gcs_string("Got last WP ACK state -> IDLE"); + mavlink_missionlib_send_gcs_string("Got last WP ACK state -> IDLE"); #else - if (MAVLINK_WPM_VERBOSE) printf("Received ACK after having sent last waypoint, going to state MAVLINK_WPM_STATE_IDLE\n"); + if (MAVLINK_WPM_VERBOSE) printf("Received ACK after having sent last waypoint, going to state MAVLINK_WPM_STATE_IDLE\n"); #endif wpm.current_state = MAVLINK_WPM_STATE_IDLE; wpm.current_wp_id = 0; @@ -471,20 +455,20 @@ void mavlink_wpm_message_handler(const mavlink_message_t* msg) else { #ifdef MAVLINK_WPM_NO_PRINTF - mavlink_wpm_send_gcs_string("REJ. WP CMD: curr partner id mismatch"); + mavlink_missionlib_send_gcs_string("REJ. WP CMD: curr partner id mismatch"); #else - if (MAVLINK_WPM_VERBOSE) printf("IGNORED WAYPOINT COMMAND BECAUSE TARGET SYSTEM AND COMPONENT OR COMM PARTNER ID MISMATCH\n"); + if (MAVLINK_WPM_VERBOSE) printf("IGNORED WAYPOINT COMMAND BECAUSE TARGET SYSTEM AND COMPONENT OR COMM PARTNER ID MISMATCH\n"); #endif } break; } - case MAVLINK_MSG_ID_WAYPOINT_SET_CURRENT: + case MAVLINK_MSG_ID_MISSION_SET_CURRENT: { - mavlink_waypoint_set_current_t wpc; - mavlink_msg_waypoint_set_current_decode(msg, &wpc); + mavlink_mission_set_current_t wpc; + mavlink_msg_mission_set_current_decode(msg, &wpc); - if(wpc.target_system == mavlink_system.sysid /*&& wpc.target_component == mavlink_system.compid*/) + if(wpc.target_system == mavlink_system.sysid /*&& wpc.target_component == mavlink_wpm_comp_id*/) { wpm.timestamp_lastaction = now; @@ -492,7 +476,7 @@ void mavlink_wpm_message_handler(const mavlink_message_t* msg) { if (wpc.seq < wpm.size) { - // if (verbose) // printf("Received MAVLINK_MSG_ID_WAYPOINT_SET_CURRENT\n"); + // if (verbose) // printf("Received MAVLINK_MSG_ID_MISSION_ITEM_SET_CURRENT\n"); wpm.current_active_wp_id = wpc.seq; uint32_t i; for(i = 0; i < wpm.size; i++) @@ -507,9 +491,9 @@ void mavlink_wpm_message_handler(const mavlink_message_t* msg) } } #ifdef MAVLINK_WPM_NO_PRINTF - mavlink_wpm_send_gcs_string("NEW WP SET"); + mavlink_missionlib_send_gcs_string("NEW WP SET"); #else - if (MAVLINK_WPM_VERBOSE) printf("New current waypoint %u\n", wpm.current_active_wp_id); + if (MAVLINK_WPM_VERBOSE) printf("New current waypoint %u\n", wpm.current_active_wp_id); #endif wpm.yaw_reached = false; wpm.pos_reached = false; @@ -520,37 +504,37 @@ void mavlink_wpm_message_handler(const mavlink_message_t* msg) else { #ifdef MAVLINK_WPM_NO_PRINTF - mavlink_wpm_send_gcs_string("IGN WP CURR CMD: Not in list"); + mavlink_missionlib_send_gcs_string("IGN WP CURR CMD: Not in list"); #else - if (MAVLINK_WPM_VERBOSE) printf("Ignored MAVLINK_MSG_ID_WAYPOINT_SET_CURRENT: Index out of bounds\n"); + if (MAVLINK_WPM_VERBOSE) printf("Ignored MAVLINK_MSG_ID_MISSION_ITEM_SET_CURRENT: Index out of bounds\n"); #endif } } else { #ifdef MAVLINK_WPM_NO_PRINTF - mavlink_wpm_send_gcs_string("IGN WP CURR CMD: Busy"); + mavlink_missionlib_send_gcs_string("IGN WP CURR CMD: Busy"); #else - if (MAVLINK_WPM_VERBOSE) printf("IGNORED WAYPOINT COMMAND BECAUSE NOT IN IDLE STATE\n"); + if (MAVLINK_WPM_VERBOSE) printf("IGNORED WAYPOINT COMMAND BECAUSE NOT IN IDLE STATE\n"); #endif } } else { #ifdef MAVLINK_WPM_NO_PRINTF - mavlink_wpm_send_gcs_string("REJ. WP CMD: target id mismatch"); + mavlink_missionlib_send_gcs_string("REJ. WP CMD: target id mismatch"); #else - if (MAVLINK_WPM_VERBOSE) printf("IGNORED WAYPOINT COMMAND BECAUSE TARGET SYSTEM AND COMPONENT OR COMM PARTNER ID MISMATCH\n"); + if (MAVLINK_WPM_VERBOSE) printf("IGNORED WAYPOINT COMMAND BECAUSE TARGET SYSTEM AND COMPONENT OR COMM PARTNER ID MISMATCH\n"); #endif } break; } - case MAVLINK_MSG_ID_WAYPOINT_REQUEST_LIST: + case MAVLINK_MSG_ID_MISSION_REQUEST_LIST: { - mavlink_waypoint_request_list_t wprl; - mavlink_msg_waypoint_request_list_decode(msg, &wprl); - if(wprl.target_system == mavlink_system.sysid /*&& wprl.target_component == mavlink_system.compid*/) + mavlink_mission_request_list_t wprl; + mavlink_msg_mission_request_list_decode(msg, &wprl); + if(wprl.target_system == mavlink_system.sysid /*&& wprl.target_component == mavlink_wpm_comp_id*/) { wpm.timestamp_lastaction = now; @@ -558,38 +542,38 @@ void mavlink_wpm_message_handler(const mavlink_message_t* msg) { if (wpm.size > 0) { - if (verbose && wpm.current_state == MAVLINK_WPM_STATE_IDLE) // printf("Got MAVLINK_MSG_ID_WAYPOINT_REQUEST_LIST from %u changing state to MAVLINK_WPM_STATE_SENDLIST\n", msg->sysid); - if (verbose && wpm.current_state == MAVLINK_WPM_STATE_SENDLIST) // printf("Got MAVLINK_MSG_ID_WAYPOINT_REQUEST_LIST again from %u staying in state MAVLINK_WPM_STATE_SENDLIST\n", msg->sysid); - wpm.current_state = MAVLINK_WPM_STATE_SENDLIST; + //if (verbose && wpm.current_state == MAVLINK_WPM_STATE_IDLE) // printf("Got MAVLINK_MSG_ID_MISSION_ITEM_REQUEST_LIST from %u changing state to MAVLINK_WPM_STATE_SENDLIST\n", msg->sysid); +// if (verbose && wpm.current_state == MAVLINK_WPM_STATE_SENDLIST) // printf("Got MAVLINK_MSG_ID_MISSION_ITEM_REQUEST_LIST again from %u staying in state MAVLINK_WPM_STATE_SENDLIST\n", msg->sysid); + wpm.current_state = MAVLINK_WPM_STATE_SENDLIST; wpm.current_wp_id = 0; wpm.current_partner_sysid = msg->sysid; wpm.current_partner_compid = msg->compid; } else { - // if (verbose) // printf("Got MAVLINK_MSG_ID_WAYPOINT_REQUEST_LIST from %u but have no waypoints, staying in \n", msg->sysid); + // if (verbose) // printf("Got MAVLINK_MSG_ID_MISSION_ITEM_REQUEST_LIST from %u but have no waypoints, staying in \n", msg->sysid); } wpm.current_count = wpm.size; mavlink_wpm_send_waypoint_count(msg->sysid,msg->compid, wpm.current_count); } else { - // if (verbose) // printf("Ignored MAVLINK_MSG_ID_WAYPOINT_REQUEST_LIST because i'm doing something else already (state=%i).\n", wpm.current_state); + // if (verbose) // printf("Ignored MAVLINK_MSG_ID_MISSION_ITEM_REQUEST_LIST because i'm doing something else already (state=%i).\n", wpm.current_state); } } else { // if (verbose) // printf("IGNORED WAYPOINT COMMAND BECAUSE TARGET SYSTEM AND COMPONENT MISMATCH\n"); } - + break; } - case MAVLINK_MSG_ID_WAYPOINT_REQUEST: + case MAVLINK_MSG_ID_MISSION_REQUEST: { - mavlink_waypoint_request_t wpr; - mavlink_msg_waypoint_request_decode(msg, &wpr); - if(msg->sysid == wpm.current_partner_sysid && msg->compid == wpm.current_partner_compid && wpr.target_system == mavlink_system.sysid /*&& wpr.target_component == mavlink_system.compid*/) + mavlink_mission_request_t wpr; + mavlink_msg_mission_request_decode(msg, &wpr); + if(msg->sysid == wpm.current_partner_sysid && msg->compid == wpm.current_partner_compid && wpr.target_system == mavlink_system.sysid /*&& wpr.target_component == mavlink_wpm_comp_id*/) { wpm.timestamp_lastaction = now; @@ -599,25 +583,25 @@ void mavlink_wpm_message_handler(const mavlink_message_t* msg) if (wpm.current_state == MAVLINK_WPM_STATE_SENDLIST) { #ifdef MAVLINK_WPM_NO_PRINTF - mavlink_wpm_send_gcs_string("GOT WP REQ, state -> SEND"); + mavlink_missionlib_send_gcs_string("GOT WP REQ, state -> SEND"); #else - if (MAVLINK_WPM_VERBOSE) printf("Got MAVLINK_MSG_ID_WAYPOINT_REQUEST of waypoint %u from %u changing state to MAVLINK_WPM_STATE_SENDLIST_SENDWPS\n", wpr.seq, msg->sysid); + if (MAVLINK_WPM_VERBOSE) printf("Got MAVLINK_MSG_ID_MISSION_ITEM_REQUEST of waypoint %u from %u changing state to MAVLINK_WPM_STATE_SENDLIST_SENDWPS\n", wpr.seq, msg->sysid); #endif } if (wpm.current_state == MAVLINK_WPM_STATE_SENDLIST_SENDWPS && wpr.seq == wpm.current_wp_id + 1) { #ifdef MAVLINK_WPM_NO_PRINTF - mavlink_wpm_send_gcs_string("GOT 2nd WP REQ"); + mavlink_missionlib_send_gcs_string("GOT 2nd WP REQ"); #else - if (MAVLINK_WPM_VERBOSE) printf("Got MAVLINK_MSG_ID_WAYPOINT_REQUEST of waypoint %u from %u staying in state MAVLINK_WPM_STATE_SENDLIST_SENDWPS\n", wpr.seq, msg->sysid); + if (MAVLINK_WPM_VERBOSE) printf("Got MAVLINK_MSG_ID_MISSION_ITEM_REQUEST of waypoint %u from %u staying in state MAVLINK_WPM_STATE_SENDLIST_SENDWPS\n", wpr.seq, msg->sysid); #endif } if (wpm.current_state == MAVLINK_WPM_STATE_SENDLIST_SENDWPS && wpr.seq == wpm.current_wp_id) { #ifdef MAVLINK_WPM_NO_PRINTF - mavlink_wpm_send_gcs_string("GOT 2nd WP REQ"); + mavlink_missionlib_send_gcs_string("GOT 2nd WP REQ"); #else - if (MAVLINK_WPM_VERBOSE) printf("Got MAVLINK_MSG_ID_WAYPOINT_REQUEST of waypoint %u (again) from %u staying in state MAVLINK_WPM_STATE_SENDLIST_SENDWPS\n", wpr.seq, msg->sysid); + if (MAVLINK_WPM_VERBOSE) printf("Got MAVLINK_MSG_ID_MISSION_ITEM_REQUEST of waypoint %u (again) from %u staying in state MAVLINK_WPM_STATE_SENDLIST_SENDWPS\n", wpr.seq, msg->sysid); #endif } @@ -632,20 +616,20 @@ void mavlink_wpm_message_handler(const mavlink_message_t* msg) if (!(wpm.current_state == MAVLINK_WPM_STATE_SENDLIST || wpm.current_state == MAVLINK_WPM_STATE_SENDLIST_SENDWPS)) { #ifdef MAVLINK_WPM_NO_PRINTF - mavlink_wpm_send_gcs_string("REJ. WP CMD: Busy"); + mavlink_missionlib_send_gcs_string("REJ. WP CMD: Busy"); #else - if (MAVLINK_WPM_VERBOSE) printf("Ignored MAVLINK_MSG_ID_WAYPOINT_REQUEST because i'm doing something else already (state=%i).\n", wpm.current_state); + if (MAVLINK_WPM_VERBOSE) printf("Ignored MAVLINK_MSG_ID_MISSION_ITEM_REQUEST because i'm doing something else already (state=%i).\n", wpm.current_state); #endif - break; + break; } else if (wpm.current_state == MAVLINK_WPM_STATE_SENDLIST) { if (wpr.seq != 0) { #ifdef MAVLINK_WPM_NO_PRINTF - mavlink_wpm_send_gcs_string("REJ. WP CMD: First id != 0"); + mavlink_missionlib_send_gcs_string("REJ. WP CMD: First id != 0"); #else - if (MAVLINK_WPM_VERBOSE) printf("Ignored MAVLINK_MSG_ID_WAYPOINT_REQUEST because the first requested waypoint ID (%u) was not 0.\n", wpr.seq); + if (MAVLINK_WPM_VERBOSE) printf("Ignored MAVLINK_MSG_ID_MISSION_ITEM_REQUEST because the first requested waypoint ID (%u) was not 0.\n", wpr.seq); #endif } } @@ -654,26 +638,26 @@ void mavlink_wpm_message_handler(const mavlink_message_t* msg) if (wpr.seq != wpm.current_wp_id && wpr.seq != wpm.current_wp_id + 1) { #ifdef MAVLINK_WPM_NO_PRINTF - mavlink_wpm_send_gcs_string("REJ. WP CMD: Req. WP was unexpected"); + mavlink_missionlib_send_gcs_string("REJ. WP CMD: Req. WP was unexpected"); #else - if (MAVLINK_WPM_VERBOSE) printf("Ignored MAVLINK_MSG_ID_WAYPOINT_REQUEST because the requested waypoint ID (%u) was not the expected (%u or %u).\n", wpr.seq, wpm.current_wp_id, wpm.current_wp_id+1); + if (MAVLINK_WPM_VERBOSE) printf("Ignored MAVLINK_MSG_ID_MISSION_ITEM_REQUEST because the requested waypoint ID (%u) was not the expected (%u or %u).\n", wpr.seq, wpm.current_wp_id, wpm.current_wp_id+1); #endif } else if (wpr.seq >= wpm.size) { #ifdef MAVLINK_WPM_NO_PRINTF - mavlink_wpm_send_gcs_string("REJ. WP CMD: Req. WP not in list"); + mavlink_missionlib_send_gcs_string("REJ. WP CMD: Req. WP not in list"); #else - if (MAVLINK_WPM_VERBOSE) printf("Ignored MAVLINK_MSG_ID_WAYPOINT_REQUEST because the requested waypoint ID (%u) was out of bounds.\n", wpr.seq); + if (MAVLINK_WPM_VERBOSE) printf("Ignored MAVLINK_MSG_ID_MISSION_ITEM_REQUEST because the requested waypoint ID (%u) was out of bounds.\n", wpr.seq); #endif } } else { #ifdef MAVLINK_WPM_NO_PRINTF - mavlink_wpm_send_gcs_string("REJ. WP CMD: ?"); + mavlink_missionlib_send_gcs_string("REJ. WP CMD: ?"); #else - if (MAVLINK_WPM_VERBOSE) printf("Ignored MAVLINK_MSG_ID_WAYPOINT_REQUEST - FIXME: missed error description\n"); + if (MAVLINK_WPM_VERBOSE) printf("Ignored MAVLINK_MSG_ID_MISSION_ITEM_REQUEST - FIXME: missed error description\n"); #endif } } @@ -682,32 +666,32 @@ void mavlink_wpm_message_handler(const mavlink_message_t* msg) else { //we we're target but already communicating with someone else - if((wpr.target_system == mavlink_system.sysid /*&& wpr.target_component == mavlink_system.compid*/) && !(msg->sysid == wpm.current_partner_sysid && msg->compid == wpm.current_partner_compid)) + if((wpr.target_system == mavlink_system.sysid /*&& wpr.target_component == mavlink_wpm_comp_id*/) && !(msg->sysid == wpm.current_partner_sysid && msg->compid == wpm.current_partner_compid)) { #ifdef MAVLINK_WPM_NO_PRINTF - mavlink_wpm_send_gcs_string("REJ. WP CMD: Busy"); + mavlink_missionlib_send_gcs_string("REJ. WP CMD: Busy"); #else - if (MAVLINK_WPM_VERBOSE) printf("Ignored MAVLINK_MSG_ID_WAYPOINT_REQUEST from ID %u because i'm already talking to ID %u.\n", msg->sysid, wpm.current_partner_sysid); + if (MAVLINK_WPM_VERBOSE) printf("Ignored MAVLINK_MSG_ID_MISSION_ITEM_REQUEST from ID %u because i'm already talking to ID %u.\n", msg->sysid, wpm.current_partner_sysid); #endif } else { #ifdef MAVLINK_WPM_NO_PRINTF - mavlink_wpm_send_gcs_string("REJ. WP CMD: target id mismatch"); + mavlink_missionlib_send_gcs_string("REJ. WP CMD: target id mismatch"); #else - if (MAVLINK_WPM_VERBOSE) printf("IGNORED WAYPOINT COMMAND BECAUSE TARGET SYSTEM AND COMPONENT OR COMM PARTNER ID MISMATCH\n"); + if (MAVLINK_WPM_VERBOSE) printf("IGNORED WAYPOINT COMMAND BECAUSE TARGET SYSTEM AND COMPONENT OR COMM PARTNER ID MISMATCH\n"); #endif } - + } break; } - case MAVLINK_MSG_ID_WAYPOINT_COUNT: + case MAVLINK_MSG_ID_MISSION_COUNT: { - mavlink_waypoint_count_t wpc; - mavlink_msg_waypoint_count_decode(msg, &wpc); - if(wpc.target_system == mavlink_system.sysid/* && wpc.target_component == mavlink_system.compid*/) + mavlink_mission_count_t wpc; + mavlink_msg_mission_count_decode(msg, &wpc); + if(wpc.target_system == mavlink_system.sysid/* && wpc.target_component == mavlink_wpm_comp_id*/) { wpm.timestamp_lastaction = now; @@ -718,17 +702,17 @@ void mavlink_wpm_message_handler(const mavlink_message_t* msg) if (wpm.current_state == MAVLINK_WPM_STATE_IDLE) { #ifdef MAVLINK_WPM_NO_PRINTF - mavlink_wpm_send_gcs_string("WP CMD OK: state -> GETLIST"); + mavlink_missionlib_send_gcs_string("WP CMD OK: state -> GETLIST"); #else - if (MAVLINK_WPM_VERBOSE) printf("Got MAVLINK_MSG_ID_WAYPOINT_COUNT (%u) from %u changing state to MAVLINK_WPM_STATE_GETLIST\n", wpc.count, msg->sysid); + if (MAVLINK_WPM_VERBOSE) printf("Got MAVLINK_MSG_ID_MISSION_ITEM_COUNT (%u) from %u changing state to MAVLINK_WPM_STATE_GETLIST\n", wpc.count, msg->sysid); #endif } if (wpm.current_state == MAVLINK_WPM_STATE_GETLIST) { #ifdef MAVLINK_WPM_NO_PRINTF - mavlink_wpm_send_gcs_string("WP CMD OK AGAIN"); + mavlink_missionlib_send_gcs_string("WP CMD OK AGAIN"); #else - if (MAVLINK_WPM_VERBOSE) printf("Got MAVLINK_MSG_ID_WAYPOINT_COUNT (%u) again from %u\n", wpc.count, msg->sysid); + if (MAVLINK_WPM_VERBOSE) printf("Got MAVLINK_MSG_ID_MISSION_ITEM_COUNT (%u) again from %u\n", wpc.count, msg->sysid); #endif } @@ -739,32 +723,32 @@ void mavlink_wpm_message_handler(const mavlink_message_t* msg) wpm.current_count = wpc.count; #ifdef MAVLINK_WPM_NO_PRINTF - mavlink_wpm_send_gcs_string("CLR RCV BUF: READY"); + mavlink_missionlib_send_gcs_string("CLR RCV BUF: READY"); #else - if (MAVLINK_WPM_VERBOSE) printf("clearing receive buffer and readying for receiving waypoints\n"); + if (MAVLINK_WPM_VERBOSE) printf("clearing receive buffer and readying for receiving waypoints\n"); #endif wpm.rcv_size = 0; //while(waypoints_receive_buffer->size() > 0) - // { - // delete waypoints_receive_buffer->back(); - // waypoints_receive_buffer->pop_back(); - // } +// { +// delete waypoints_receive_buffer->back(); +// waypoints_receive_buffer->pop_back(); +// } mavlink_wpm_send_waypoint_request(wpm.current_partner_sysid, wpm.current_partner_compid, wpm.current_wp_id); } else if (wpc.count == 0) { #ifdef MAVLINK_WPM_NO_PRINTF - mavlink_wpm_send_gcs_string("COUNT 0"); + mavlink_missionlib_send_gcs_string("COUNT 0"); #else - if (MAVLINK_WPM_VERBOSE) printf("got waypoint count of 0, clearing waypoint list and staying in state MAVLINK_WPM_STATE_IDLE\n"); + if (MAVLINK_WPM_VERBOSE) printf("got waypoint count of 0, clearing waypoint list and staying in state MAVLINK_WPM_STATE_IDLE\n"); #endif wpm.rcv_size = 0; //while(waypoints_receive_buffer->size() > 0) - // { - // delete waypoints->back(); - // waypoints->pop_back(); - // } +// { +// delete waypoints->back(); +// waypoints->pop_back(); +// } wpm.current_active_wp_id = -1; wpm.yaw_reached = false; wpm.pos_reached = false; @@ -774,9 +758,9 @@ void mavlink_wpm_message_handler(const mavlink_message_t* msg) else { #ifdef MAVLINK_WPM_NO_PRINTF - mavlink_wpm_send_gcs_string("IGN WP CMD"); + mavlink_missionlib_send_gcs_string("IGN WP CMD"); #else - if (MAVLINK_WPM_VERBOSE) printf("Ignoring MAVLINK_MSG_ID_WAYPOINT_COUNT from %u with count of %u\n", msg->sysid, wpc.count); + if (MAVLINK_WPM_VERBOSE) printf("Ignoring MAVLINK_MSG_ID_MISSION_ITEM_COUNT from %u with count of %u\n", msg->sysid, wpc.count); #endif } } @@ -785,25 +769,25 @@ void mavlink_wpm_message_handler(const mavlink_message_t* msg) if (!(wpm.current_state == MAVLINK_WPM_STATE_IDLE || wpm.current_state == MAVLINK_WPM_STATE_GETLIST)) { #ifdef MAVLINK_WPM_NO_PRINTF - mavlink_wpm_send_gcs_string("REJ. WP CMD: Busy"); + mavlink_missionlib_send_gcs_string("REJ. WP CMD: Busy"); #else - if (MAVLINK_WPM_VERBOSE) printf("Ignored MAVLINK_MSG_ID_WAYPOINT_COUNT because i'm doing something else already (state=%i).\n", wpm.current_state); + if (MAVLINK_WPM_VERBOSE) printf("Ignored MAVLINK_MSG_ID_MISSION_ITEM_COUNT because i'm doing something else already (state=%i).\n", wpm.current_state); #endif } else if (wpm.current_state == MAVLINK_WPM_STATE_GETLIST && wpm.current_wp_id != 0) { #ifdef MAVLINK_WPM_NO_PRINTF - mavlink_wpm_send_gcs_string("REJ. WP CMD: Busy"); + mavlink_missionlib_send_gcs_string("REJ. WP CMD: Busy"); #else - if (MAVLINK_WPM_VERBOSE) printf("Ignored MAVLINK_MSG_ID_WAYPOINT_COUNT because i'm already receiving waypoint %u.\n", wpm.current_wp_id); + if (MAVLINK_WPM_VERBOSE) printf("Ignored MAVLINK_MSG_ID_MISSION_ITEM_COUNT because i'm already receiving waypoint %u.\n", wpm.current_wp_id); #endif } else { #ifdef MAVLINK_WPM_NO_PRINTF - mavlink_wpm_send_gcs_string("REJ. WP CMD: ?"); + mavlink_missionlib_send_gcs_string("REJ. WP CMD: ?"); #else - if (MAVLINK_WPM_VERBOSE) printf("Ignored MAVLINK_MSG_ID_WAYPOINT_COUNT - FIXME: missed error description\n"); + if (MAVLINK_WPM_VERBOSE) printf("Ignored MAVLINK_MSG_ID_MISSION_ITEM_COUNT - FIXME: missed error description\n"); #endif } } @@ -811,43 +795,43 @@ void mavlink_wpm_message_handler(const mavlink_message_t* msg) else { #ifdef MAVLINK_WPM_NO_PRINTF - mavlink_wpm_send_gcs_string("REJ. WP CMD: target id mismatch"); + mavlink_missionlib_send_gcs_string("REJ. WP CMD: target id mismatch"); #else - if (MAVLINK_WPM_VERBOSE) printf("IGNORED WAYPOINT COMMAND BECAUSE TARGET SYSTEM AND COMPONENT OR COMM PARTNER ID MISMATCH\n"); + if (MAVLINK_WPM_VERBOSE) printf("IGNORED WAYPOINT COMMAND BECAUSE TARGET SYSTEM AND COMPONENT OR COMM PARTNER ID MISMATCH\n"); #endif } } break; - case MAVLINK_MSG_ID_WAYPOINT: + case MAVLINK_MSG_ID_MISSION_ITEM: { - mavlink_waypoint_t wp; - mavlink_msg_waypoint_decode(msg, &wp); + mavlink_mission_item_t wp; + mavlink_msg_mission_item_decode(msg, &wp); - // if (verbose) // printf("GOT WAYPOINT!"); + mavlink_missionlib_send_gcs_string("GOT WP"); - if((msg->sysid == wpm.current_partner_sysid && msg->compid == wpm.current_partner_compid) && (wp.target_system == mavlink_system.sysid /*&& wp.target_component == mavlink_system.compid*/)) + if((msg->sysid == wpm.current_partner_sysid && msg->compid == wpm.current_partner_compid) && (wp.target_system == mavlink_system.sysid /*&& wp.target_component == mavlink_wpm_comp_id*/)) { wpm.timestamp_lastaction = now; //ensure that we are in the correct state and that the first waypoint has id 0 and the following waypoints have the correct ids if ((wpm.current_state == MAVLINK_WPM_STATE_GETLIST && wp.seq == 0) || (wpm.current_state == MAVLINK_WPM_STATE_GETLIST_GETWPS && wp.seq == wpm.current_wp_id && wp.seq < wpm.current_count)) { - if (verbose && wpm.current_state == MAVLINK_WPM_STATE_GETLIST) // printf("Got MAVLINK_MSG_ID_WAYPOINT %u from %u changing state to MAVLINK_WPM_STATE_GETLIST_GETWPS\n", wp.seq, msg->sysid); - if (verbose && wpm.current_state == MAVLINK_WPM_STATE_GETLIST_GETWPS && wp.seq == wpm.current_wp_id) // printf("Got MAVLINK_MSG_ID_WAYPOINT %u from %u\n", wp.seq, msg->sysid); - if (verbose && wpm.current_state == MAVLINK_WPM_STATE_GETLIST_GETWPS && wp.seq-1 == wpm.current_wp_id) // printf("Got MAVLINK_MSG_ID_WAYPOINT %u (again) from %u\n", wp.seq, msg->sysid); - - wpm.current_state = MAVLINK_WPM_STATE_GETLIST_GETWPS; - mavlink_waypoint_t* newwp = &(wpm.rcv_waypoints[wp.seq]); - memcpy(newwp, &wp, sizeof(mavlink_waypoint_t)); - +// if (verbose && wpm.current_state == MAVLINK_WPM_STATE_GETLIST) // printf("Got MAVLINK_MSG_ID_MISSION_ITEM %u from %u changing state to MAVLINK_WPM_STATE_GETLIST_GETWPS\n", wp.seq, msg->sysid); +// if (verbose && wpm.current_state == MAVLINK_WPM_STATE_GETLIST_GETWPS && wp.seq == wpm.current_wp_id) // printf("Got MAVLINK_MSG_ID_MISSION_ITEM %u from %u\n", wp.seq, msg->sysid); +// if (verbose && wpm.current_state == MAVLINK_WPM_STATE_GETLIST_GETWPS && wp.seq-1 == wpm.current_wp_id) // printf("Got MAVLINK_MSG_ID_MISSION_ITEM %u (again) from %u\n", wp.seq, msg->sysid); +// + wpm.current_state = MAVLINK_WPM_STATE_GETLIST_GETWPS; + mavlink_mission_item_t* newwp = &(wpm.rcv_waypoints[wp.seq]); + memcpy(newwp, &wp, sizeof(mavlink_mission_item_t)); wpm.current_wp_id = wp.seq + 1; // if (verbose) // printf ("Added new waypoint to list. X= %f\t Y= %f\t Z= %f\t Yaw= %f\n", newwp->x, newwp->y, newwp->z, newwp->param4); if(wpm.current_wp_id == wpm.current_count && wpm.current_state == MAVLINK_WPM_STATE_GETLIST_GETWPS) { + mavlink_missionlib_send_gcs_string("GOT ALL WPS"); // if (verbose) // printf("Got all %u waypoints, changing state to MAVLINK_WPM_STATE_IDLE\n", wpm.current_count); mavlink_wpm_send_waypoint_ack(wpm.current_partner_sysid, wpm.current_partner_compid, 0); @@ -903,44 +887,44 @@ void mavlink_wpm_message_handler(const mavlink_message_t* msg) { //we're done receiving waypoints, answer with ack. mavlink_wpm_send_waypoint_ack(wpm.current_partner_sysid, wpm.current_partner_compid, 0); - // printf("Received MAVLINK_MSG_ID_WAYPOINT while state=MAVLINK_WPM_STATE_IDLE, answered with WAYPOINT_ACK.\n"); + // printf("Received MAVLINK_MSG_ID_MISSION_ITEM while state=MAVLINK_WPM_STATE_IDLE, answered with WAYPOINT_ACK.\n"); } // if (verbose) { if (!(wpm.current_state == MAVLINK_WPM_STATE_GETLIST || wpm.current_state == MAVLINK_WPM_STATE_GETLIST_GETWPS)) { - // printf("Ignored MAVLINK_MSG_ID_WAYPOINT %u because i'm doing something else already (state=%i).\n", wp.seq, wpm.current_state); + // printf("Ignored MAVLINK_MSG_ID_MISSION_ITEM %u because i'm doing something else already (state=%i).\n", wp.seq, wpm.current_state); break; } else if (wpm.current_state == MAVLINK_WPM_STATE_GETLIST) { if(!(wp.seq == 0)) { - // printf("Ignored MAVLINK_MSG_ID_WAYPOINT because the first waypoint ID (%u) was not 0.\n", wp.seq); + // printf("Ignored MAVLINK_MSG_ID_MISSION_ITEM because the first waypoint ID (%u) was not 0.\n", wp.seq); } else { - // printf("Ignored MAVLINK_MSG_ID_WAYPOINT %u - FIXME: missed error description\n", wp.seq); + // printf("Ignored MAVLINK_MSG_ID_MISSION_ITEM %u - FIXME: missed error description\n", wp.seq); } } else if (wpm.current_state == MAVLINK_WPM_STATE_GETLIST_GETWPS) { if (!(wp.seq == wpm.current_wp_id)) { - // printf("Ignored MAVLINK_MSG_ID_WAYPOINT because the waypoint ID (%u) was not the expected %u.\n", wp.seq, wpm.current_wp_id); + // printf("Ignored MAVLINK_MSG_ID_MISSION_ITEM because the waypoint ID (%u) was not the expected %u.\n", wp.seq, wpm.current_wp_id); } else if (!(wp.seq < wpm.current_count)) { - // printf("Ignored MAVLINK_MSG_ID_WAYPOINT because the waypoint ID (%u) was out of bounds.\n", wp.seq); + // printf("Ignored MAVLINK_MSG_ID_MISSION_ITEM because the waypoint ID (%u) was out of bounds.\n", wp.seq); } else { - // printf("Ignored MAVLINK_MSG_ID_WAYPOINT %u - FIXME: missed error description\n", wp.seq); + // printf("Ignored MAVLINK_MSG_ID_MISSION_ITEM %u - FIXME: missed error description\n", wp.seq); } } else { - // printf("Ignored MAVLINK_MSG_ID_WAYPOINT %u - FIXME: missed error description\n", wp.seq); + // printf("Ignored MAVLINK_MSG_ID_MISSION_ITEM %u - FIXME: missed error description\n", wp.seq); } } } @@ -948,37 +932,37 @@ void mavlink_wpm_message_handler(const mavlink_message_t* msg) else { //we we're target but already communicating with someone else - if((wp.target_system == mavlink_system.sysid /*&& wp.target_component == mavlink_system.compid*/) && !(msg->sysid == wpm.current_partner_sysid && msg->compid == wpm.current_partner_compid) && wpm.current_state != MAVLINK_WPM_STATE_IDLE) + if((wp.target_system == mavlink_system.sysid /*&& wp.target_component == mavlink_wpm_comp_id*/) && !(msg->sysid == wpm.current_partner_sysid && msg->compid == wpm.current_partner_compid) && wpm.current_state != MAVLINK_WPM_STATE_IDLE) { - // if (verbose) // printf("Ignored MAVLINK_MSG_ID_WAYPOINT %u from ID %u because i'm already talking to ID %u.\n", wp.seq, msg->sysid, wpm.current_partner_sysid); + // if (verbose) // printf("Ignored MAVLINK_MSG_ID_MISSION_ITEM %u from ID %u because i'm already talking to ID %u.\n", wp.seq, msg->sysid, wpm.current_partner_sysid); } - else if(wp.target_system == mavlink_system.sysid /* && wp.target_component == mavlink_system.compid*/) + else if(wp.target_system == mavlink_system.sysid /* && wp.target_component == mavlink_wpm_comp_id*/) { - // if (verbose) // printf("Ignored MAVLINK_MSG_ID_WAYPOINT %u from ID %u because i have no idea what to do with it\n", wp.seq, msg->sysid); + // if (verbose) // printf("Ignored MAVLINK_MSG_ID_MISSION_ITEM %u from ID %u because i have no idea what to do with it\n", wp.seq, msg->sysid); } } break; } - case MAVLINK_MSG_ID_WAYPOINT_CLEAR_ALL: + case MAVLINK_MSG_ID_MISSION_CLEAR_ALL: { - mavlink_waypoint_clear_all_t wpca; - mavlink_msg_waypoint_clear_all_decode(msg, &wpca); + mavlink_mission_clear_all_t wpca; + mavlink_msg_mission_clear_all_decode(msg, &wpca); - if(wpca.target_system == mavlink_system.sysid /*&& wpca.target_component == mavlink_system.compid */ && wpm.current_state == MAVLINK_WPM_STATE_IDLE) + if(wpca.target_system == mavlink_system.sysid /*&& wpca.target_component == mavlink_wpm_comp_id */ && wpm.current_state == MAVLINK_WPM_STATE_IDLE) { wpm.timestamp_lastaction = now; - // if (verbose) // printf("Got MAVLINK_MSG_ID_WAYPOINT_CLEAR_LIST from %u deleting all waypoints\n", msg->sysid); + // if (verbose) // printf("Got MAVLINK_MSG_ID_MISSION_ITEM_CLEAR_LIST from %u deleting all waypoints\n", msg->sysid); // Delete all waypoints wpm.size = 0; wpm.current_active_wp_id = -1; wpm.yaw_reached = false; wpm.pos_reached = false; } - else if (wpca.target_system == mavlink_system.sysid /*&& wpca.target_component == mavlink_system.compid */ && wpm.current_state != MAVLINK_WPM_STATE_IDLE) + else if (wpca.target_system == mavlink_system.sysid /*&& wpca.target_component == mavlink_wpm_comp_id */ && wpm.current_state != MAVLINK_WPM_STATE_IDLE) { - // if (verbose) // printf("Ignored MAVLINK_MSG_ID_WAYPOINT_CLEAR_LIST from %u because i'm doing something else already (state=%i).\n", msg->sysid, wpm.current_state); + // if (verbose) // printf("Ignored MAVLINK_MSG_ID_MISSION_ITEM_CLEAR_LIST from %u because i'm doing something else already (state=%i).\n", msg->sysid, wpm.current_state); } break; } @@ -995,7 +979,7 @@ void mavlink_wpm_message_handler(const mavlink_message_t* msg) { if (wpm.current_active_wp_id < wpm.size) { - mavlink_waypoint_t *cur_wp = &(wpm.waypoints[wpm.current_active_wp_id]); + mavlink_mission_item_t *cur_wp = &(wpm.waypoints[wpm.current_active_wp_id]); if (wpm.timestamp_firstinside_orbit == 0) { diff --git a/src/GCS_MAVLink/missionlib/waypoints.h b/src/GCS_MAVLink/missionlib/waypoints.h index 4bc32a14a..49374f6a3 100644 --- a/src/GCS_MAVLink/missionlib/waypoints.h +++ b/src/GCS_MAVLink/missionlib/waypoints.h @@ -19,6 +19,19 @@ /* This assumes you have the mavlink headers on your include path or in the same folder as this source file */ + +// Disable auto-data structures +#ifndef MAVLINK_NO_DATA +#define MAVLINK_NO_DATA +#endif + +#include +extern void mavlink_send_uart_bytes(mavlink_channel_t chan, uint8_t* buffer, uint16_t len); + +#ifndef MAVLINK_SEND_UART_BYTES +#define MAVLINK_SEND_UART_BYTES(chan, buffer, len) mavlink_send_uart_bytes(chan, buffer, len) +#endif +extern mavlink_system_t mavlink_system; #include #include @@ -47,20 +60,20 @@ enum MAVLINK_WPM_CODES /* WAYPOINT MANAGER - MISSION LIB */ -#define MAVLINK_WPM_MAX_WP_COUNT 100 +#define MAVLINK_WPM_MAX_WP_COUNT 15 #define MAVLINK_WPM_CONFIG_IN_FLIGHT_UPDATE ///< Enable double buffer and in-flight updates -#define MAVLINK_WPM_TEXT_FEEDBACK 1 ///< Report back status information as text -#define MAVLINK_WPM_SYSTEM_ID 1 -#define MAVLINK_WPM_COMPONENT_ID 1 -#define MAVLINK_WPM_PROTOCOL_TIMEOUT_DEFAULT 2000000 -#define MAVLINK_WPM_SETPOINT_DELAY_DEFAULT 1000000 +#ifndef MAVLINK_WPM_TEXT_FEEDBACK +#define MAVLINK_WPM_TEXT_FEEDBACK 0 ///< Report back status information as text +#endif +#define MAVLINK_WPM_PROTOCOL_TIMEOUT_DEFAULT 5000 ///< Protocol communication timeout in milliseconds +#define MAVLINK_WPM_SETPOINT_DELAY_DEFAULT 1000 ///< When to send a new setpoint #define MAVLINK_WPM_PROTOCOL_DELAY_DEFAULT 40 struct mavlink_wpm_storage { - mavlink_waypoint_t waypoints[MAVLINK_WPM_MAX_WP_COUNT]; ///< Currently active waypoints + mavlink_mission_item_t waypoints[MAVLINK_WPM_MAX_WP_COUNT]; ///< Currently active waypoints #ifdef MAVLINK_WPM_CONFIG_IN_FLIGHT_UPDATE - mavlink_waypoint_t rcv_waypoints[MAVLINK_WPM_MAX_WP_COUNT]; ///< Receive buffer for next waypoints + mavlink_mission_item_t rcv_waypoints[MAVLINK_WPM_MAX_WP_COUNT]; ///< Receive buffer for next waypoints #endif uint16_t size; uint16_t max_size; @@ -87,5 +100,5 @@ struct mavlink_wpm_storage { typedef struct mavlink_wpm_storage mavlink_wpm_storage; void mavlink_wpm_init(mavlink_wpm_storage* state); - -void mavlink_wpm_message_handler(const mavlink_message_t* msg); \ No newline at end of file +void mavlink_wpm_loop(); +void mavlink_wpm_message_handler(const mavlink_message_t* msg); diff --git a/src/GCS_MAVLink/sync b/src/GCS_MAVLink/sync index 424c24393..c8a05c779 100644 --- a/src/GCS_MAVLink/sync +++ b/src/GCS_MAVLink/sync @@ -2,7 +2,7 @@ branch="master" trap exit ERR rm -rf _tmp -git clone git://github.com/pixhawk/mavlink.git -b $branch _tmp +git clone git://github.com/mavlink/mavlink.git -b $branch _tmp rm -rf _tmp/.git rsync -av _tmp/* . rm -rf _tmp diff --git a/src/Makefile b/src/Makefile index 88fbc6852..c0972c3b6 100644 --- a/src/Makefile +++ b/src/Makefile @@ -800,7 +800,7 @@ endif ifeq ($(EXT), MAVLINK) CPPDEFS += -DMAVLINK - CPPSRC += telemetry/mavlink.cpp rotarysw.cpp serial.cpp + CPPSRC += telemetry/mavlink.cpp gui/view_mavlink.cpp serial.cpp endif ifeq ($(EXT), TELEMETREZ) diff --git a/src/gui/view_mavlink.cpp b/src/gui/view_mavlink.cpp new file mode 100644 index 000000000..f3119aadd --- /dev/null +++ b/src/gui/view_mavlink.cpp @@ -0,0 +1,319 @@ +/* + * Authors (alphabetical order) + * - Andre Bernet + * - Andreas Weitl + * - Bertrand Songis + * - Bryan J. Rentoul (Gruvin) + * - Cameron Weeks + * - Erez Raviv + * - Gabriel Birkus + * - Gerard Valade + * - Jean-Pierre Parisy + * - Karl Szmutny + * - Michael Blandford + * - Michal Hlavinka + * - Pat Mackenzie + * - Philip Moss + * - Rienk de Jong + * - Rob Thomson + * - Romolo Manfredini + * - Thomas Husterer + * + * opentx is based on code named + * gruvin9x by Bryan J. Rentoul: http://code.google.com/p/gruvin9x/, + * er9x by Erez Raviv: http://code.google.com/p/er9x/, + * and the original (and ongoing) project by + * Thomas Husterer, th9x: http://code.google.com/p/th9x/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + +/*! \file view_mavlink.cpp + * Mavlink menu + * Contains the menu specific code for Mavlink support. + */ + +#include "gui/view_mavlink.h" + + // Globals declaration + + +/*! \brief Top Mavlink Menu definition + * \details Registers button events and handles that info. Buttons select menus, these + * are launched from the MAVLINK_menu switch statement. + */ +void menuTelemetryMavlink(uint8_t event) { + + switch (event) // new event received, branch accordingly + { + case EVT_ENTRY: + MAVLINK_menu = MENU_INFO; + break; + + case EVT_KEY_FIRST(KEY_UP): + if (MAVLINK_menu > 0) + { + MAVLINK_menu--; + break; + } + else + { + chainMenu(menuMainView); + return; + } + case EVT_KEY_FIRST(KEY_DOWN): + if (MAVLINK_menu < MAX_MAVLINK_MENU - 1) + MAVLINK_menu++; + break; + case EVT_KEY_FIRST(KEY_MENU): + case EVT_KEY_FIRST(KEY_EXIT): + //MAVLINK_Quit(); + chainMenu(menuMainView); + return; + } + + switch (MAVLINK_menu) { + case MENU_INFO: + menuTelemetryMavlinkInfos(); + break; + case MENU_GPS: + menuTelemetryMavlinkGPS(); + break; +#ifdef DUMP_RX_TX + case MENU_DUMP_TX: + case MENU_DUMP_RX: + menuTelemetryMavlinkDump(event); + break; +#endif + + default: + break; + } + +} + +/*! \brief Float variable display helper + * \param x x position on the screen + * \param y y position on the screen + * \param val value to display + * \param percis precision to display + * \param mode Use one of the defines in lcd.h line 81 + * \details The maximum value is 9999. The position is the position of the ones, see below for explanation "*" marks + * the x position. + * \verbatim + * + 9999.9999 \endverbatim + */ +void lcd_outdezFloat(uint8_t x, uint8_t y, float val, uint8_t precis, uint8_t mode) { + char c; + int16_t lnum = val; + uint8_t x1 = x; + val -= lnum; + + int8_t i = 0; + lnum = abs(lnum); + for (; i < 4; i++) { + c = (lnum % 10) + '0'; + x1 -= FWNUM; + lcd_putcAtt(x1, y, c, mode); + lnum /= 10; + if (lnum == 0) { + break; + } + } + if (lnum != 0) { + // Error number too big + x1 = x; + for (i = 0; i < 4; i++) { + x1 -= FW; + lcd_putcAtt(x1, y, '?', mode); + } + } else { + if (val < 0) { + val = -val; + x1 -= FWNUM; + lcd_putcAtt(x1, y, '-', mode); + } + if (precis) + lcd_putcAtt(x, y, '.', mode); + + for (i = 0; i < precis; i++) { + val *= 10; + int a = val; + c = a + '0'; + x += FWNUM; + lcd_putcAtt(x, y, c, mode); + val -= a; + } + } +} + +/*! \brief Menu header + * \details Small helper function to print the standard header on the screen. + */ +void mav_title(const pm_char * s, uint8_t index) +{ + lcd_putsAtt(0, 0, PSTR("MAVLINK"), INVERS); + lcd_puts(10 * FW, 0, s); + displayScreenIndex(index, MAX_MAVLINK_MENU, INVERS); + lcd_putc(8 * FW, 0, (mav_heartbeat > 0) ? '*' : ' '); +} + +/*! \brief Global info menu + * \details Quick status overview menu. The menu should contain current mode, + * armed | disarmed, battery status and RSSI info. Menu must be clean and + * readable with a quick glance. + * \todo Make menu as described as above. + */ +void menuTelemetryMavlinkInfos(void) { + + mav_title(PSTR("INFOS"), MAVLINK_menu); + + uint8_t x1, x2, xnum, y; + x1 = FW; + x2 = 7 * FW; + xnum = x2 + 5 * FWNUM; + y = FH; + + char * ptr = mav_statustext; + for (uint8_t j = 0; j < LEN_STATUSTEXT; j++) { + if (*ptr == 0) { + lcd_putc(x1, y, ' '); + } else { + lcd_putc(x1, y, *ptr++); + } + x1 += FW; + } + x1 = FW; + y += FH; + + if (telemetry_data.status) { + + lcd_putsnAtt(x1, y, PSTR("MODE"), 4, 0); + if (telemetry_data.mode & MAV_MODE_FLAG_SAFETY_ARMED) + lcd_putsnAtt(x2, y, PSTR("A"), 1, 0); + lcd_outdezAtt(xnum, y, telemetry_data.mode, 0); + + y += FH; + lcd_puts(x1, y, PSTR("BATT")); + lcd_outdezNAtt(xnum, y, telemetry_data.vbat, PREC1, 5); + + y += FH; + lcd_puts(x1, y, PSTR("DROP")); + lcd_outdezAtt(xnum, y, telemetry_data.packet_drop, 0); + + } +} + +/*! \brief GPS information menu + * \details Menu gives a lot of info from the gps like fix type, position, + * attitude, heading and velocity. Text is small and the user must focus to + * read it. + * \todo Text is small. Should we do something about this or leaf it like this. + * I don't think will be used much when a user is concentrated on flying. + */ +void menuTelemetryMavlinkGPS(void) { + mav_title(PSTR("GPS"), MAVLINK_menu); + + uint8_t x1, x2, xnum, y; + x1 = FW; + x2 = 5 * FW + FWNUM; + xnum = 5 * FW + 3 * FWNUM; + y = FH; + + lcd_putsnAtt(x1, y, PSTR("GPS"), 3, 0); + if (telemetry_data.fix_type <= 2) { + lcd_putsnAtt(x2, y, PSTR("__NOOK") + 2 * telemetry_data.fix_type, 2, 0); + } else { + lcd_outdezNAtt(xnum, y, telemetry_data.fix_type, 0, 3); + lcd_puts(xnum, y, PSTR("D")); + } + lcd_puts(x2 + 5 * FW, y, PSTR("SAT")); + lcd_outdezNAtt(x2 + 8 * FW + 3 * FWNUM, y, telemetry_data.satellites_visible, 0, 2); + +// if (telemetry_data.fix_type > 0) { + y += FH; + lcd_puts(0, y, PSTR("HDOP")); + lcd_outdezFloat(xnum, y, telemetry_data.eph, 2); + + y += FH; + lcd_puts(0, y, PSTR("COOR")); + lcd_outdezFloat(xnum, y, telemetry_data.loc_current.lat, 2); + + // y += FH; + // lcd_putsnAtt(x1, y, PSTR("LON"), 3, 0); + lcd_outdezFloat(xnum + 10 * FWNUM, y, telemetry_data.loc_current.lon, 2); + + y += FH; + lcd_putsnAtt(x1, y, PSTR("ALT"), 3, 0); + lcd_outdezAtt(xnum, y, telemetry_data.loc_current.alt, 2); + + y += FH; + lcd_putsnAtt(x1, y, PSTR("COG"), 3, 0); + lcd_outdezFloat(xnum, y, telemetry_data.course, 2); + + y += FH; + lcd_putsnAtt(x1, y, PSTR("V"), 1, 0); + lcd_outdezAtt(xnum, y, telemetry_data.v, 2); + //} +} + +#ifdef DUMP_RX_TX +//! \brief Display one byte as hex. +void lcd_outhex2(uint8_t x, uint8_t y, uint8_t val) { + x += FWNUM * 2; + for (int i = 0; i < 2; i++) { + x -= FWNUM; + char c = val & 0xf; + c = c > 9 ? c + 'A' - 10 : c + '0'; + lcd_putcAtt(x, y, c, c >= 'A' ? CONDENSED : 0); + val >>= 4; + } +} + +//! \brief Hex dump of the current mavlink message. +void menuTelemetryMavlinkDump(uint8_t event) { + uint8_t x = 0; + uint8_t y = FH; + uint16_t count = 0; + uint16_t bufferLen = 0; + uint8_t *ptr = NULL; + switch (MAVLINK_menu) { + case MENU_DUMP_RX: + mav_dump_rx = 1; + mav_title(PSTR("RX"), MAVLINK_menu); + bufferLen = mavlinkRxBufferCount; + ptr = mavlinkRxBuffer; + break; + + case MENU_DUMP_TX: + mav_title(PSTR("TX"), MAVLINK_menu); + bufferLen = serialTxBufferCount; + ptr = ptrTxISR; + break; + default: + break; + } + for (uint16_t var = 0; var < bufferLen; var++) { + uint8_t byte = *ptr++; + lcd_outhex2(x, y, byte); + x += 2 * FW; + count++; + if (count > 8) { + count = 0; + x = 0; + y += FH; + if (y == (6 * FH)) + break; + } + } +} +#endif diff --git a/src/gui/view_mavlink.h b/src/gui/view_mavlink.h new file mode 100644 index 000000000..742be4e2c --- /dev/null +++ b/src/gui/view_mavlink.h @@ -0,0 +1,77 @@ +/* + * Authors (alphabetical order) + * - Andre Bernet + * - Andreas Weitl + * - Bertrand Songis + * - Bryan J. Rentoul (Gruvin) + * - Cameron Weeks + * - Erez Raviv + * - Gabriel Birkus + * - Gerard Valade + * - Jean-Pierre Parisy + * - Karl Szmutny + * - Michael Blandford + * - Michal Hlavinka + * - Pat Mackenzie + * - Philip Moss + * - Rienk de Jong + * - Rob Thomson + * - Romolo Manfredini + * - Thomas Husterer + * + * opentx is based on code named + * gruvin9x by Bryan J. Rentoul: http://code.google.com/p/gruvin9x/, + * er9x by Erez Raviv: http://code.google.com/p/er9x/, + * and the original (and ongoing) project by + * Thomas Husterer, th9x: http://code.google.com/p/th9x/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + +/*! \file view_mavlink.h + * Mavlink menu include file + */ + +#ifndef _VIEW_MAVLINK_H_ +#define _VIEW_MAVLINK_H_ + +#include "opentx.h" +#include "telemetry/mavlink.h" +#include "gui/menus.h" + +void menuTelemetryMavlink(uint8_t event); +void displayScreenIndex(uint8_t index, uint8_t count, uint8_t attr); +void lcd_outdezFloat(uint8_t x, uint8_t y, float val, uint8_t precis, uint8_t mode = 0); +void mav_title(const pm_char * s, uint8_t index); +void menuTelemetryMavlinkInfos(void); +void menuTelemetryMavlinkGPS(void); +#ifdef DUMP_RX_TX +void lcd_outhex2(uint8_t x, uint8_t y, uint8_t val); +void menuTelemetryMavlinkDump(uint8_t event); +#endif + +/*! \brief Mavlink menu enumerator + * \details Used to create a readable case statement for the + * \link menuTelemetryMavlink menuTelemetryMavlink \endlink funtion. + */ +enum mavlink_menu_ { + MENU_INFO = 0, // + MENU_GPS, // +#ifdef DUMP_RX_TX + MENU_DUMP_RX, // + MENU_DUMP_TX, // +#endif + MAX_MAVLINK_MENU +}; + +uint8_t MAVLINK_menu = MENU_INFO; + +#endif diff --git a/src/opentx.h b/src/opentx.h index d88468e0c..709de763e 100644 --- a/src/opentx.h +++ b/src/opentx.h @@ -1187,7 +1187,6 @@ inline bool isFunctionActive(uint8_t func) #include "telemetry/nmea.h" #elif defined(MAVLINK) // Mavlink Telemetry - #include "rotarysw.h" #include "telemetry/mavlink.h" #endif diff --git a/src/rotarysw.cpp b/src/rotarysw.cpp deleted file mode 100644 index 68b585b82..000000000 --- a/src/rotarysw.cpp +++ /dev/null @@ -1,121 +0,0 @@ -/* - * Author - Gerard Valade - * - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - */ -#include "opentx.h" - -#define CTIME_ROTARY_ANIM 500 -uint16_t rotarySwChanged = 0; -int8_t rotarySwIdx = -1; -int8_t rotarySwLastPPMVal = 0; - -void putsRotarySwPos(uint8_t x, uint8_t y, uint8_t idx, uint8_t att) { - lcd_putcAtt(x, y, 'P', att); - lcd_putcAtt(x + FW, y, '1' + idx, att); -} - -#ifdef MAVLINK -extern bool isValidReqControlMode(); -extern void putsMavlinkControlMode(uint8_t x, uint8_t y, uint8_t len); -extern void MAVLINK_ReqMode(uint8_t mode, uint8_t send); -#endif - -void putsControlMode(uint8_t x, uint8_t y, uint8_t idx, uint8_t attr, uint8_t len) { - if (idx < ACM_NUM_MODE) { - lcd_putsnAtt(x, y, PSTR(CONROL_MODE_STR) + 6 * idx, len, attr); - } else if (idx < NUM_MODES) { - idx -= ACM_NUM_MODE; - lcd_putsnAtt(x, y, PSTR(CONROL_MODE_STR_APM) + 6 * idx, len, attr); - } else if (idx < NUM_MODES_ALL) { - idx -= NUM_MODES; - lcd_putsnAtt(x, y, PSTR(DISPLAY_ONLY_STR) + 6 * idx, len, attr); - } else { - for (uint8_t i = 0; i < len; i++) { - lcd_putcAtt(x, y, '-', attr); - } - } -} - -void setRotarySwIdx(int8_t idx) { - if (rotarySwIdx != idx) { - rotarySwIdx = idx; - if (rotarySwIdx >= 0) { - rotarySwChanged = (get_tmr10ms() >> 3) + 3; -#ifdef MAVLINK - uint8_t send = g_model.mavlink.rotarySw[rotarySwIdx].typeRotary == ROTARY_TYPE_MAVLINK ? 1 : 0; - MAVLINK_ReqMode(g_model.mavlink.rotarySw[rotarySwIdx].numMode, send); -#endif - } - } -} - - -void animRotarySw(uint8_t x) { - - uint16_t s_time = get_tmr10ms() >> 3; // 80ms time unit - uint8_t swToggle = (s_time < rotarySwChanged); - uint8_t att1 = 0; - - if (s_timerState[0] != TMR_OFF) { - att1 = DBLSIZE | (s_timerState[0] == TMR_BEEPING ? BLINK : 0); - putsTime(x + 14 * FW - 2+5*FWNUM+1, FH * 2, s_timerVal[0], att1, att1); - } - - s_time = s_time >> 4; // 1280ms time unit - uint8_t num4Display = s_time & 0x01; // 1/4 display time -#ifdef MAVLINK - s_time = telemetry_data.status ? (s_time >> 1) : 0; // 2560ms time unit -#else - s_time = 0; -#endif - uint8_t num2Display = s_time & 0x01; // 1/2 time display time - - if (rotarySwIdx >= 0) { - att1 = swToggle ? INVERS : 0; - putsControlMode(x + 4 * FW, 2 * FH, g_model.mavlink.rotarySw[rotarySwIdx].numMode, att1 | NO_UNIT, 6); - } - - switch (num2Display) { - case 0: - att1 = (g_vbat100mV <= g_eeGeneral.vBatWarn ? BLINK : 0); - putsVBat(x + 4 * FW, 2 * FH, att1 | NO_UNIT | DBLSIZE); - - switch (num4Display) { - case 0: - lcd_putsnAtt(x + 4 * FW, 3 * FH, PSTR("ExpExFFneMedCrs") + 3 * g_model.trimInc, 3, 0); - lcd_putsnAtt(x + 8 * FW - FW / 2, 3 * FH, PSTR(" TTm") + 3 * g_model.thrTrim, 3, 0); - break; - default: - lcd_putcAtt(x + 4 * FW, 3 * FH, 'V', 0); - if (s_timerState != TMR_OFF) { - putsTmrMode(x + 7 * FW - FW / 2, 3 * FH, g_model.timers[0].mode, 0); - } - break; - } - break; - - default: -#ifdef MAVLINK - att1 = (telemetry_data.vbat_low ? BLINK : 0); - lcd_outdezAtt(x + 4 * FW, 2 * FH, telemetry_data.vbat, att1 | PREC1 | DBLSIZE); - if (isValidReqControlMode()) - { - lcd_putsnAtt(x + 4 * FW, 3 * FH, PSTR("MAVLNK"), 6, 0); - } else { - putsMavlinkControlMode(x + 4 * FW, 3 * FH, 6); - } - -#endif - break; - } -} diff --git a/src/rotarysw.h b/src/rotarysw.h deleted file mode 100644 index ed0c36842..000000000 --- a/src/rotarysw.h +++ /dev/null @@ -1,113 +0,0 @@ -/* - * Author - Gerard Valade - * - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - */ - -#ifndef rotarysw_h -#define rotarysw_h - -#define ROTARY_SW_CHANNEL "UP DOWN" -// Channel number for rotary switch -//#define MIX_SW_ROLL_CHAN (MIXSRC_LAST_CH+NUM_VIRTUAL) // GVA:Rotary switch -#define MIX_INC_ROTARY_SW (MIXSRC_LAST_CH+MAX_TIMERS+1) -#define MIX_DEC_ROTARY_SW (MIXSRC_LAST_CH+MAX_TIMERS+1) - -extern int8_t rotarySwIdx; -extern int8_t rotarySwLastPPMVal; - -extern void putsControlMode(uint8_t x, uint8_t y, uint8_t idx, uint8_t attr, uint8_t len); -extern void putsRotarySwPos(uint8_t x, uint8_t y, uint8_t idx1, uint8_t att); -extern void setRotarySwIdx(int8_t idx); -extern void setRotarySwDisplay(int8_t idx); -extern void animRotarySw(uint8_t x); - -// Control mode define from arducoper -enum CONTROL_MODE { - STABILIZE = 0, // hold level position - ACRO, // rate control - ALT_HOLD, // AUTO control - AUTO, // AUTO control - GUIDED, // AUTO control - LOITER, // AUTO control - RTL, // AUTO control - CIRCLE, // AUTO control - POSITION, // AUTO control - LAND, // AUTO control - OF_LOITER, // Hold a single location using optical flow sensor - // - // Adding control mode define from ardupilot - MANUAL, - FLY_BY_WIRE_A, // Fly By Wire A has left stick horizontal => desired roll angle, left stick vertical => desired pitch angle, right stick vertical = manual throttle - FLY_BY_WIRE_B, // Fly By Wire B has left stick horizontal => desired roll angle, left stick vertical => desired pitch angle, right stick vertical => desired airspeed - FLY_BY_WIRE_C, // Fly By Wire C has left stick horizontal => desired roll angle, left stick vertical => desired climb rate, right stick vertical => desired airspeed -// Fly By Wire B and Fly By Wire C require airspeed sensor - - // This only for display - INITIALISING, - - NUM_MODES_ALL, -}; -#define ACM_NUM_MODE (OF_LOITER+1) -#define NUM_MODES (FLY_BY_WIRE_C+1) - -// 0123456789012345678901234567890123456789012345678901234567890123456789 -// 0 1 2 3 4 5 6 7 8 9 0 1 -#define CONROL_MODE_STR "STAB ACRO ALT_H AUTO GUIDEDLOITERRTL CIRCLEPOSITILAND OF_LOI" -#define CONROL_MODE_STR_APM "MANUALWIRE_AWIRE_BWIRE_C" -#define DISPLAY_ONLY_STR "INIT" - - -inline void init_rotary_sw() { - setRotarySwIdx(-1); // Reinit sw roll idx - for (uint8_t i = 0; i < NUM_ROTARY_SW; i++) { - if (g_model.mavlink.rotarySw[i].numMode >= NUM_MODES || g_model.mavlink.rotarySw[i].typeRotary > ROTARY_TYPE_MAVLINK) - { - g_model.mavlink.rotarySw[i].typeRotary = 0; - g_model.mavlink.rotarySw[i].numMode = 0; - } -#ifdef OLD_ROTARY - for (uint8_t j = 0; j < sizeof(g_model.mavlink.rotarySw[i].name); j++) // makes sure name is valid - { - uint8_t idx = char2idx(g_model.mavlink.rotarySw[i].name[j]); - g_model.mavlink.rotarySw[i].name[j] = idx2char(idx); - } -#endif - } -} - -inline int8_t find_rotary_sw_pos(uint8_t srcRaw, uint8_t swTog, uint8_t swOn) { - if ((swOn && swTog) || rotarySwIdx == -1) { // toggle switch on - int8_t idx = rotarySwIdx; - int8_t inc = srcRaw == MIX_INC_ROTARY_SW ? 1 : -1; - for (uint8_t k = 0; k < NUM_ROTARY_SW; k++) { // find first enable slot - idx = (idx + inc) & 0x7; // do modulo 8 - if (g_model.mavlink.rotarySw[idx].typeRotary) { - setRotarySwIdx(idx); - return idx; - } - } - setRotarySwIdx(-1); - } - return rotarySwIdx; -} - -inline int8_t get_rotary_value() { - if (g_model.mavlink.rotarySw[rotarySwIdx].typeRotary == ROTARY_TYPE_PPM) { - uint8_t num = g_model.mavlink.rotarySw[rotarySwIdx].numMode; - rotarySwLastPPMVal = g_model.mavlink.modesVal[num]; - } - return rotarySwLastPPMVal; -} - -#endif - diff --git a/src/serial.cpp b/src/serial.cpp index 7f0fadf6f..7d3365738 100644 --- a/src/serial.cpp +++ b/src/serial.cpp @@ -198,7 +198,7 @@ void SERIAL_Init(void) { DDRE &= ~(1 << DDE0); // set RXD0 pin as input PORTE &= ~(1 << PORTE0); // disable pullup on RXD0 pin - uint8_t b = 1; // TODO g_eeGeneral.baudRate; + uint8_t b = 2; // TODO g_eeGeneral.baudRate; if (b == 0) { uart_19200(); diff --git a/src/telemetry/mavlink.cpp b/src/telemetry/mavlink.cpp index ef2434a3a..94e190489 100644 --- a/src/telemetry/mavlink.cpp +++ b/src/telemetry/mavlink.cpp @@ -34,15 +34,18 @@ * GNU General Public License for more details. * */ +/*! \file telemetry_mavlink.cpp + * Mavlink telemetry decoder for Arducopter/Arduplane telemetry information. + */ -#include "opentx.h" -#include "serial.h" -#define DUMP_RX_TX +#include "telemetry/mavlink.h" + +//#define DUMP_RX_TX // this might need to move to the flight software //static -mavlink_system_t mavlink_system = { 7, 1, 0, 0 }; +mavlink_system_t mavlink_system = { 7, MAV_COMP_ID_MISSIONPLANNER, 0, 0, 0, 0 }; //static uint8_t system_id = 7; //static uint8_t component_id = 1; @@ -54,7 +57,7 @@ mavlink_system_t mavlink_system = { 7, 1, 0, 0 }; // Mavlink message decoded Status Text #define PARAM_NB_REPEAT 10 #define LEN_STATUSTEXT 15 -static uint8_t mav_statustext[LEN_STATUSTEXT]; +static char mav_statustext[LEN_STATUSTEXT]; static int8_t mav_heartbeat = 0; static int8_t mav_heartbeat_recv = 0; static int8_t watch_mav_req_id_action = 0; @@ -64,6 +67,7 @@ int8_t watch_mav_req_params_list = 5; static uint8_t mav_req_params_nb_recv = 0; static int8_t watch_mav_req_params_set = 0; + // Telemetry data hold Telemetry_Data_t telemetry_data; @@ -95,6 +99,10 @@ void MAVLINK_rxhandler(uint8_t byte) { SerialFuncP RXHandler = MAVLINK_rxhandler; +/*! \brief Reset basic Mavlink varables + * \todo Figure out exact function + * + */ void MAVLINK_reset(uint8_t warm_reset) { if (warm_reset && telemetry_data.status) { mav_statustext[0] = 0; @@ -120,68 +128,85 @@ void MAVLINK_reset(uint8_t warm_reset) { data_stream_start_stop = 0; } +//! \brief initalize mavlink extension void MAVLINK_Init(void) { mav_statustext[0] = 0; MAVLINK_reset(0); SERIAL_Init(); } +/*! \brief Status log message + * \details Processes the mavlink status messages. This message contains a + * severity and a message. The severity is an enum difined by MAV_SEVERITY also + * see RFC-5424 for the severity levels. + * The original message is maximum 50 characters and is without termination + * character. For readablity on the 9x the only the first 15 (LEN_STATUSTEXT) + * characters are used. To get the full message you can use the commented + * funtion below. + */ static inline void REC_MAVLINK_MSG_ID_STATUSTEXT(const mavlink_message_t* msg) { - //memcpy(mav_statustext, msg->payload + sizeof(uint8_t), sizeof(int8_t) * LEN_STATUSTEXT); - // _MAV_RETURN_int8_t_array(msg, mav_statustext, LEN_STATUSTEXT, 1); - memcpy(mav_statustext, &_MAV_PAYLOAD(msg)[1], LEN_STATUSTEXT); + uint8_t temp = mavlink_msg_statustext_get_severity(msg); + _MAV_RETURN_char_array(msg, mav_statustext, LEN_STATUSTEXT, 1); + //mavlink_msg_statustext_get_text( msg, mav_statustext); } +/*! \brief System status including cpu load, battery status and communication status. + * \details From this message we use use only the batery infomation. The rest + * is not realy of use while flying. The complete message can be decoded in to + * a struct with the first two commented lines. + * The batery votage is in mV. We devide by 100 to display tenths of volts.' + * \todo Add battery remaining variable in telemetry_data struct for estimated + * remaining battery. Decoding funtion allready in place. + */ static inline void REC_MAVLINK_MSG_ID_SYS_STATUS(const mavlink_message_t* msg) { - mavlink_sys_status_t sys_status; - mavlink_msg_sys_status_decode(msg, &sys_status); +// mavlink_sys_status_t sys_status; +// mavlink_msg_sys_status_decode(msg, &sys_status); - telemetry_data.packet_drop = mavlink_msg_sys_status_get_packet_drop(msg); - - uint8_t mode = mavlink_msg_sys_status_get_mode(msg); - uint8_t nav_mode = mavlink_msg_sys_status_get_nav_mode(msg); - telemetry_data.rcv_control_mode = MAVLINK_NavMode2CtrlMode(mode, nav_mode); - //telemetry_data.mode = mode; - //telemetry_data.nav_mode = nav_mode; - - telemetry_data.status = mavlink_msg_sys_status_get_status(msg); - //telemetry_data.load = mavlink_msg_sys_status_get_load(msg); - telemetry_data.vbat = mavlink_msg_sys_status_get_vbat(msg) / 100; // Voltage * 10 + telemetry_data.vbat = mavlink_msg_sys_status_get_voltage_battery(msg) / 100; // Voltage * 10 + int8_t temp = mavlink_msg_sys_status_get_battery_remaining(msg); +#ifdef MAVLINK_PARAMS telemetry_data.vbat_low = (getMavlinParamsValue(BATT_MONITOR) > 0) && (((float) telemetry_data.vbat / 10.0) < getMavlinParamsValue(LOW_VOLT)) && (telemetry_data.vbat > 50); +#endif } -static inline void REC_MAVLINK_MSG_ID_GPS_RAW(const mavlink_message_t* msg) { - telemetry_data.fix_type = mavlink_msg_gps_raw_get_fix_type(msg); - telemetry_data.loc_current.lat = mavlink_msg_gps_raw_get_lat(msg); - telemetry_data.loc_current.lon = mavlink_msg_gps_raw_get_lon(msg); - telemetry_data.loc_current.alt = mavlink_msg_gps_raw_get_alt(msg); - telemetry_data.eph = mavlink_msg_gps_raw_get_eph(msg); - telemetry_data.hdg = mavlink_msg_gps_raw_get_hdg(msg); - telemetry_data.v = mavlink_msg_gps_raw_get_v(msg); +/*! \brief Hardbeat message + * \todo Fix hartbeat * on display title see \link telemetryWakeup telemetryWakeup \endlink + * and \link mav_title mav_title \endlink. + */ +static inline void REC_MAVLINK_MSG_ID_HEARTBEAT(const mavlink_message_t* msg) { + telemetry_data.mode = mavlink_msg_heartbeat_get_base_mode(msg); + telemetry_data.status = mavlink_msg_heartbeat_get_system_status(msg); + mav_heartbeat = 3; // 450ms display '*' + mav_heartbeat_recv = 1; +} +static inline void REC_MAVLINK_MSG_ID_HIL_CONTROLS(const mavlink_message_t* msg) { + telemetry_data.nav_mode = mavlink_msg_hil_controls_get_mode(msg); +} +/*! \brief Process GPS raw intger message + * \details This message contains the following data: + * - fix type: 0-1: no fix, 2: 2D fix, 3: 3D fix. + * - Latitude, longitude in 1E7 * degrees + * - Altutude 1E3 * meters above MSL. + * - Course over ground in 100 * degrees + * - GPS HDOP horizontal dilution of precision in cm (m*100). + * - Ground speed in m/s * 100 + */ +static inline void REC_MAVLINK_MSG_ID_GPS_RAW_INT(const mavlink_message_t* msg) { + telemetry_data.fix_type = mavlink_msg_gps_raw_int_get_fix_type(msg); + telemetry_data.loc_current.lat = mavlink_msg_gps_raw_int_get_lat(msg) / 1E7; + telemetry_data.loc_current.lon = mavlink_msg_gps_raw_int_get_lon(msg) / 1E7; + telemetry_data.loc_current.alt = mavlink_msg_gps_raw_int_get_alt(msg) / 1E3; + telemetry_data.eph = mavlink_msg_gps_raw_int_get_eph(msg) / 100; + telemetry_data.course = mavlink_msg_gps_raw_int_get_cog(msg) / 100; + telemetry_data.v = mavlink_msg_gps_raw_int_get_vel(msg) / 100; } static inline void REC_MAVLINK_MSG_ID_GPS_STATUS(const mavlink_message_t* msg) { telemetry_data.satellites_visible = mavlink_msg_gps_status_get_satellites_visible(msg); } -static inline void REC_MAVLINK_MSG_ID_ACTION_ACK(const mavlink_message_t* msg) { - uint8_t ack_action = mavlink_msg_action_ack_get_action(msg); - telemetry_data.ack_result = mavlink_msg_action_ack_get_result(msg); - uint8_t *ptr = mav_statustext; - if (!telemetry_data.ack_result) - *ptr++ = 'N'; - *ptr++ = 'A'; - *ptr++ = 'C'; - *ptr++ = 'K'; - *ptr++ = ' '; - *ptr++ = ack_action / 10 + '0'; - *ptr++ = ack_action % 10 + '0'; - *ptr++ = 0; - watch_mav_req_id_action = 0; - AUDIO_WARNING1(); -} #ifdef MAVLINK_PARAMS const pm_char * getParamId(uint8_t idx) { @@ -317,8 +342,8 @@ static inline void setParamValue(int8_t *id, float value) { static inline void REC_MAVLINK_MSG_ID_PARAM_VALUE(const mavlink_message_t* msg) { mavlink_param_value_t param_value; mavlink_msg_param_value_decode(msg, ¶m_value); - int8_t *id = param_value.param_id; - setParamValue(id, param_value.param_value); + char *id = param_value.param_id; + setParamValue((int8_t*)id, param_value.param_value); data_stream_start_stop = 0; // stop data stream while getting params list watch_mav_req_params_list = mav_req_params_nb_recv < (NB_PARAMS - 5) ? 20 : 0; // stop timeout } @@ -327,8 +352,7 @@ static inline void REC_MAVLINK_MSG_ID_PARAM_VALUE(const mavlink_message_t* msg) static inline void handleMessage(mavlink_message_t* p_rxmsg) { switch (p_rxmsg->msgid) { case MAVLINK_MSG_ID_HEARTBEAT: - mav_heartbeat = 3; // 450ms display '*' - mav_heartbeat_recv = 1; + REC_MAVLINK_MSG_ID_HEARTBEAT(p_rxmsg); break; case MAVLINK_MSG_ID_STATUSTEXT: REC_MAVLINK_MSG_ID_STATUSTEXT(p_rxmsg); @@ -338,15 +362,15 @@ static inline void handleMessage(mavlink_message_t* p_rxmsg) { REC_MAVLINK_MSG_ID_SYS_STATUS(p_rxmsg); watch_mav_req_start_data_stream = 20; break; - case MAVLINK_MSG_ID_GPS_RAW: - REC_MAVLINK_MSG_ID_GPS_RAW(p_rxmsg); + case MAVLINK_MSG_ID_HIL_CONTROLS: + REC_MAVLINK_MSG_ID_HIL_CONTROLS(p_rxmsg); + break; + case MAVLINK_MSG_ID_GPS_RAW_INT: + REC_MAVLINK_MSG_ID_GPS_RAW_INT(p_rxmsg); break; case MAVLINK_MSG_ID_GPS_STATUS: REC_MAVLINK_MSG_ID_GPS_STATUS(p_rxmsg); break; - case MAVLINK_MSG_ID_ACTION_ACK: - REC_MAVLINK_MSG_ID_ACTION_ACK(p_rxmsg); - break; #ifdef MAVLINK_PARAMS case MAVLINK_MSG_ID_PARAM_VALUE: REC_MAVLINK_MSG_ID_PARAM_VALUE(p_rxmsg); @@ -357,28 +381,28 @@ static inline void handleMessage(mavlink_message_t* p_rxmsg) { } -#if 0 + +/*! \brief Mavlink message parser + * \details Parses the characters in to a mavlink message. + * Case statement parses each character as it is recieved. + * \attention One big change form the 0.9 to 1.0 version is the + * MAVLINK_CRC_EXTRA. This requires the mavlink_message_crcs array of 256 bytes. + * \todo create dot for the statemachine + */ static void MAVLINK_parse_char(uint8_t c) { -// mavlink_message_t msg; -// mavlink_status_t status; static mavlink_message_t m_mavlink_message; - static mavlink_status_t m_mavlink_status; - mavlink_message_t *p_rxmsg = &m_mavlink_message;///< The currently decoded message - mavlink_status_t *p_status = &m_mavlink_status;///< The current decode status - - if (mavlink_parse_char(MAVLINK_COMM_0, c, p_rxmsg, p_status)) { - handleMessage(p_rxmsg); - } -} + //! The currently decoded message + static mavlink_message_t* p_rxmsg = &m_mavlink_message; + //! The current decode status + mavlink_status_t* p_status = mavlink_get_channel_status(MAVLINK_COMM_0); + + +#if MAVLINK_CRC_EXTRA + static const uint8_t mavlink_message_crcs[256] = MAVLINK_MESSAGE_CRCS; +#define MAVLINK_MESSAGE_CRC(msgid) mavlink_message_crcs[msgid] #endif -static void MAVLINK_parse_char(uint8_t c) { - - static mavlink_message_t m_mavlink_message; - static mavlink_message_t* p_rxmsg = &m_mavlink_message; ///< The currently decoded message - mavlink_status_t* p_status = mavlink_get_channel_status(MAVLINK_COMM_0); ///< The current decode status - // Initializes only once, values keep unchanged after first initialization //mavlink_parse_state_initialize(p_status); @@ -430,7 +454,7 @@ static void MAVLINK_parse_char(uint8_t c) { break; case MAVLINK_PARSE_STATE_GOT_MSGID: - _MAV_PAYLOAD(p_rxmsg)[p_status->packet_idx++] = (char) c; + _MAV_PAYLOAD_NON_CONST(p_rxmsg)[p_status->packet_idx++] = (char) c; mavlink_update_checksum(p_rxmsg, c); if (p_status->packet_idx == p_rxmsg->len) { p_status->parse_state = MAVLINK_PARSE_STATE_GOT_PAYLOAD; @@ -438,6 +462,10 @@ static void MAVLINK_parse_char(uint8_t c) { break; case MAVLINK_PARSE_STATE_GOT_PAYLOAD: + +#if MAVLINK_CRC_EXTRA + mavlink_update_checksum(p_rxmsg, MAVLINK_MESSAGE_CRC(p_rxmsg->msgid)); +#endif if (c != (p_rxmsg->checksum & 0xFF)) { // Check first checksum byte p_status->parse_error = 3; @@ -458,7 +486,6 @@ static void MAVLINK_parse_char(uint8_t c) { //p_status->msg_received = 1; p_status->parse_state = MAVLINK_PARSE_STATE_IDLE; //memcpy(r_message, p_rxmsg, sizeof(mavlink_message_t)); - handleMessage(p_rxmsg); } break; @@ -515,7 +542,10 @@ static inline void MAVLINK_msg_param_set(uint8_t idx) { float param_value = getParam(idx)->value; mavlink_channel_t chan = MAVLINK_COMM_0; - mavlink_msg_param_set_send(chan, mavlink_system.sysid, mavlink_system.compid, buf, param_value); + uint8_t param_type = (uint8_t)MAV_PARAM_TYPE_REAL32; + const char* param_id = (const char*)buf; + mavlink_msg_param_set_send(chan, mavlink_system.sysid, mavlink_system.compid, param_id, param_value, param_type); + } #endif @@ -526,26 +556,31 @@ static inline void MAVLINK_msg_request_data_stream_pack_send(uint8_t req_stream_ start_stop); } +//! \brief old mode switch funtion static inline void MAVLINK_msg_action_pack_send(uint8_t action) { - mavlink_channel_t chan = MAVLINK_COMM_0; - mavlink_msg_action_send(chan, mavlink_system.sysid, mavlink_system.compid, action); +// mavlink_channel_t chan = MAVLINK_COMM_0; +// mavlink_msg_action_send(chan, mavlink_system.sysid, mavlink_system.compid, action); } +//! \brief old mode switch funtion static inline void MAVLINK_msg_set_mode_send(uint8_t mode) { mavlink_channel_t chan = MAVLINK_COMM_0; - mavlink_msg_set_mode_send(chan, mavlink_system.sysid, mode); + mavlink_msg_set_mode_send(chan, mavlink_system.sysid, mode, 0); } +/*! \brief Looks like som kind of task switcher on a timer + * \todo Figure out wher this was used for and intergrate in current implemnetation. + */ void MAVLINK10mspoll(uint8_t count) { switch (count) { case 2: // MAVLINK_MSG_ID_ACTION if (watch_mav_req_id_action > 0) { watch_mav_req_id_action--; // Repeat is not ack : 150ms*0x07 - if ((watch_mav_req_id_action & 0x07) == 0 && telemetry_data.req_mode < NUM_MODES) { + if ((watch_mav_req_id_action & 0x07) == 0) { uint8_t action = MAVLINK_CtrlMode2Action(telemetry_data.req_mode); MAVLINK_msg_action_pack_send(action); - uint8_t *ptr = mav_statustext; + char *ptr = mav_statustext; *ptr++ = 'R'; *ptr++ = 'Q'; *ptr++ = ' '; @@ -560,6 +595,7 @@ void MAVLINK10mspoll(uint8_t count) { } } break; +#ifdef MAVLINK_PARAMS case 4: // MAVLINK_MSG_ID_PARAM_REQUEST_LIST if (watch_mav_req_params_list > 0) { watch_mav_req_params_list--; @@ -570,7 +606,7 @@ void MAVLINK10mspoll(uint8_t count) { } } break; - +#endif case 6: // MAVLINK_MSG_ID_REQUEST_DATA_STREAM if (watch_mav_req_start_data_stream > 0) { watch_mav_req_start_data_stream--; @@ -584,6 +620,7 @@ void MAVLINK10mspoll(uint8_t count) { } } break; +#ifdef MAVLINK_PARAMS case 8: // MAVLINK_MSG_ID_PARAM_SET if (watch_mav_req_params_set > 0) { watch_mav_req_params_set--; @@ -599,12 +636,17 @@ void MAVLINK10mspoll(uint8_t count) { } } break; - +#endif default: return; } } +/*! \brief Telemetry monitoring, calls \link MAVLINK10mspoll. + * \todo add #if defined(FRSKY) || defined(MAVLINK) to line 3487 + * of opentx.cpp to add a call to telemetryWakeup from void perMain(). + * + */ void telemetryWakeup() { uint16_t tmr10ms = get_tmr10ms(); uint8_t count = tmr10ms & 0x0f; // 15*10ms @@ -623,293 +665,3 @@ void telemetryWakeup() { MAVLINK10mspoll(count); } } - -// Start of Mavlink menus <<<<<<<<<<<<<<<<<<<<<<<<<<< -void displayScreenIndex(uint8_t index, uint8_t count, uint8_t attr); - -enum mavlink_menu_ { - MENU_INFO = 0, // - MENU_GPS, // -#ifdef DUMP_RX_TX - MENU_DUMP_RX, // - MENU_DUMP_TX, // -#endif - MAX_MAVLINK_MENU -}; - -uint8_t MAVLINK_menu = MENU_INFO; - -void mav_title(const pm_char * s, uint8_t index) -{ - lcd_putsAtt(0, 0, PSTR("MAVLINK"), INVERS); - lcd_puts(10 * FW, 0, s); - displayScreenIndex(index, MAX_MAVLINK_MENU, INVERS); - lcd_putc(8 * FW, 0, (mav_heartbeat > 0) ? '*' : ' '); -} - -void lcd_outdezFloat(uint8_t x, uint8_t y, float val, uint8_t precis, uint8_t mode = 0) { - char c; - int16_t lnum = val; - uint8_t x1 = x; - val -= lnum; - - int8_t i = 0; - lnum = abs(lnum); - for (; i < 4; i++) { - c = (lnum % 10) + '0'; - x1 -= FWNUM; - lcd_putcAtt(x1, y, c, mode); - lnum /= 10; - if (lnum == 0) { - break; - } - } - if (lnum != 0) { - // Error number too big - x1 = x; - for (i = 0; i < 4; i++) { - x1 -= FW; - lcd_putcAtt(x1, y, '?', mode); - } - } else { - if (val < 0) { - val = -val; - x1 -= FWNUM; - lcd_putcAtt(x1, y, '-', mode); - } - if (precis) - lcd_putcAtt(x, y, '.', mode); - - for (i = 0; i < precis; i++) { - val *= 10; - int a = val; - c = a + '0'; - x += FWNUM; - lcd_putcAtt(x, y, c, mode); - val -= a; - } - } -} - -bool isValidReqControlMode() -{ - if (telemetry_data.req_mode < NUM_MODES) { - if (telemetry_data.req_mode != telemetry_data.rcv_control_mode) { - return false; - } - } - return true; -} - -void putsMavlinkControlMode(uint8_t x, uint8_t y, uint8_t len) { - if (telemetry_data.status) { - uint8_t attr = 0; - uint8_t mode = telemetry_data.rcv_control_mode; - if (telemetry_data.req_mode < NUM_MODES) { - - if (telemetry_data.req_mode != telemetry_data.rcv_control_mode) { - attr = INVERS; - switch (telemetry_data.ack_result) { - case 5: - AUDIO_ERROR(); - telemetry_data.req_mode = NUM_MODES; - break; - default: - //mode = telemetry_data.req_mode; - break; - } - } - } - putsControlMode(x, y, mode, attr, len); - } -} - -void MAVLINK_ReqMode(uint8_t mode, uint8_t send) { - telemetry_data.req_mode = mode; - telemetry_data.ack_result = 0; - if (send) { - watch_mav_req_id_action = 0x43; - } -} - -void menuTelemetryMavlinkInfos(void) { - - mav_title(PSTR("INFOS"), MAVLINK_menu); - - uint8_t x1, x2, xnum, y; - x1 = FW; - x2 = 7 * FW; - xnum = x2 + 5 * FWNUM; - y = FH; - - uint8_t * ptr = mav_statustext; - for (uint8_t j = 0; j < LEN_STATUSTEXT; j++) { - if (*ptr == 0) { - lcd_putc(x1, y, ' '); - } else { - lcd_putc(x1, y, *ptr++); - } - x1 += FW; - } - x1 = FW; - y += FH; - - if (telemetry_data.status) { - if (!isValidReqControlMode()) { - lcd_puts(x1, y, PSTR("REQ")); - putsControlMode(x2, y, telemetry_data.req_mode, 0, 6); - y += FH; - } - lcd_puts(x1, y, PSTR("MODE")); - putsMavlinkControlMode(x2, y, 6); - - y += FH; - lcd_puts(x1, y, PSTR("BATT")); - lcd_outdezNAtt(xnum, y, telemetry_data.vbat, PREC1, 5); - - y += FH; - lcd_puts(x1, y, PSTR("DROP")); - lcd_outdezAtt(xnum, y, telemetry_data.packet_drop, 0); - - } - -} - -void menuTelemetryMavlinkGPS(void) { - mav_title(PSTR("GPS"), MAVLINK_menu); - - uint8_t x1, x2, xnum, y; - x1 = FW; - x2 = 5 * FW + FWNUM; - xnum = 5 * FW + 3 * FWNUM; - y = FH; - - lcd_putsnAtt(x1, y, PSTR("GPS"), 3, 0); - uint8_t fix_type = telemetry_data.fix_type; - if (fix_type <= 2) { - lcd_putsnAtt(x2, y, PSTR("__NOOK") + 2 * fix_type, 2, 0); - } else { - lcd_outdezNAtt(xnum, y, fix_type, 0, 3); - } - lcd_puts(x2 + 5 * FW, y, PSTR("SAT")); - lcd_outdezNAtt(x2 + 8 * FW + 3 * FWNUM, y, telemetry_data.satellites_visible, 0, 2); - -// if (telemetry_data.fix_type > 0) { - y += FH; - lcd_puts(0, y, PSTR("HDOP")); - lcd_outdezFloat(xnum, y, telemetry_data.eph, 2); - - y += FH; - lcd_puts(0, y, PSTR("COOR")); - lcd_outdezFloat(xnum, y, telemetry_data.loc_current.lat, 5); - - // y += FH; - // lcd_putsnAtt(x1, y, PSTR("LON"), 3, 0); - lcd_outdezFloat(xnum + 10 * FWNUM, y, telemetry_data.loc_current.lon, 5); - - y += FH; - lcd_putsnAtt(x1, y, PSTR("ALT"), 3, 0); - lcd_outdezFloat(xnum, y, telemetry_data.loc_current.alt, 2); - - y += FH; - lcd_putsnAtt(x1, y, PSTR("HDG"), 3, 0); - lcd_outdezFloat(xnum, y, telemetry_data.hdg, 2); - - y += FH; - lcd_putsnAtt(x1, y, PSTR("V"), 1, 0); - lcd_outdezFloat(xnum, y, telemetry_data.v, 2); - //} -} - -#ifdef DUMP_RX_TX - -void lcd_outhex2(uint8_t x, uint8_t y, uint8_t val) { - x += FWNUM * 2; - for (int i = 0; i < 2; i++) { - x -= FWNUM; - char c = val & 0xf; - c = c > 9 ? c + 'A' - 10 : c + '0'; - lcd_putcAtt(x, y, c, c >= 'A' ? CONDENSED : 0); - val >>= 4; - } -} - -void menuTelemetryMavlinkDump(uint8_t event) { - uint8_t x = 0; - uint8_t y = FH; - uint16_t count = 0; - uint16_t bufferLen = 0; - uint8_t *ptr = NULL; - switch (MAVLINK_menu) { - case MENU_DUMP_RX: - mav_dump_rx = 1; - mav_title(PSTR("RX"), MAVLINK_menu); - bufferLen = mavlinkRxBufferCount; - ptr = mavlinkRxBuffer; - break; - - case MENU_DUMP_TX: - mav_title(PSTR("TX"), MAVLINK_menu); - bufferLen = serialTxBufferCount; - ptr = ptrTxISR; - break; - default: - break; - } - for (uint16_t var = 0; var < bufferLen; var++) { - uint8_t byte = *ptr++; - lcd_outhex2(x, y, byte); - x += 2 * FW; - count++; - if (count > 8) { - count = 0; - x = 0; - y += FH; - if (y == (6 * FH)) - break; - } - } -} -#endif - -void menuTelemetryMavlink(uint8_t event) { - - switch (event) // new event received, branch accordingly - { - case EVT_ENTRY: - MAVLINK_menu = MENU_INFO; - break; - - case EVT_KEY_FIRST(KEY_UP): - MAVLINK_menu--; - break; - case EVT_KEY_FIRST(KEY_DOWN): - MAVLINK_menu++; - break; - case EVT_KEY_FIRST(KEY_MENU): - case EVT_KEY_FIRST(KEY_EXIT): - //MAVLINK_Quit(); - chainMenu(menuMainView); - return; - } - - switch (MAVLINK_menu) { - case MENU_INFO: - menuTelemetryMavlinkInfos(); - break; - case MENU_GPS: - menuTelemetryMavlinkGPS(); - break; -#ifdef DUMP_RX_TX - case MENU_DUMP_TX: - case MENU_DUMP_RX: - menuTelemetryMavlinkDump(event); - break; -#endif - - default: - break; - } - -} - diff --git a/src/telemetry/mavlink.h b/src/telemetry/mavlink.h index 37cb62425..7ab1ae071 100644 --- a/src/telemetry/mavlink.h +++ b/src/telemetry/mavlink.h @@ -20,16 +20,10 @@ #define MAVLINK_USE_CONVENIENCE_FUNCTIONS #define MAVLINK_COMM_NUM_BUFFERS 1 -//#define MAVLINK10 - -#ifdef MAVLINK10 #include "GCS_MAVLink/include_v1.0/mavlink_types.h" -#else -#include "GCS_MAVLink/include/mavlink_types.h" -#endif - #include "serial.h" - +#include "opentx.h" +#include "serial.h" //#include "include/mavlink_helpers.h" extern mavlink_system_t mavlink_system; @@ -42,17 +36,18 @@ extern void SERIAL_send_uart_bytes(uint8_t * buf, uint16_t len); #define MAVLINK_END_UART_SEND(chan,len) SERIAL_end_uart_send() #define MAVLINK_SEND_UART_BYTES(chan,buf,len) SERIAL_send_uart_bytes(buf,len) -#ifdef MAVLINK10 -#include "GCS_MAVLink/include_v1.0/ardupilotmega/mavlink.h" -#else -#include "GCS_MAVLink/include/ardupilotmega/mavlink.h" -#endif - -#define MAVLINK_PARAMS +#include "../GCS_MAVLink/include_v1.0/ardupilotmega/mavlink.h" +//#define MAVLINK_PARAMS +//#define DUMP_RX_TX #define ERROR_NUM_MODES 99 #define ERROR_MAV_ACTION_NB 99 + +/* + * Type definitions + */ + #ifdef MAVLINK_PARAMS enum ACM_PARAMS { @@ -76,7 +71,7 @@ enum ACM_PARAMS { HLD_LAT_I, // Loiter NAV_LON_P, // Nav WP NAV_LON_I, // Nav WP - NAV_LAT_P, // Nav WP + NAV_LAT_P, // Nav WPs NAV_LAT_I, // Nav WP NB_PID_PARAMS, // Number of PI Parameters LOW_VOLT = NB_PID_PARAMS, @@ -107,12 +102,14 @@ typedef struct Telemetry_Data_ { // INFOS uint8_t status; ///< System status flag, see MAV_STATUS ENUM uint16_t packet_drop; - //uint8_t mode; - //uint8_t nav_mode; + uint8_t mode; + uint8_t nav_mode; uint8_t rcv_control_mode; ///< System mode, see MAV_MODE ENUM in mavlink/include/mavlink_types.h - //uint16_t load; ///< Maximum usage in percent of the mainloop time, (0%: 0, 100%: 1000) should be always below 1000 + uint16_t load; ///< Maximum usage in percent of the mainloop time, (0%: 0, 100%: 1000) should be always below 1000 uint8_t vbat; ///< Battery voltage, in millivolts (1 = 1 millivolt) uint8_t vbat_low; + + uint8_t debug; // MSG ACTION / ACK uint8_t req_mode; @@ -123,8 +120,11 @@ typedef struct Telemetry_Data_ { uint8_t satellites_visible; ///< Number of satellites visible Location_t loc_current; float eph; - float hdg; + float course; float v; // Ground speed + // Navigation + float heading; + float bearing; #ifdef MAVLINK_PARAMS // Params @@ -136,126 +136,24 @@ typedef struct Telemetry_Data_ { // Telemetry data hold extern Telemetry_Data_t telemetry_data; -#ifndef MAVLINK10 -extern inline uint8_t MAVLINK_NavMode2CtrlMode(uint8_t mode, uint8_t nav_mode) { +/* + * Funtion definitions + */ - uint8_t control_mode = ERROR_NUM_MODES; - switch (mode) { - case MAV_MODE_UNINIT: - control_mode = INITIALISING; - break; - case MAV_MODE_AUTO: - switch (nav_mode) { - case MAV_NAV_HOLD: // ACM - case MAV_NAV_LOITER: // APM - control_mode = LOITER; - break; - case MAV_NAV_WAYPOINT: - control_mode = AUTO; - break; - case MAV_NAV_RETURNING: - control_mode = RTL; - break; - } - break; - case MAV_MODE_GUIDED: - control_mode = GUIDED; - break; - /* from ardupilot */ - case MAV_MODE_MANUAL: - control_mode = MANUAL; - break; - case MAV_MODE_TEST1: - control_mode = STABILIZE; - break; - case MAV_MODE_TEST2: - switch (nav_mode) { - case 1: - control_mode = FLY_BY_WIRE_A; - break; - case 2: - control_mode = FLY_BY_WIRE_B; - break; - } - break; - case MAV_MODE_TEST3: - control_mode = CIRCLE; - break; - default: - if (mode >= 100) { - control_mode = mode - 100; - } - break; - } - return control_mode; -} -#endif extern inline uint8_t MAVLINK_CtrlMode2Action(uint8_t mode) { uint8_t action; - switch (mode) { - case STABILIZE: - action = MAV_ACTION_SET_MANUAL; - break; - case RTL: - action = MAV_ACTION_RETURN; - break; - case LAND: - action = MAV_ACTION_LAND; - break; - case LOITER: - action = MAV_ACTION_LOITER; - break; - case AUTO: - action = MAV_ACTION_SET_AUTO; - break; - case MANUAL: - action = MAV_ACTION_SET_MANUAL; - break; - default: - action = ERROR_MAV_ACTION_NB; - break; - } + return action; } #if 0 extern inline uint8_t MAVLINK_Action2CtrlMode(uint8_t action) { uint8_t mode = ERROR_NUM_MODES; switch (action) { - case MAV_ACTION_SET_MANUAL: - mode = STABILIZE; - break; - /* - case ACRO: - action = 0; - break; - case SIMPLE: - action = 0; - break; - case ALT_HOLD: - action = 0; - break;*/ - case MAV_ACTION_SET_AUTO: - mode = AUTO; - break; - /*case GUIDED: - action = 0; - break;*/ - case MAV_ACTION_LOITER: - mode = LOITER; - break; - case MAV_ACTION_RETURN: - mode = RTL; - break; - /*case CIRCLE: - action = 0; - break;*/ - default: - break; - } + return action; } #endif