thank you for the reply dsetin19.
I followed your advice, and added echo ‘tx’ to the launchSitl script. And I can tell exactly where the script gets hung up. But can’t figure out the reason, why?
I’m on a virtual environment, using the correct version of MAVLink, and yet, the script refuses to execute the next command,
/usr/bin/python “$1” --connect 127.0.0.1:5762… I always get the heart beat error. The only think I can think of is the screen program, doesn’t run in the virtual environment (dksitl)?
######################## launchSITL code ###################
#!/bin/bash
echo ‘t1’
kill -9 $(ps -eF | grep QG | awk -F ’ ’ ‘{print $2}’) > /dev/null 2<&1
kill -9 $(ps -eF | grep ardu | awk -F ’ ’ ‘{print $2}’) > /dev/null 2<&1
kill -9 $(ps -eF | grep mav | awk -F ’ ’ ‘{print $2}’) > /dev/null 2<&1
kill -9 $(ps -eF | grep apm | awk -F ’ ’ ‘{print $2}’) > /dev/null 2<&1
echo ‘t2’
############ Launch a SITL instance
/usr/local/bin/dronekit-sitl copter --home 44.5013,-88.0622,0,180&
###$apm/ardupilot/build/sitl/bin/arducopter -S -I0 --home=44.5013,-88.0622,0,180 --model “+” --speedup 1 --defaults $apm/ardupilot/Tools/autotest/default_params/copter.parm&
sleep 5
echo ‘t3’
################ Launch QGC
/usr/local/bin/QGC.AppImage 2>/dev/null&
sleep 5
echo ‘t4’
############# Start MAVProxy
screen -dm mavproxy.py --master=127.0.0.1:5760 --out=127.0.0.1:14550 --out=127.0.0.1:5762&
echo ‘t5’
############# Launch the dronekit-python script
/usr/bin/python “$1” --connect 127.0.0.1:5762
echo ‘t6’
###~/courseRoot/env/dksitl/bin/python “$1” --connect 127.0.0.1:5762
######## launchSitl “basic_template.py”
function finish {
kill -9 $(ps -eF | grep QG | awk -F ’ ’ ‘{print $2}’) > /dev/null 2<&1
kill -9 $(ps -eF | grep ardu | awk -F ’ ’ ‘{print $2}’) > /dev/null 2<&1
kill -9 $(ps -eF | grep mav | awk -F ’ ’ ‘{print $2}’) > /dev/null 2<&1
kill -9 $(ps -eF | grep apm | awk -F ’ ’ ‘{print $2}’) > /dev/null 2<&1
}
trap finish EXIT
echo ‘t7’
And it fails on echo ‘t5’
################## output ######################################
SITL already Downloaded and Extracted.
Ready to boot.
Execute: /home/gustavo/.dronekit/sitl/copter-3.3/apm --home 44.5013,-88.0622,0,180 --model=quad -I 0
SITL-0> Started model quad at 44.5013,-88.0622,0,180 at speed 1.0
SITL-0.stderr> bind port 5760 for 0
Starting sketch ‘ArduCopter’
Serial port 0 on TCP port 5760
Starting SITL input
Waiting for connection …
t3
t4
t5
WARNING:dronekit:Link timeout, no heartbeat in last 5 seconds
ERROR:dronekit.mavlink:Exception in MAVLink input loop
Traceback (most recent call last):
File “/usr/local/lib/python2.7/dist-packages/dronekit/mavlink.py”, line 211, in mavlink_thread_in
fn(self)
File “/usr/local/lib/python2.7/dist-packages/dronekit/init.py”, line 1371, in listener
self._heartbeat_error)
APIException: No heartbeat in 30 seconds, aborting.
Traceback (most recent call last):
File “basic_template.py”, line 62, in
vehicle = connectMyCopter()
File “basic_template.py”, line 25, in connectMyCopter
vehicle = connect(connection_string,wait_ready=True)
File “/usr/local/lib/python2.7/dist-packages/dronekit/init.py”, line 3166, in connect
vehicle.initialize(rate=rate, heartbeat_timeout=heartbeat_timeout)
File “/usr/local/lib/python2.7/dist-packages/dronekit/init.py”, line 2275, in initialize
raise APIException(‘Timeout in initializing connection.’)
dronekit.APIException: Timeout in initializing connection.
t6
t7
/usr/local/bin/launchSitl: line 37: 17784 Killed /usr/local/bin/QGC.AppImage 2> /dev/null
(dksitl) gustavo@thinkpad-t430:~/courseRoot/dk$