Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

simulator in hardware, new module #11400

Closed
wants to merge 15 commits into from
Closed
Show file tree
Hide file tree
Changes from 13 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 17 additions & 0 deletions ROMFS/px4fmu_common/init.d/airframes/1100_rc_quad_x_sih.hil
@@ -0,0 +1,17 @@
#!/bin/sh
#
# @name SIH Quadcopter X
#
# @type Simulation
romain-chiap marked this conversation as resolved.
Show resolved Hide resolved
# @class Copter
#
# @maintainer Romain Chiappinelli <romain.chiap@gmail.com>
#

sh /etc/init.d/rc.mc_defaults

set MIXER quad_x
set PWM_OUT 1234

# set SYS_HITL to 2 to start the SIH and avoid sensors startup
param set SYS_HITL 2
1 change: 1 addition & 0 deletions ROMFS/px4fmu_common/init.d/airframes/CMakeLists.txt
Expand Up @@ -38,6 +38,7 @@ px4_add_romfs_files(
1000_rc_fw_easystar.hil
1001_rc_quad_x.hil
1002_standard_vtol.hil
1100_rc_quad_x_sih.hil

# [2000, 2999] Standard planes"
2100_standard_plane
Expand Down
2 changes: 1 addition & 1 deletion ROMFS/px4fmu_common/init.d/rc.interface
Expand Up @@ -202,7 +202,7 @@ then
if fmu mode_${AUX_MODE} $FMU_ARGS
then
# Append aux mixer to main device.
if param compare SYS_HITL 1
if param greater SYS_HITL 0
then
if mixer append ${OUTPUT_DEV} ${MIXER_AUX_FILE}
then
Expand Down
9 changes: 7 additions & 2 deletions ROMFS/px4fmu_common/init.d/rcS
Expand Up @@ -324,15 +324,20 @@ else
# Sensors System (start before Commander so Preflight checks are properly run).
# Commander needs to be this early for in-air-restarts.
#
if param compare SYS_HITL 1
if param greater SYS_HITL 0
then
set OUTPUT_MODE hil
sensors start -h
commander start --hil

# disable GPS
param set GPS_1_CONFIG 0

# start the simulator in hardware if needed
if param compare SYS_HITL 2
then
sih start
fi

else
#
# board sensors: rc.sensors
Expand Down
2 changes: 1 addition & 1 deletion Tools/px4moduledoc/srcparser.py
Expand Up @@ -9,7 +9,7 @@ class ModuleDocumentation(object):
"""

valid_categories = ['driver', 'estimator', 'controller', 'system',
'communication', 'command', 'template']
'communication', 'command', 'template','simulation']

max_line_length = 80 # wrap lines that are longer than this

Expand Down
1 change: 1 addition & 0 deletions boards/aerotenna/ocpoc/ubuntu.cmake
Expand Up @@ -49,6 +49,7 @@ px4_add_board(
mc_pos_control
navigator
sensors
sih
#simulator
vmount
vtol_att_control
Expand Down
1 change: 1 addition & 0 deletions boards/airmind/mindpx-v2/default.cmake
Expand Up @@ -69,6 +69,7 @@ px4_add_board(
mc_pos_control
navigator
sensors
sih
vmount
vtol_att_control
wind_estimator
Expand Down
1 change: 1 addition & 0 deletions boards/atlflight/eagle/default.cmake
Expand Up @@ -84,6 +84,7 @@ px4_add_board(
mc_pos_control
navigator
sensors
sih
simulator
vmount
vtol_att_control
Expand Down
1 change: 1 addition & 0 deletions boards/atlflight/eagle/qurt-default.cmake
Expand Up @@ -74,6 +74,7 @@ px4_add_board(
mc_att_control
mc_pos_control
sensors
sih
vmount
vtol_att_control
wind_estimator
Expand Down
1 change: 1 addition & 0 deletions boards/atlflight/excelsior/default.cmake
Expand Up @@ -84,6 +84,7 @@ px4_add_board(
mc_pos_control
navigator
sensors
sih
simulator
vmount
vtol_att_control
Expand Down
1 change: 1 addition & 0 deletions boards/atlflight/excelsior/qurt-default.cmake
Expand Up @@ -74,6 +74,7 @@ px4_add_board(
mc_att_control
mc_pos_control
sensors
sih
vmount
vtol_att_control
wind_estimator
Expand Down
1 change: 1 addition & 0 deletions boards/auav/x21/default.cmake
Expand Up @@ -74,6 +74,7 @@ px4_add_board(
mc_pos_control
navigator
sensors
sih
vmount
vtol_att_control
wind_estimator
Expand Down
1 change: 1 addition & 0 deletions boards/av/x-v1/default.cmake
Expand Up @@ -74,6 +74,7 @@ px4_add_board(
mc_pos_control
navigator
sensors
sih
vmount
vtol_att_control
wind_estimator
Expand Down
1 change: 1 addition & 0 deletions boards/beaglebone/blue/cross.cmake
Expand Up @@ -48,6 +48,7 @@ px4_add_board(
mc_pos_control
navigator
sensors
sih
vmount
vtol_att_control
wind_estimator
Expand Down
1 change: 1 addition & 0 deletions boards/beaglebone/blue/native.cmake
Expand Up @@ -46,6 +46,7 @@ px4_add_board(
mc_pos_control
navigator
sensors
sih
vmount
vtol_att_control
wind_estimator
Expand Down
1 change: 1 addition & 0 deletions boards/bitcraze/crazyflie/default.cmake
Expand Up @@ -37,6 +37,7 @@ px4_add_board(
mc_pos_control
navigator
sensors
sih
#vtol_att_control
wind_estimator

Expand Down
1 change: 1 addition & 0 deletions boards/emlid/navio2/cross.cmake
Expand Up @@ -52,6 +52,7 @@ px4_add_board(
mc_pos_control
navigator
sensors
sih
#simulator
vmount
vtol_att_control
Expand Down
1 change: 1 addition & 0 deletions boards/emlid/navio2/native.cmake
Expand Up @@ -50,6 +50,7 @@ px4_add_board(
mc_pos_control
navigator
sensors
sih
#simulator
vmount
vtol_att_control
Expand Down
1 change: 1 addition & 0 deletions boards/gumstix/aerocore2/default.cmake
Expand Up @@ -72,6 +72,7 @@ px4_add_board(
navigator
#position_estimator_inav
sensors
sih
vmount
#vtol_att_control
#wind_estimator
Expand Down
1 change: 1 addition & 0 deletions boards/intel/aerofc-v1/default.cmake
Expand Up @@ -53,6 +53,7 @@ px4_add_board(
mc_pos_control
navigator
sensors
sih
vmount
#vtol_att_control
#wind_estimator
Expand Down
1 change: 1 addition & 0 deletions boards/intel/aerofc-v1/rtps.cmake
Expand Up @@ -56,6 +56,7 @@ px4_add_board(
micrortps_bridge
navigator
sensors
sih
vmount
#vtol_att_control
#wind_estimator
Expand Down
1 change: 1 addition & 0 deletions boards/nxp/fmuk66-v3/default.cmake
Expand Up @@ -70,6 +70,7 @@ px4_add_board(
mc_pos_control
navigator
sensors
sih
vmount
vtol_att_control
wind_estimator
Expand Down
1 change: 1 addition & 0 deletions boards/omnibus/f4sd/default.cmake
Expand Up @@ -64,6 +64,7 @@ px4_add_board(
mc_pos_control
navigator
sensors
sih
#vmount
#vtol_att_control
#wind_estimator
Expand Down
1 change: 1 addition & 0 deletions boards/parrot/bebop/default.cmake
Expand Up @@ -40,6 +40,7 @@ px4_add_board(
mc_pos_control
navigator
sensors
sih
#vtol_att_control
wind_estimator

Expand Down
1 change: 1 addition & 0 deletions boards/px4/fmu-v3/default.cmake
Expand Up @@ -82,6 +82,7 @@ px4_add_board(
mc_pos_control
navigator
sensors
sih
vmount
vtol_att_control
wind_estimator
Expand Down
1 change: 1 addition & 0 deletions boards/px4/fmu-v3/rtps.cmake
Expand Up @@ -83,6 +83,7 @@ px4_add_board(
micrortps_bridge
navigator
sensors
sih
vmount
vtol_att_control
wind_estimator
Expand Down
1 change: 1 addition & 0 deletions boards/px4/fmu-v3/stackcheck.cmake
Expand Up @@ -82,6 +82,7 @@ px4_add_board(
mc_pos_control
navigator
sensors
sih
vmount
vtol_att_control
wind_estimator
Expand Down
1 change: 1 addition & 0 deletions boards/px4/fmu-v4/default.cmake
Expand Up @@ -68,6 +68,7 @@ px4_add_board(
mc_pos_control
navigator
sensors
sih
vmount
vtol_att_control
wind_estimator
Expand Down
1 change: 1 addition & 0 deletions boards/px4/fmu-v4/rtps.cmake
Expand Up @@ -69,6 +69,7 @@ px4_add_board(
micrortps_bridge
navigator
sensors
sih
vmount
vtol_att_control
wind_estimator
Expand Down
1 change: 1 addition & 0 deletions boards/px4/fmu-v4/stackcheck.cmake
Expand Up @@ -68,6 +68,7 @@ px4_add_board(
mc_pos_control
navigator
sensors
sih
vmount
vtol_att_control
wind_estimator
Expand Down
1 change: 1 addition & 0 deletions boards/px4/fmu-v4pro/default.cmake
Expand Up @@ -81,6 +81,7 @@ px4_add_board(
mc_pos_control
navigator
sensors
sih
vmount
vtol_att_control
wind_estimator
Expand Down
1 change: 1 addition & 0 deletions boards/px4/fmu-v4pro/rtps.cmake
Expand Up @@ -82,6 +82,7 @@ px4_add_board(
micrortps_bridge
navigator
sensors
sih
vmount
vtol_att_control
wind_estimator
Expand Down
1 change: 1 addition & 0 deletions boards/px4/fmu-v5/default.cmake
Expand Up @@ -81,6 +81,7 @@ px4_add_board(
mc_pos_control
navigator
sensors
sih
vmount
vtol_att_control
wind_estimator
Expand Down
1 change: 1 addition & 0 deletions boards/px4/fmu-v5/multicopter.cmake
Expand Up @@ -64,6 +64,7 @@ px4_add_board(
mc_pos_control
navigator
sensors
sih
vmount
wind_estimator

Expand Down
1 change: 1 addition & 0 deletions boards/px4/fmu-v5/rtps.cmake
Expand Up @@ -83,6 +83,7 @@ px4_add_board(
micrortps_bridge
navigator
sensors
sih
vmount
vtol_att_control
wind_estimator
Expand Down
1 change: 1 addition & 0 deletions boards/px4/fmu-v5/stackcheck.cmake
Expand Up @@ -82,6 +82,7 @@ px4_add_board(
mc_pos_control
navigator
sensors
sih
vmount
vtol_att_control
wind_estimator
Expand Down
1 change: 1 addition & 0 deletions boards/px4/raspberrypi/cross.cmake
Expand Up @@ -45,6 +45,7 @@ px4_add_board(
mc_pos_control
navigator
sensors
sih
vmount
vtol_att_control
wind_estimator
Expand Down
1 change: 1 addition & 0 deletions boards/px4/raspberrypi/native.cmake
Expand Up @@ -43,6 +43,7 @@ px4_add_board(
mc_pos_control
navigator
sensors
sih
#simulator
vmount
vtol_att_control
Expand Down
11 changes: 7 additions & 4 deletions src/lib/systemlib/system_params.c
Expand Up @@ -65,12 +65,15 @@ PARAM_DEFINE_INT32(SYS_AUTOSTART, 0);
PARAM_DEFINE_INT32(SYS_AUTOCONFIG, 0);

/**
* Enable HITL mode on next boot
* Enable HITL/SIH mode on next boot
*
* While enabled the system will boot in HITL mode and not enable all sensors and checks.
* When disabled the same vehicle can be normally flown outdoors.
* While enabled the system will boot in Hardware-In-The-Loop (HITL)
* or Simulation-In-Hardware (SIH) mode and not enable all sensors and checks.
* When disabled the same vehicle can be flown normally.
*
* @boolean
* @value 0 HITL and SIH disabled
* @value 1 HITL enabled
* @value 2 SIH enabled
* @reboot_required true
*
* @group System
Expand Down
9 changes: 9 additions & 0 deletions src/modules/mavlink/mavlink_main.cpp
Expand Up @@ -824,12 +824,21 @@ Mavlink::set_hil_enabled(bool hil_enabled)
if (hil_enabled && !_hil_enabled && _datarate > 5000) {
_hil_enabled = true;
ret = configure_stream("HIL_ACTUATOR_CONTROLS", 200.0f);

if (_param_sys_hitl.get() == 2) { // Simulation in Hardware enabled ?
configure_stream("GROUND_TRUTH", 25.0f); // HIL_STATE_QUATERNION to display the SIH

} else {
configure_stream("GROUND_TRUTH", 0.0f);
}
}

/* disable HIL */
if (!hil_enabled && _hil_enabled) {
_hil_enabled = false;
ret = configure_stream("HIL_ACTUATOR_CONTROLS", 0.0f);

configure_stream("GROUND_TRUTH", 0.0f);
}

return ret;
Expand Down
3 changes: 2 additions & 1 deletion src/modules/mavlink/mavlink_main.h
Expand Up @@ -642,7 +642,8 @@ class Mavlink : public ModuleParams
(ParamInt<px4::params::MAV_BROADCAST>) _param_broadcast_mode,
(ParamBool<px4::params::MAV_HASH_CHK_EN>) _param_hash_check_enabled,
(ParamBool<px4::params::MAV_HB_FORW_EN>) _param_heartbeat_forwarding_enabled,
(ParamBool<px4::params::MAV_ODOM_LP>) _param_send_odom_loopback
(ParamBool<px4::params::MAV_ODOM_LP>) _param_send_odom_loopback,
(ParamInt<px4::params::SYS_HITL>) _param_sys_hitl
)

perf_counter_t _loop_perf; /**< loop performance counter */
Expand Down