forked from Archive/PX4-Autopilot
add parameter to mavlink app to allow parsing of HIL GPS message even if not in HIL mode
Conflicts: src/modules/mavlink/mavlink_receiver.cpp
This commit is contained in:
parent
aefea1a95d
commit
a2940182ef
|
@ -62,6 +62,12 @@ PARAM_DEFINE_INT32(MAV_COMP_ID, 50);
|
||||||
* @group MAVLink
|
* @group MAVLink
|
||||||
*/
|
*/
|
||||||
PARAM_DEFINE_INT32(MAV_TYPE, MAV_TYPE_FIXED_WING);
|
PARAM_DEFINE_INT32(MAV_TYPE, MAV_TYPE_FIXED_WING);
|
||||||
|
/**
|
||||||
|
* Use/Accept HIL GPS message (even if not in HIL mode)
|
||||||
|
* If set to 1 incomming HIL GPS messages are parsed.
|
||||||
|
* @group MAVLink
|
||||||
|
*/
|
||||||
|
PARAM_DEFINE_INT32(MAV_USEHILGPS, 0);
|
||||||
|
|
||||||
mavlink_system_t mavlink_system = {
|
mavlink_system_t mavlink_system = {
|
||||||
100,
|
100,
|
||||||
|
|
|
@ -208,6 +208,7 @@ Mavlink::Mavlink() :
|
||||||
_mavlink_fd(-1),
|
_mavlink_fd(-1),
|
||||||
_task_running(false),
|
_task_running(false),
|
||||||
_hil_enabled(false),
|
_hil_enabled(false),
|
||||||
|
_use_hil_gps(false),
|
||||||
_is_usb_uart(false),
|
_is_usb_uart(false),
|
||||||
_wait_to_transmit(false),
|
_wait_to_transmit(false),
|
||||||
_received_messages(false),
|
_received_messages(false),
|
||||||
|
@ -487,11 +488,13 @@ void Mavlink::mavlink_update_system(void)
|
||||||
static param_t param_system_id;
|
static param_t param_system_id;
|
||||||
static param_t param_component_id;
|
static param_t param_component_id;
|
||||||
static param_t param_system_type;
|
static param_t param_system_type;
|
||||||
|
static param_t param_use_hil_gps;
|
||||||
|
|
||||||
if (!initialized) {
|
if (!initialized) {
|
||||||
param_system_id = param_find("MAV_SYS_ID");
|
param_system_id = param_find("MAV_SYS_ID");
|
||||||
param_component_id = param_find("MAV_COMP_ID");
|
param_component_id = param_find("MAV_COMP_ID");
|
||||||
param_system_type = param_find("MAV_TYPE");
|
param_system_type = param_find("MAV_TYPE");
|
||||||
|
param_use_hil_gps = param_find("MAV_USEHILGPS");
|
||||||
initialized = true;
|
initialized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -516,6 +519,11 @@ void Mavlink::mavlink_update_system(void)
|
||||||
if (system_type >= 0 && system_type < MAV_TYPE_ENUM_END) {
|
if (system_type >= 0 && system_type < MAV_TYPE_ENUM_END) {
|
||||||
mavlink_system.type = system_type;
|
mavlink_system.type = system_type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t use_hil_gps;
|
||||||
|
param_get(param_use_hil_gps, &use_hil_gps);
|
||||||
|
|
||||||
|
_use_hil_gps = (bool)use_hil_gps;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Mavlink::mavlink_open_uart(int baud, const char *uart_name, struct termios *uart_config_original, bool *is_usb)
|
int Mavlink::mavlink_open_uart(int baud, const char *uart_name, struct termios *uart_config_original, bool *is_usb)
|
||||||
|
|
|
@ -157,6 +157,8 @@ public:
|
||||||
|
|
||||||
bool get_hil_enabled() { return _hil_enabled; }
|
bool get_hil_enabled() { return _hil_enabled; }
|
||||||
|
|
||||||
|
bool get_use_hil_gps() { return _use_hil_gps; }
|
||||||
|
|
||||||
bool get_flow_control_enabled() { return _flow_control_enabled; }
|
bool get_flow_control_enabled() { return _flow_control_enabled; }
|
||||||
|
|
||||||
bool get_forwarding_on() { return _forwarding_on; }
|
bool get_forwarding_on() { return _forwarding_on; }
|
||||||
|
@ -223,6 +225,7 @@ private:
|
||||||
|
|
||||||
/* states */
|
/* states */
|
||||||
bool _hil_enabled; /**< Hardware In the Loop mode */
|
bool _hil_enabled; /**< Hardware In the Loop mode */
|
||||||
|
bool _use_hil_gps; /**< Accept GPS HIL messages (for example from an external motion capturing system to fake indoor gps) */
|
||||||
bool _is_usb_uart; /**< Port is USB */
|
bool _is_usb_uart; /**< Port is USB */
|
||||||
bool _wait_to_transmit; /**< Wait to transmit until received messages. */
|
bool _wait_to_transmit; /**< Wait to transmit until received messages. */
|
||||||
bool _received_messages; /**< Whether we've received valid mavlink messages. */
|
bool _received_messages; /**< Whether we've received valid mavlink messages. */
|
||||||
|
|
|
@ -162,6 +162,9 @@ MavlinkReceiver::handle_message(mavlink_message_t *msg)
|
||||||
* The HIL mode is enabled by the HIL bit flag
|
* The HIL mode is enabled by the HIL bit flag
|
||||||
* in the system mode. Either send a set mode
|
* in the system mode. Either send a set mode
|
||||||
* COMMAND_LONG message or a SET_MODE message
|
* COMMAND_LONG message or a SET_MODE message
|
||||||
|
*
|
||||||
|
* Accept HIL GPS messages if use_hil_gps flag is true.
|
||||||
|
* This allows to provide fake gps measurements to the system.
|
||||||
*/
|
*/
|
||||||
if (_mavlink->get_hil_enabled()) {
|
if (_mavlink->get_hil_enabled()) {
|
||||||
switch (msg->msgid) {
|
switch (msg->msgid) {
|
||||||
|
@ -169,10 +172,6 @@ MavlinkReceiver::handle_message(mavlink_message_t *msg)
|
||||||
handle_message_hil_sensor(msg);
|
handle_message_hil_sensor(msg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MAVLINK_MSG_ID_HIL_GPS:
|
|
||||||
handle_message_hil_gps(msg);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case MAVLINK_MSG_ID_HIL_STATE_QUATERNION:
|
case MAVLINK_MSG_ID_HIL_STATE_QUATERNION:
|
||||||
handle_message_hil_state_quaternion(msg);
|
handle_message_hil_state_quaternion(msg);
|
||||||
break;
|
break;
|
||||||
|
@ -182,6 +181,19 @@ MavlinkReceiver::handle_message(mavlink_message_t *msg)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (_mavlink->get_hil_enabled() || _mavlink->get_use_hil_gps()) {
|
||||||
|
switch (msg->msgid) {
|
||||||
|
case MAVLINK_MSG_ID_HIL_GPS:
|
||||||
|
handle_message_hil_gps(msg);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/* If we've received a valid message, mark the flag indicating so.
|
/* If we've received a valid message, mark the flag indicating so.
|
||||||
This is used in the '-w' command-line flag. */
|
This is used in the '-w' command-line flag. */
|
||||||
_mavlink->set_has_received_messages(true);
|
_mavlink->set_has_received_messages(true);
|
||||||
|
|
Loading…
Reference in New Issue