Skip to content

Commit

Permalink
sitl: update airframes; gps sim: reduce gaussian noise level
Browse files Browse the repository at this point in the history
  • Loading branch information
haitomatic committed Oct 24, 2023
1 parent 0c8e31e commit 9fc8070
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 43 deletions.
5 changes: 2 additions & 3 deletions ROMFS/px4fmu_common/init.d-posix/airframes/4003_gz_rc_cessna
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,13 @@ PX4_GZ_WORLD=${PX4_GZ_WORLD:=default}
PX4_SIM_MODEL=${PX4_SIM_MODEL:=rc_cessna}

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_EN_BAROSIM 0
param set-default SENS_EN_BAROSIM 1
param set-default SENS_EN_MAGSIM 1
param set-default SENS_EN_ARSPDSIM 1



param set-default FW_LND_ANG 8

param set-default NPFG_PERIOD 12
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ PX4_GZ_WORLD=${PX4_GZ_WORLD:=default}
PX4_SIM_MODEL=${PX4_SIM_MODEL:=standard_vtol}

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_EN_BAROSIM 0
param set-default SENS_EN_BAROSIM 1
param set-default SENS_EN_MAGSIM 1
param set-default SENS_EN_ARSPDSIM 1

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ PX4_SIM_MODEL=${PX4_SIM_MODEL:=skywalker_x8}
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_MAGSIM 1
param set-default SENS_EN_ARSPDSIM 1

# Control allocator parameters
param set-default CA_AIRFRAME 1
param set-default CA_ROTOR_COUNT 1
Expand All @@ -26,44 +31,65 @@ param set-default CA_SV_CS1_TYPE 6
param set-default CA_SV_CS1_TRQ_P 0.5
param set-default CA_SV_CS1_TRQ_R 0.5

# PWM
param set-default PWM_MAIN_FUNC1 201
param set-default PWM_MAIN_FUNC2 202
param set-default PWM_MAIN_FUNC4 101
param set-default PWM_AUX_FUNC1 201
param set-default PWM_AUX_FUNC2 202
param set-default PWM_AUX_FUNC4 101
# GZ SIM
param set-default SIM_GZ_EC_FUNC1 101
param set-default SIM_GZ_EC_MIN1 0
param set-default SIM_GZ_EC_MAX1 1000

param set-default SIM_GZ_SV_FUNC1 201
param set-default SIM_GZ_SV_FUNC2 202

# Airspeed parameters
sdp3x start -X -f 400
param set-default ASPD_DO_CHECKS 15
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 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

# Battery parameters
param set-default BAT1_N_CELLS 4
param set-default BAT1_R_INTERNAL 0.0050
param set-default BAT1_V_EMPTY 3.6000
param set-default BAT1_V_LOAD_DROP 0.1000
# Maximum landing slope angle in deg
param set-default FW_LND_ANG 8

param set-default BAT2_R_INTERNAL 0.0050
param set-default BAT2_V_EMPTY 3.6000
param set-default BAT2_V_LOAD_DROP 0.1000
# RC loss failsafe to HOLD mode
param set-default COM_RC_IN_MODE 1

# Disable internal magnetometer
param set CAL_MAG0_PRIO 0
# Fixed wing control
# Pitch rate
param set-default FW_PR_P 0.9
param set-default FW_PR_FF 0.5
param set-default FW_PR_I 0.5
param set-default TRIM_PITCH -0.15
# Pitch angle in deg
param set-default FW_PSP_OFF 0
param set-default FW_P_LIM_MIN -15
# Roll rate
param set-default FW_RR_FF 0.5
param set-default FW_RR_P 0.3
param set-default FW_RR_I 0.5
# Yaw rate
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
# Climb and sink rate
param set-default FW_T_CLMB_MAX 8
param set-default FW_T_SINK_MAX 2.7
param set-default FW_T_SINK_MIN 2.2

# Launch detection
param set-default FW_LAUN_DETCN_ON 1
# Navigation
param set-default NAV_ACC_RAD 15
param set-default NAV_DLL_ACT 2

# Maximum manual roll angle
param set-default FW_MAN_R_MAX 60.0
# Misc
param set-default MIS_TAKEOFF_ALT 30.0
param set-default RTL_RETURN_ALT 30.0

# Rate control
param set-default FW_RR_IMAX 0.4000
param set-default FW_YR_IMAX 0.4000
# Disable internal magnetometer
param set CAL_MAG0_PRIO 0

# Misc
param set-default RTL_RETURN_ALT 30.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
8 changes: 4 additions & 4 deletions packaging/entrypoint_sitl_gzsim.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ case $PX4_VEHICLE_TYPE in
export PX4_GZ_MODEL=scout_mini
;;
vtol)
export PX4_SYS_AUTOSTART=4430
export PX4_GZ_MODEL=striver_mini
export PX4_SYS_AUTOSTART=4004
export PX4_GZ_MODEL=standard_vtol
;;
fw)
export PX4_SYS_AUTOSTART=4440
export PX4_GZ_MODEL=skywalker_x8
export PX4_SYS_AUTOSTART=4003
export PX4_GZ_MODEL=rc_cessna
;;
*)
echo "ERROR: unknown vehicle type: $PX4_VEHICLE_TYPE"
Expand Down
6 changes: 3 additions & 3 deletions src/modules/simulation/sensor_gps_sim/SensorGpsSim.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,9 @@ void SensorGpsSim::Run()
vehicle_global_position_s gpos{};
_vehicle_global_position_sub.copy(&gpos);

double latitude = gpos.lat + math::degrees((double)generate_wgn() * 0.2 / CONSTANTS_RADIUS_OF_EARTH);
double longitude = gpos.lon + math::degrees((double)generate_wgn() * 0.2 / CONSTANTS_RADIUS_OF_EARTH);
float altitude = gpos.alt + (generate_wgn() * 0.5f);
double latitude = gpos.lat + math::degrees((double)generate_wgn() * 0.1 / CONSTANTS_RADIUS_OF_EARTH);
double longitude = gpos.lon + math::degrees((double)generate_wgn() * 0.1 / CONSTANTS_RADIUS_OF_EARTH);
float altitude = gpos.alt + (generate_wgn() * 0.1f);

Vector3f gps_vel = Vector3f{lpos.vx, lpos.vy, lpos.vz} + noiseGauss3f(0.06f, 0.077f, 0.158f);

Expand Down

0 comments on commit 9fc8070

Please sign in to comment.