SITL for Ardusub

Did anyone try getting SITL to work with ArduSub. I want to simulate an underwater rover I am not sure if I can get SITL with ArduSub working by my self.

ArduSub hasn’t been merged yet, but is in the process: https://github.com/ArduPilot/ardupilot/pull/5678
It includes support for SITL.

Hi @jakkala_kalvik,

Maybe this can help you :slight_smile:

Clone Ardupilot and update submodules:

git clone https://github.com/ArduPilot/ardupilot
git submodule update --init --recursive 

Some packages may be necessary, you can check here the list.
Go to ardupilot/Tools/autotest and run the sitl:

cd ardupilot/Tools/autotest
python sim_vehicle.py -v ArduSub

And than, you’ll have this output if succeed.

SIM_VEHICLE: Start
SIM_VEHICLE: Killing tasks
SIM_VEHICLE: Starting up at -35.363261,149.165230,584,353 (CMAC)
SIM_VEHICLE: WAF build
SIM_VEHICLE: Configure waf
SIM_VEHICLE: "/mnt/hd/git/blue/ardupilot/modules/waf/waf-light" "configure" "--board" "sitl"
Setting top to                           : /mnt/hd/git/blue/ardupilot 
Setting out to                           : /mnt/hd/git/blue/ardupilot/build 
Autoconfiguration                        : enabled 
Setting board to                         : sitl 
Checking for 'g++' (C++ compiler)        : /usr/bin/g++ 
Checking for 'gcc' (C compiler)          : /usr/bin/gcc 
Checking for need to link with librt     : not necessary 
Checking for HAVE_CMATH_ISFINITE         : yes 
Checking for HAVE_CMATH_ISINF            : yes 
Checking for HAVE_CMATH_ISNAN            : yes 
Checking for NEED_CMATH_ISFINITE_STD_NAMESPACE : yes 
Checking for NEED_CMATH_ISINF_STD_NAMESPACE    : yes 
Checking for NEED_CMATH_ISNAN_STD_NAMESPACE    : yes 
Checking for header endian.h                   : yes 
Checking for header byteswap.h                 : yes 
Checking for program 'python'                  : /usr/bin/python 
Checking for python version >= 2.7.0           : 3.6.2 
Checking for program 'python'                  : /usr/bin/python 
Checking for python version >= 2.7.0           : 3.6.2 
Source is git repository                       : yes 
Update submodules                              : yes 
Checking for program 'git'                     : /usr/bin/git 
Checking for program 'size'                    : /usr/bin/size 
Benchmarks                                     : disabled 
Unit tests                                     : enabled 
Checking for program 'rsync'                   : /usr/bin/rsync 
'configure' finished successfully (1.979s)
SIM_VEHICLE: Building
SIM_VEHICLE: "/mnt/hd/git/blue/ardupilot/modules/waf/waf-light" "build" "--target" "bin/ardusub"
Waf: Entering directory `/mnt/hd/git/blue/ardupilot/build/sitl'
Waf: Leaving directory `/mnt/hd/git/blue/ardupilot/build/sitl'

BUILD SUMMARY
Build directory: /mnt/hd/git/blue/ardupilot/build/sitl
Target       Text     Data   BSS    Total  
-------------------------------------------
bin/ardusub  1329446  46606  32896  1408948

Build commands will be stored in build/sitl/compile_commands.json
'build' finished successfully (3.247s)
SIM_VEHICLE: Using defaults from (/mnt/hd/git/blue/ardupilot/Tools/autotest/default_params/sub.parm)
SIM_VEHICLE: Run ArduSub
SIM_VEHICLE: "/mnt/hd/git/blue/ardupilot/Tools/autotest/run_in_terminal_window.sh" "ArduSub" "/mnt/hd/git/blue/ardupilot/build/sitl/bin/ardusub" "-S" "-I0" "--home" "-35.363261,149.165230,584,353" "--model" "vectored" "--speedup" "1" "--defaults" "/mnt/hd/git/blue/ardupilot/Tools/autotest/default_params/sub.parm"
SIM_VEHICLE: Run MavProxy
SIM_VEHICLE: "mavproxy.py" "--master" "tcp:127.0.0.1:5760" "--sitl" "127.0.0.1:5501" "--out" "127.0.0.1:14550" "--out" "127.0.0.1:14551"
RiTW: Starting ArduSub : /mnt/hd/git/blue/ardupilot/build/sitl/bin/ardusub -S -I0 --home -35.363261,149.165230,584,353 --model vectored --speedup 1 --defaults /mnt/hd/git/blue/ardupilot/Tools/autotest/default_params/sub.parm
which: no osascript in (/usr/local/sbin:/usr/local/bin:/usr/bin:/opt/android-ndk:/opt/android-sdk/platform-tools:/opt/android-sdk/tools:/opt/android-sdk/tools/bin:/opt/cuda/bin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:/home/patrick/.gem/ruby/2.4.0/bin)
Connect tcp:127.0.0.1:5760 source_system=255
Log Directory: 
Telemetry log: mav.tlog
Waiting for heartbeat from tcp:127.0.0.1:5760


Init ArduSub V3.6-dev (cMAV> c55e5a8)

Free RAM: 131072
Firmware change: erasing EEPROM...
done.
load_all took 0us
0 0 0 validate_structures:188: Validating structures
DataFlash_File: buffer size=16384
online system 1
MANUAL> Mode MANUAL
APM: ArduSub V3.6-dev (cc55e5a8)
Got MAVLink msg: COMMAND_ACK {command : 520, result : 0}
Received 790 parameters
Saved 790 parameters to mav.parm
No waypoint load started
APM: Barometer calibration complete

Init completefence breach
APM: EKF2 IMU0 initial yaw alignment complete
APM: EKF2 IMU1 initial yaw alignment complete
APM: EKF2 IMU0 tilt alignment complete
APM: EKF2 IMU1 tilt alignment complete
APM: GPS 1: detected as u-blox at 115200 baud
APM: EKF2 IMU0 Origin set to GPS
APM: EKF2 IMU1 Origin set to GPS
APM: EKF2 IMU0 is using GPS
APM: EKF2 IMU1 is using GPS

QGroundControl will connect to it automatically.

Thanks for the help! I did as was recomented here

WHERE I HAVE TO PUT THIS CODE IN QGROUNDCONTROLL please tell

You have no code to put in QGC, you have to run SITL following these steps “SITL Simulator (Software in the Loop) — Dev documentation” then follow the steps of @patrickelectric. QGC is only the interface between the vehicle that is simulated and you