From 61590e97da79713422265f850de5115e2b3a1eb2 Mon Sep 17 00:00:00 2001 From: haitomatic Date: Wed, 6 Mar 2024 11:12:45 +0000 Subject: [PATCH] sitl: fix fw airspeed sensor and update fw airframe to use skywalker_x8 --- .../airframes/4440_gz_ssrc_skywalker_x8 | 39 +++++++++---------- packaging/entrypoint_sitl_gzsim.sh | 4 +- .../sensor_airspeed_sim/SensorAirspeedSim.cpp | 2 +- .../sensor_airspeed_sim/SensorAirspeedSim.hpp | 1 + 4 files changed, 23 insertions(+), 23 deletions(-) diff --git a/ROMFS/px4fmu_common/init.d-posix/airframes/4440_gz_ssrc_skywalker_x8 b/ROMFS/px4fmu_common/init.d-posix/airframes/4440_gz_ssrc_skywalker_x8 index d2ede5ef2686..faaa438d531c 100644 --- a/ROMFS/px4fmu_common/init.d-posix/airframes/4440_gz_ssrc_skywalker_x8 +++ b/ROMFS/px4fmu_common/init.d-posix/airframes/4440_gz_ssrc_skywalker_x8 @@ -6,7 +6,7 @@ # @class Plane # -. /etc/init.d/rc.fw_defaults +. ${R}etc/init.d/rc.fw_defaults PX4_SIMULATOR=${PX4_SIMULATOR:=gz} PX4_GZ_WORLD=${PX4_GZ_WORLD:=default} @@ -16,7 +16,7 @@ param set-default SIM_GZ_EN 1 param set-default SIM_GZ_RUN_GZSIM 0 param set-default SENS_EN_GPSSIM 1 -param set-default SENS_BAROSIM 0 +param set-default SENS_EN_BAROSIM 1 param set-default SENS_EN_MAGSIM 1 param set-default SENS_EN_ARSPDSIM 1 @@ -33,7 +33,7 @@ param set-default CA_SV_CS1_TRQ_R 0.5 # GZ SIM param set-default SIM_GZ_EC_FUNC1 101 -param set-default SIM_GZ_EC_MIN1 0 +param set-default SIM_GZ_EC_MIN1 150 param set-default SIM_GZ_EC_MAX1 1000 param set-default SIM_GZ_SV_FUNC1 201 @@ -41,10 +41,10 @@ param set-default SIM_GZ_SV_FUNC2 202 # Airspeed parameters param set-default ASPD_PRIMARY 1 -# param set-default FW_AIRSPD_MAX 22.0 -# param set-default FW_AIRSPD_MIN 14.0 -# param set-default FW_AIRSPD_STALL 12.0 -# param set-default FW_AIRSPD_TRIM 18.0 +param set-default FW_AIRSPD_MAX 22.0 +param set-default FW_AIRSPD_MIN 14.0 +param set-default FW_AIRSPD_STALL 12.0 +param set-default FW_AIRSPD_TRIM 18.0 # Maximum landing slope angle in deg param set-default FW_LND_ANG 8 @@ -52,6 +52,9 @@ param set-default FW_LND_ANG 8 # RC loss failsafe to HOLD mode param set-default COM_RC_IN_MODE 1 +# Maximum manual roll angle +param set-default FW_MAN_R_MAX 60.0 + # Fixed wing control # Pitch rate param set-default FW_PR_P 0.9 @@ -69,10 +72,10 @@ param set-default FW_RR_I 0.5 param set-default FW_YR_FF 0.5 param set-default FW_YR_P 0.6 param set-default FW_YR_I 0.5 -# Throttle limit -# param set-default FW_THR_MAX 0.6 -# param set-default FW_THR_MIN 0.05 -# param set-default FW_THR_TRIM 0.25 +#Throttle limit +param set-default FW_THR_MAX 0.6 +param set-default FW_THR_MIN 0.05 +param set-default FW_THR_TRIM 0.25 # Climb and sink rate param set-default FW_T_CLMB_MAX 8 param set-default FW_T_SINK_MAX 2.7 @@ -82,14 +85,10 @@ param set-default FW_T_SINK_MIN 2.2 param set-default NAV_ACC_RAD 15 param set-default NAV_DLL_ACT 2 +# Launch detection +param set-default FW_LAUN_DETCN_ON 1 + # Misc -param set-default MIS_TAKEOFF_ALT 30.0 param set-default RTL_RETURN_ALT 30.0 - -# Disable internal magnetometer -param set CAL_MAG0_PRIO 0 - -# Catapult launch with acc threshold trigger -param set-default FW_LAUN_DETCN_ON 1 -param set-default FW_THR_IDLE 0.1 # needs to be running before throw as that's how gazebo detects arming -param set-default FW_LAUN_AC_THLD 10 +param set-default RTL_DESCEND_ALT 30.0 +param set-default FW_LND_USETER 0 diff --git a/packaging/entrypoint_sitl_gzsim.sh b/packaging/entrypoint_sitl_gzsim.sh index 5ddd91a623dc..3836a6ec9caf 100755 --- a/packaging/entrypoint_sitl_gzsim.sh +++ b/packaging/entrypoint_sitl_gzsim.sh @@ -17,8 +17,8 @@ case $PX4_VEHICLE_TYPE in export PX4_GZ_MODEL=standard_vtol ;; fw) - export PX4_SYS_AUTOSTART=4003 - export PX4_GZ_MODEL=rc_cessna + export PX4_SYS_AUTOSTART=4440 + export PX4_GZ_MODEL=skywalker_x8 ;; *) echo "ERROR: unknown vehicle type: $PX4_VEHICLE_TYPE" diff --git a/src/modules/simulation/sensor_airspeed_sim/SensorAirspeedSim.cpp b/src/modules/simulation/sensor_airspeed_sim/SensorAirspeedSim.cpp index 7b0d9556cadf..744ab6639722 100644 --- a/src/modules/simulation/sensor_airspeed_sim/SensorAirspeedSim.cpp +++ b/src/modules/simulation/sensor_airspeed_sim/SensorAirspeedSim.cpp @@ -144,7 +144,7 @@ void SensorAirspeedSim::Run() // report.timestamp_sample = time; differential_pressure.device_id = 1377548; // 1377548: DRV_DIFF_PRESS_DEVTYPE_SIM, BUS: 1, ADDR: 5, TYPE: SIMULATION differential_pressure.differential_pressure_pa = (double)diff_pressure * 100.0; // hPa to Pa; - differential_pressure.temperature = temperature_local; + differential_pressure.temperature = temperature_local - TEMPERATURE_ZERO_C; differential_pressure.timestamp = hrt_absolute_time(); _differential_pressure_pub.publish(differential_pressure); diff --git a/src/modules/simulation/sensor_airspeed_sim/SensorAirspeedSim.hpp b/src/modules/simulation/sensor_airspeed_sim/SensorAirspeedSim.hpp index 64305dcccada..78121e9594cf 100644 --- a/src/modules/simulation/sensor_airspeed_sim/SensorAirspeedSim.hpp +++ b/src/modules/simulation/sensor_airspeed_sim/SensorAirspeedSim.hpp @@ -50,6 +50,7 @@ using namespace time_literals; static constexpr float TEMPERATURE_MSL = 288.15; // temperature at MSL [K] (15 [C]) +static constexpr float TEMPERATURE_ZERO_C = 273.15; // temperature at zero degree Celcius [K] (0 [C]) static constexpr float PRESSURE_MSL = 101325.0; // pressure at MSL [Pa] static constexpr float LAPSE_RATE = 0.0065; // reduction in temperature with altitude for troposphere [K/m] static constexpr float AIR_DENSITY_MSL = 1.225; // air density at MSL [kg/m^3]