FlightGear simulator support (#14539)

- Add flightgear_bridge submodule.
- Add traget px4_sitl_nolockstep with disabled  LOCKSTEP simulation.
- Add flightgear viewer targets and startup scripts
- Add a few possible vehicles plane (rascal), autogyro (tf-g1), and rover (tf-r1))

Co-authored-by: Vit Hanousek <vithanousek@seznam.cz>
This commit is contained in:
Jakub Kákona 2020-04-29 08:46:59 +02:00 committed by GitHub
parent 5ffe88672e
commit dfa5ca1710
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 412 additions and 1 deletions

3
.gitmodules vendored
View File

@ -45,3 +45,6 @@
[submodule "platforms/qurt/dspal"] [submodule "platforms/qurt/dspal"]
path = platforms/qurt/dspal path = platforms/qurt/dspal
url = https://github.com/ATLFlight/dspal.git url = https://github.com/ATLFlight/dspal.git
[submodule "Tools/flightgear_bridge"]
path = Tools/flightgear_bridge
url = https://github.com/ThunderFly-aerospace/PX4-FlightGear-Bridge.git

View File

@ -0,0 +1,58 @@
#!/bin/sh
#
# @name Plane SITL
#
sh /etc/init.d/rc.fw_defaults
if [ $AUTOCNF = yes ]
then
param set EKF2_ARSP_THR 8
param set EKF2_FUSE_BETA 1
#param set EKF2_MAG_ACCLIM 0
#param set EKF2_MAG_YAWLIM 0
param set FW_LND_AIRSPD_SC 1.1
param set FW_LND_ANG 5
param set FW_THR_LND_MAX 0
param set FW_LND_HHDIST 30
param set FW_LND_FL_PMIN 9.5
param set FW_LND_FL_PMAX 20
param set FW_LND_FLALT 5
param set FW_LND_TLALT 15
param set FW_L1_PERIOD 25
param set FW_P_TC 0.4
param set FW_PR_FF 0.40
param set FW_PR_I 0.05
param set FW_PR_P 0.05
param set FW_R_TC 0.45
param set FW_RR_FF 0.40
param set FW_RR_I 0.132
param set FW_RR_P 0.085
param set FW_W_EN 1
param set MIS_LTRMIN_ALT 30
param set MIS_TAKEOFF_ALT 20
param set MIS_DIST_1WP 2500
param set MIS_DIST_WPS 10000
param set NAV_ACC_RAD 15
param set NAV_DLL_ACT 2
param set NAV_LOITER_RAD 50
param set RWTO_TKOFF 1
#param set FW_THR_SLEW_MAX 0.3 # fix takeoff failure for JSBsim in autonomous mission mode.
param set RWTO_MAX_PITCH 20
param set RWTO_MAX_ROLL 10
#param set RWTO_MAX_THR 0.6 # fix takeoff failure for JSBsim in autonomous mission mode.
param set RWTO_PSP 8
param set RWTO_AIRSPD_SCL 1.8
fi
set MIXER_FILE etc/mixers-sitl/plane_sitl.main.mix
set MIXER custom

View File

@ -0,0 +1,58 @@
#!/bin/sh
#
# @name Plane SITL
#
sh /etc/init.d/rc.fw_defaults
if [ $AUTOCNF = yes ]
then
param set EKF2_ARSP_THR 8
param set EKF2_FUSE_BETA 1
#param set EKF2_MAG_ACCLIM 0
#param set EKF2_MAG_YAWLIM 0
param set FW_LND_AIRSPD_SC 1.1
param set FW_LND_ANG 5
param set FW_THR_LND_MAX 0
param set FW_LND_HHDIST 30
param set FW_LND_FL_PMIN 9.5
param set FW_LND_FL_PMAX 20
param set FW_LND_FLALT 5
param set FW_LND_TLALT 15
param set FW_L1_PERIOD 25
param set FW_P_TC 0.4
param set FW_PR_FF 0.40
param set FW_PR_I 0.05
param set FW_PR_P 0.05
param set FW_R_TC 0.45
param set FW_RR_FF 0.40
param set FW_RR_I 0.132
param set FW_RR_P 0.085
param set FW_W_EN 1
param set MIS_LTRMIN_ALT 30
param set MIS_TAKEOFF_ALT 20
param set MIS_DIST_1WP 2500
param set MIS_DIST_WPS 10000
param set NAV_ACC_RAD 15
param set NAV_DLL_ACT 2
param set NAV_LOITER_RAD 50
param set RWTO_TKOFF 1
#param set FW_THR_SLEW_MAX 0.3 # fix takeoff failure for JSBsim in autonomous mission mode.
param set RWTO_MAX_PITCH 20
param set RWTO_MAX_ROLL 10
#param set RWTO_MAX_THR 0.6 # fix takeoff failure for JSBsim in autonomous mission mode.
param set RWTO_PSP 8
param set RWTO_AIRSPD_SCL 1.8
fi
set MIXER_FILE etc/mixers-sitl/plane_sitl.main.mix
set MIXER custom

