From e1d9438f793a849626ec9c5c0186dc0585df1319 Mon Sep 17 00:00:00 2001 From: romain <romain.chiap@gmail.com> Date: Mon, 18 Mar 2019 10:39:56 -0400 Subject: [PATCH] sih: remove SYS_SIH parameter and extend SYS_HITL --- .../init.d/airframes/1100_rc_quad_x_sih.hil | 8 +-- ROMFS/px4fmu_common/init.d/rc.interface | 2 +- ROMFS/px4fmu_common/init.d/rcS | 7 ++- src/lib/systemlib/system_params.c | 24 +++------ src/modules/sih/sih.cpp | 2 +- src/modules/sih/sih.hpp | 12 ++--- src/modules/sih/sih_params.c | 50 +++++++++---------- 7 files changed, 45 insertions(+), 60 deletions(-) diff --git a/ROMFS/px4fmu_common/init.d/airframes/1100_rc_quad_x_sih.hil b/ROMFS/px4fmu_common/init.d/airframes/1100_rc_quad_x_sih.hil index 03c3f2d5a7..1d2d295954 100644 --- a/ROMFS/px4fmu_common/init.d/airframes/1100_rc_quad_x_sih.hil +++ b/ROMFS/px4fmu_common/init.d/airframes/1100_rc_quad_x_sih.hil @@ -13,9 +13,5 @@ sh /etc/init.d/rc.mc_defaults set MIXER quad_x set PWM_OUT 1234 -# set HIL to avoid sensors startup -param set SYS_HITL 1 - -param set SYS_SIH 1 - -param set BAT_N_CELLS 4 +# set SYS_HITL to 2 to start the SIH and avoid sensors startup +param set SYS_HITL 2 diff --git a/ROMFS/px4fmu_common/init.d/rc.interface b/ROMFS/px4fmu_common/init.d/rc.interface index 3e7896c4c0..67f42f275e 100644 --- a/ROMFS/px4fmu_common/init.d/rc.interface +++ b/ROMFS/px4fmu_common/init.d/rc.interface @@ -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 diff --git a/ROMFS/px4fmu_common/init.d/rcS b/ROMFS/px4fmu_common/init.d/rcS index ef938cef91..53899526f4 100644 --- a/ROMFS/px4fmu_common/init.d/rcS +++ b/ROMFS/px4fmu_common/init.d/rcS @@ -328,17 +328,16 @@ 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 SIH if needed - if param compare SYS_SIH 1 + # start the simulator in hardware if needed + if param compare SYS_HITL 2 then sih start fi diff --git a/src/lib/systemlib/system_params.c b/src/lib/systemlib/system_params.c index 8ffa55f2ff..02da38e1ec 100644 --- a/src/lib/systemlib/system_params.c +++ b/src/lib/systemlib/system_params.c @@ -64,31 +64,21 @@ 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 */ PARAM_DEFINE_INT32(SYS_HITL, 0); -/** - * Enable SIH mode on next boot - * - * The simulation in hardware (SIH) will enable a quad simulator to run on the autopilot. - * When disabled the same vehicle can be normally flown outdoors. - * - * @boolean - * @reboot_required true - * - * @group System - */ -PARAM_DEFINE_INT32(SYS_SIH, 0); - /** * Set restart type * diff --git a/src/modules/sih/sih.cpp b/src/modules/sih/sih.cpp index d4255ffbdf..4ccfa24531 100644 --- a/src/modules/sih/sih.cpp +++ b/src/modules/sih/sih.cpp @@ -82,7 +82,7 @@ Most of the variables are declared global in the .hpp file to avoid stack overfl )DESCR_STR"); - PRINT_MODULE_USAGE_NAME("sih", "sih"); + PRINT_MODULE_USAGE_NAME("sih", "simulation"); PRINT_MODULE_USAGE_COMMAND("start"); PRINT_MODULE_USAGE_PARAM_FLAG('f', "Optional example flag", true); PRINT_MODULE_USAGE_PARAM_INT('p', 0, 0, 1024, "Optional example parameter", true); diff --git a/src/modules/sih/sih.hpp b/src/modules/sih/sih.hpp index 8fcd770735..38cf4060b2 100644 --- a/src/modules/sih/sih.hpp +++ b/src/modules/sih/sih.hpp @@ -217,11 +217,11 @@ private: (ParamFloat<px4::params::SIH_L_PITCH>) _sih_l_pitch, (ParamFloat<px4::params::SIH_KDV>) _sih_kdv, (ParamFloat<px4::params::SIH_KDW>) _sih_kdw, - (ParamInt<px4::params::SIH_LAT0>) _sih_lat0, - (ParamInt<px4::params::SIH_LON0>) _sih_lon0, - (ParamFloat<px4::params::SIH_H0>) _sih_h0, - (ParamFloat<px4::params::SIH_MU_X>) _sih_mu_x, - (ParamFloat<px4::params::SIH_MU_Y>) _sih_mu_y, - (ParamFloat<px4::params::SIH_MU_Z>) _sih_mu_z + (ParamInt<px4::params::SIHG_LAT0>) _sih_lat0, + (ParamInt<px4::params::SIHG_LON0>) _sih_lon0, + (ParamFloat<px4::params::SIHG_H0>) _sih_h0, + (ParamFloat<px4::params::SIHG_MU_X>) _sih_mu_x, + (ParamFloat<px4::params::SIHG_MU_Y>) _sih_mu_y, + (ParamFloat<px4::params::SIHG_MU_Z>) _sih_mu_z ) }; diff --git a/src/modules/sih/sih_params.c b/src/modules/sih/sih_params.c index 91f18c1b94..b7d3b0c179 100644 --- a/src/modules/sih/sih_params.c +++ b/src/modules/sih/sih_params.c @@ -48,7 +48,7 @@ * @min 0.0 * @decimal 2 * @increment 0.1 - * @group SIH + * @group Simulation In Hardware */ PARAM_DEFINE_FLOAT(SIH_MASS, 1.0f); @@ -62,7 +62,7 @@ PARAM_DEFINE_FLOAT(SIH_MASS, 1.0f); * @min 0.0 * @decimal 3 * @increment 0.005 - * @group SIH + * @group Simulation In Hardware */ PARAM_DEFINE_FLOAT(SIH_IXX, 0.025f); @@ -76,7 +76,7 @@ PARAM_DEFINE_FLOAT(SIH_IXX, 0.025f); * @min 0.0 * @decimal 3 * @increment 0.005 - * @group SIH + * @group Simulation In Hardware */ PARAM_DEFINE_FLOAT(SIH_IYY, 0.025f); @@ -90,7 +90,7 @@ PARAM_DEFINE_FLOAT(SIH_IYY, 0.025f); * @min 0.0 * @decimal 3 * @increment 0.005 - * @group SIH + * @group Simulation In Hardware */ PARAM_DEFINE_FLOAT(SIH_IZZ, 0.030f); @@ -103,7 +103,7 @@ PARAM_DEFINE_FLOAT(SIH_IZZ, 0.030f); * @unit kg*m*m * @decimal 3 * @increment 0.005 - * @group SIH + * @group Simulation In Hardware */ PARAM_DEFINE_FLOAT(SIH_IXY, 0.0f); @@ -116,7 +116,7 @@ PARAM_DEFINE_FLOAT(SIH_IXY, 0.0f); * @unit kg*m*m * @decimal 3 * @increment 0.005 - * @group SIH + * @group Simulation In Hardware */ PARAM_DEFINE_FLOAT(SIH_IXZ, 0.0f); @@ -129,7 +129,7 @@ PARAM_DEFINE_FLOAT(SIH_IXZ, 0.0f); * @unit kg*m*m * @decimal 3 * @increment 0.005 - * @group SIH + * @group Simulation In Hardware */ PARAM_DEFINE_FLOAT(SIH_IYZ, 0.0f); @@ -145,7 +145,7 @@ PARAM_DEFINE_FLOAT(SIH_IYZ, 0.0f); * @min 0.0 * @decimal 2 * @increment 0.5 - * @group SIH + * @group Simulation In Hardware */ PARAM_DEFINE_FLOAT(SIH_T_MAX, 5.0f); @@ -161,7 +161,7 @@ PARAM_DEFINE_FLOAT(SIH_T_MAX, 5.0f); * @min 0.0 * @decimal 3 * @increment 0.05 - * @group SIH + * @group Simulation In Hardware */ PARAM_DEFINE_FLOAT(SIH_Q_MAX, 0.1f); @@ -177,7 +177,7 @@ PARAM_DEFINE_FLOAT(SIH_Q_MAX, 0.1f); * @min 0.0 * @decimal 2 * @increment 0.05 - * @group SIH + * @group Simulation In Hardware */ PARAM_DEFINE_FLOAT(SIH_L_ROLL, 0.2f); @@ -193,7 +193,7 @@ PARAM_DEFINE_FLOAT(SIH_L_ROLL, 0.2f); * @min 0.0 * @decimal 2 * @increment 0.05 - * @group SIH + * @group Simulation In Hardware */ PARAM_DEFINE_FLOAT(SIH_L_PITCH, 0.2f); @@ -210,7 +210,7 @@ PARAM_DEFINE_FLOAT(SIH_L_PITCH, 0.2f); * @min 0.0 * @decimal 2 * @increment 0.05 - * @group SIH + * @group Simulation In Hardware */ PARAM_DEFINE_FLOAT(SIH_KDV, 1.0f); @@ -227,7 +227,7 @@ PARAM_DEFINE_FLOAT(SIH_KDV, 1.0f); * @min 0.0 * @decimal 3 * @increment 0.005 - * @group SIH + * @group Simulation In Hardware */ PARAM_DEFINE_FLOAT(SIH_KDW, 0.025f); @@ -243,9 +243,9 @@ PARAM_DEFINE_FLOAT(SIH_KDW, 0.025f); * @unit 1e-7 deg * @min -850000000 * @max 850000000 - * @group SIH + * @group Simulation In Hardware */ -PARAM_DEFINE_INT32(SIH_LAT0, 454671160); +PARAM_DEFINE_INT32(SIHG_LAT0, 454671160); /** * Initial geodetic longitude @@ -259,9 +259,9 @@ PARAM_DEFINE_INT32(SIH_LAT0, 454671160); * @unit 1e-7 deg * @min -1800000000 * @max 1800000000 - * @group SIH + * @group Simulation In Hardware */ -PARAM_DEFINE_INT32(SIH_LON0, -737578370); +PARAM_DEFINE_INT32(SIHG_LON0, -737578370); /** * Initial AMSL ground altitude @@ -280,9 +280,9 @@ PARAM_DEFINE_INT32(SIH_LON0, -737578370); * @max 8848.0 * @decimal 2 * @increment 0.01 - * @group SIH + * @group Simulation In Hardware */ -PARAM_DEFINE_FLOAT(SIH_H0, 32.34f); +PARAM_DEFINE_FLOAT(SIHG_H0, 32.34f); /** * North magnetic field at the initial location @@ -300,9 +300,9 @@ PARAM_DEFINE_FLOAT(SIH_H0, 32.34f); * @max 1.0 * @decimal 2 * @increment 0.001 - * @group SIH + * @group Simulation In Hardware */ -PARAM_DEFINE_FLOAT(SIH_MU_X, 0.179f); +PARAM_DEFINE_FLOAT(SIHG_MU_X, 0.179f); /** * East magnetic field at the initial location @@ -320,9 +320,9 @@ PARAM_DEFINE_FLOAT(SIH_MU_X, 0.179f); * @max 1.0 * @decimal 2 * @increment 0.001 - * @group SIH + * @group Simulation In Hardware */ -PARAM_DEFINE_FLOAT(SIH_MU_Y, -0.045f); +PARAM_DEFINE_FLOAT(SIHG_MU_Y, -0.045f); /** * Down magnetic field at the initial location @@ -340,6 +340,6 @@ PARAM_DEFINE_FLOAT(SIH_MU_Y, -0.045f); * @max 1.0 * @decimal 2 * @increment 0.001 - * @group SIH + * @group Simulation In Hardware */ -PARAM_DEFINE_FLOAT(SIH_MU_Z, 0.504f); \ No newline at end of file +PARAM_DEFINE_FLOAT(SIHG_MU_Z, 0.504f); \ No newline at end of file -- GitLab