View File

@ -0,0 +1,43 @@
#!/bin/sh
#
# @name ThunderFly TF-R1 UAV Rover
# @type Rover
# @class Rover
#
# @url https://github.com/ThunderFly-aerospace/TF-R1/
# @maintainer ThunderFly s.r.o.
#
sh /etc/init.d/rc.rover_defaults
if [ $AUTOCNF = yes ]
then
param set GND_L1_DIST 5
param set GND_SP_CTRL_MODE 1
param set GND_SPEED_D 3
param set GND_SPEED_I 0.001
param set GND_SPEED_IMAX 0.125
param set GND_SPEED_P 0.25
param set GND_SPEED_THR_SC 1
param set GND_SPEED_TRIM 15
param set GND_SPEED_MAX 25
param set GND_THR_CRUISE 0.3
param set GND_THR_IDLE 0
param set GND_THR_MAX 0.5
param set GND_THR_MIN 0
param set MIS_LTRMIN_ALT 0.01
param set MIS_TAKEOFF_ALT 0.01
param set NAV_ACC_RAD 0.5
param set NAV_LOITER_RAD 2
param set CBRK_AIRSPD_CHK 162128
param set GND_MAX_ANG 0.6
param set GND_WHEEL_BASE 3.0
fi
set MAV_TYPE 10
set MIXER_FILE etc/mixers-sitl/rover_sitl.main.mix

View File

@ -0,0 +1,64 @@
#!/bin/sh
#
# @name ThunderFly TF-G1
# ThunderFly TF-G1 autogyro airframe. Only for FlightGear simulator
#
# @type Autogyro
# @class Autogyro
#
# @url https://github.com/ThunderFly-aerospace/TF-G1/
#
#
sh /etc/init.d/rc.fw_defaults
if [ $AUTOCNF = yes ]
then
param set EKF2_ARSP_THR 8
param set EKF2_FUSE_BETA 1
param set ASPD_STALL 10.0
param set FW_P_RMAX_NEG 20.0
param set FW_P_RMAX_POS 60.0
param set FW_W_RMAX 10
param set FW_W_EN 1
param set FW_PR_IMAX 0.4
param set FW_R_TC 0.4
param set FW_RR_FF 0.5
param set FW_RR_I 0.1
param set FW_RR_IMAX 0.2
param set FW_RR_P 0.08
param set MIS_LTRMIN_ALT 50
param set MIS_TAKEOFF_ALT 3
param set NAV_ACC_RAD 20
param set NAV_DLL_ACT 2
param set NAV_LOITER_RAD 100
param set RWTO_TKOFF 1
param set MAV_BROADCAST 1
param set FW_ARSP_SCALE_EN 0
param set FW_AIRSPD_MAX 35
param set FW_AIRSPD_MIN 7
param set FW_AIRSPD_TRIM 15
param set FW_P_LIM_MAX 25
param set FW_P_LIM_MIN -5
param set FW_R_LIM 30
param set FW_MAN_P_MAX 30.0
param set FW_MAN_R_MAX 30.0
param set FW_THR_CRUISE 0.8
param set FW_THR_IDLE 0
param set COM_DISARM_PRFLT 0
fi
set MIXER_FILE etc/mixers-sitl/autogyro_sitl.main.mix
set MIXER custom

View File

@ -0,0 +1,37 @@
Mixer for SITL autogyro.
=========================================================
# 0 mixer for the rudder (Rotor roll)
M: 1
O: 10000 10000 0 -10000 10000
S: 0 2 10000 10000 0 -10000 10000
# 1 mixer for the pusher/puller throttle
M: 1
O: 10000 10000 0 -10000 10000
S: 0 3 0 20000 -10000 -10000 10000
# 2 mixer for the aileron
M: 1
O: 10000 10000 0 -10000 10000
S: 0 0 -10000 -10000 0 -10000 10000
# 3 mixer for the elevator (Rotor pitch)
M: 1
O: 10000 10000 0 -10000 10000
S: 0 1 10000 10000 0 -10000 10000
# 4 mixer for the prerotator AUX1
M: 1
O: 10000 10000 0 -10000 10000
S: 1 5 10000 10000 0 -10000 10000
# 5 mixer for the manual elevator AUX2
M: 1
O: 10000 10000 0 -10000 10000
S: 1 6 10000 10000 0 -10000 10000
# 6 mixer for the release device AUX3
M: 1
O: 10000 10000 0 -10000 10000
S: 1 7 10000 10000 0 -10000 10000

@ -0,0 +1 @@
Subproject commit f7eb676108c41edea5b9424f29a74a517a1dfd48

View File

@ -9,7 +9,7 @@ fi
if [[ -n "$DONT_RUN" ]]; then if [[ -n "$DONT_RUN" ]]; then
echo "Not running simulation (DONT_RUN is set)." echo "Not running simulation (DONT_RUN is set)."
exit 0 exit 0
fi fi
sitl_bin="$1" sitl_bin="$1"
@ -121,6 +121,12 @@ elif [ "$program" == "gazebo" ] && [ ! -n "$no_sim" ]; then
echo "You need to have gazebo simulator installed!" echo "You need to have gazebo simulator installed!"
exit 1 exit 1
fi fi
elif [ "$program" == "flightgear" ] && [ -z "$no_sim" ]; then
echo "FG setup"
cd "${src_path}/Tools/flightgear_bridge/"
"${src_path}/Tools/flightgear_bridge/FG_run.py" "models/"${model}".json" 0
"${build_path}/build_flightgear_bridge/flightgear_bridge" 0 `./get_FGbridge_params.py "models/"${model}".json"` &
FG_BRIDGE_PID=`echo $!`
fi fi
pushd "$rootfs" >/dev/null pushd "$rootfs" >/dev/null
@ -171,4 +177,7 @@ elif [ "$program" == "gazebo" ]; then
if [[ ! -n "$HEADLESS" ]]; then if [[ ! -n "$HEADLESS" ]]; then
kill -9 $GUI_PID kill -9 $GUI_PID
fi fi
elif [ "$program" == "flightgear" ]; then
kill $FG_BRIDGE_PID
kill -9 `cat /tmp/px4fgfspid_0`
fi fi

View File

@ -0,0 +1,91 @@
px4_add_board(
PLATFORM posix
VENDOR px4
MODEL sitl
LABEL nolockstep
TESTING
DRIVERS
#barometer # all available barometer drivers
#batt_smbus
camera_capture
camera_trigger
#differential_pressure # all available differential pressure drivers
#distance_sensor # all available distance sensor drivers
gps
#imu # all available imu drivers
#magnetometer # all available magnetometer drivers
pwm_out_sim
#telemetry # all available telemetry drivers
tone_alarm
#uavcan
MODULES
airspeed_selector
attitude_estimator_q
camera_feedback
commander
dataman
ekf2
events
fw_att_control
fw_pos_control_l1
land_detector
landing_target_estimator
#load_mon
local_position_estimator
logger
mavlink
mc_att_control
mc_hover_thrust_estimator
mc_pos_control
mc_rate_control
navigator
rc_update
replay
rover_pos_control
sensors
#sih
simulator
temperature_compensation
vmount
vtol_att_control
uuv_att_control
SYSTEMCMDS
#config
#dumpfile
dyn
esc_calib
led_control
mixer
motor_ramp
motor_test
#mtd
#nshterm
param
perf
pwm
reboot
sd_bench
shutdown
tests # tests and test runner
#top
topic_listener
tune_control
ver
work_queue
EXAMPLES
dyn_hello # dynamically loading modules example
fixedwing_control # Tutorial code from https://px4.io/dev/example_fixedwing_control
hello
#hwtest # Hardware test
#matlab_csv_serial
px4_mavlink_debug # Tutorial code from http://dev.px4.io/en/debug/debug_values.html
px4_simple_app # Tutorial code from http://dev.px4.io/en/apps/hello_sky.html
rover_steering_control # Rover example app
uuv_example_app
)
message(STATUS "Building without lockstep")
set(ENABLE_LOCKSTEP_SCHEDULER no)

View File

@ -25,6 +25,7 @@ add_custom_target(run_config
px4_add_git_submodule(TARGET git_gazebo PATH "${PX4_SOURCE_DIR}/Tools/sitl_gazebo") px4_add_git_submodule(TARGET git_gazebo PATH "${PX4_SOURCE_DIR}/Tools/sitl_gazebo")
px4_add_git_submodule(TARGET git_jmavsim PATH "${PX4_SOURCE_DIR}/Tools/jMAVSim") px4_add_git_submodule(TARGET git_jmavsim PATH "${PX4_SOURCE_DIR}/Tools/jMAVSim")
px4_add_git_submodule(TARGET git_flightgear_bridge PATH "${PX4_SOURCE_DIR}/Tools/flightgear_bridge")
# Add support for external project building # Add support for external project building
include(ExternalProject) include(ExternalProject)
@ -57,6 +58,20 @@ ExternalProject_Add(mavsdk_tests
BUILD_ALWAYS 1 BUILD_ALWAYS 1
) )
ExternalProject_Add(flightgear_bridge
SOURCE_DIR ${PX4_SOURCE_DIR}/Tools/flightgear_bridge
CMAKE_ARGS
-DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
BINARY_DIR ${PX4_BINARY_DIR}/build_flightgear_bridge
INSTALL_COMMAND ""
DEPENDS
git_flightgear_bridge
USES_TERMINAL_CONFIGURE true
USES_TERMINAL_BUILD true
EXCLUDE_FROM_ALL true
BUILD_ALWAYS 1
)
# create targets for each viewer/model/debugger combination # create targets for each viewer/model/debugger combination
set(viewers none jmavsim gazebo) set(viewers none jmavsim gazebo)
set(debuggers none ide gdb lldb ddd valgrind callgrind) set(debuggers none ide gdb lldb ddd valgrind callgrind)
@ -146,6 +161,38 @@ foreach(viewer ${viewers})
endforeach() endforeach()
endforeach() endforeach()
#add flighgear targets
if( ENABLE_LOCKSTEP_SCHEDULER STREQUAL "no")
set(models
rascal
rascal-electric
tf-g1
tf-r1
)
set(all_posix_vmd_make_targets)
foreach(model ${models})
set(_targ_name "flightgear_${model}")
add_custom_target(${_targ_name}
COMMAND ${PX4_SOURCE_DIR}/Tools/sitl_run.sh
$<TARGET_FILE:px4>
none
flightgear
${model}
none
${PX4_SOURCE_DIR}
${PX4_BINARY_DIR}
WORKING_DIRECTORY ${SITL_WORKING_DIR}
USES_TERMINAL
DEPENDS
logs_symlink
)
add_dependencies(${_targ_name} px4 flightgear_bridge)
list(APPEND all_posix_vmd_make_targets ${_targ_name})
endforeach()
endif()
string(REPLACE ";" "," posix_vmd_make_target_list "${all_posix_vmd_make_targets}") string(REPLACE ";" "," posix_vmd_make_target_list "${all_posix_vmd_make_targets}")
add_custom_target(list_vmd_make_targets add_custom_target(list_vmd_make_targets