How to bring two instances of sim_vehicle.sh?

Hi everyone,

I’m trying to bring up to instances of sim_vehicle.sh by doing, in a first terminal:

../Tools/autotest/sim_vehicle.sh -j 4 -f gazebo -I 0

and in second terminal
../Tools/autotest/sim_vehicle.sh -j 4 -f gazebo -I 0

however, after I run the second command the I get the message on the xTerm window saying:
failed to bind port 9002 to receive fdm from Gazebo
over and over again

I attach a picture below

Is there something obvious I’m missing?!

Thank you very much,
Hugo

Hello,

Forget about Erle repository and use : https://github.com/ArduPilot/ardupilot and follow http://ardupilot.org/dev/docs/setting-up-sitl-on-linux.html

I see you are using sudo … you shouldn’t need it .
Now with correct ardupilot version you could use
…/Tools/autotest/sim_vehicle.py -v ArduCopter -f gazebo-iris -m --mav10 --map --console --use-dir copter0 -I 0

and
…/Tools/autotest/sim_vehicle.py -v ArduCopter -f gazebo-iris -m --mav10 --map --console --use-dir copter1 -I 1

Each command will launch a sitl instance of copter in a different directory : copter0 or copter1
The I parameter is the instance number. It will also update the UDP port for connexion to gazebo.
For instance 0 : port out 9002 (data send to gazebo) and port in 9003 (data received from gazebo)
For instance 1 : port out 9012 (data send to gazebo) and port in 9013 (data received from gazebo)

Hi @khancyr,

Thank you very much! I have followed the links, but when I do [quote=“khancyr, post:2, topic:18653”]
…/Tools/autotest/sim_vehicle.py -v ArduCopter -f gazebo-iris -m --mav10 --map --console --use-dir copter0 -I 0
[/quote]

I get the following:

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: "/home/hugo/erle_simulation/ardupilot/ArduCopter/modules/waf/waf-light" "configure" "--board" "sitl"
Traceback (most recent call last):
  File "../Tools/autotest/sim_vehicle.py", line 745, in <module>
    do_build(vehicle_dir, cmd_opts, frame_infos)
  File "../Tools/autotest/sim_vehicle.py", line 331, in do_build
    return do_build_waf(opts, frame_options)
  File "../Tools/autotest/sim_vehicle.py", line 297, in do_build_waf
    run_cmd_blocking("Configure waf", cmd_configure, check=True)
  File "../Tools/autotest/sim_vehicle.py", line 410, in run_cmd_blocking
    p = subprocess.Popen(cmd, **kw)
  File "/usr/lib/python2.7/subprocess.py", line 711, in __init__
    errread, errwrite)
  File "/usr/lib/python2.7/subprocess.py", line 1343, in _execute_child
    raise child_exception
OSError: [Errno 2] No such file or directory
SIM_VEHICLE: Killing tasks

is this something obvious I’m missing?

Thanks again,
Hugo

Start over on a new directory by following : http://ardupilot.org/dev/docs/setting-up-sitl-on-linux.html

Weird…

when I do

git submodule update --init --recursive

I get

Submodule 'modules/PX4Firmware' (git://github.com/ArduPilot/PX4Firmware.git) registered for path 'modules/PX4Firmware'
Submodule 'modules/PX4NuttX' (git://github.com/ArduPilot/PX4NuttX.git) registered for path 'modules/PX4NuttX'
Submodule 'modules/gbenchmark' (git://github.com/google/benchmark.git) registered for path 'modules/gbenchmark'
Submodule 'gtest' (git://github.com/ArduPilot/googletest) registered for path 'modules/gtest'
Submodule 'modules/mavlink' (git://github.com/ArduPilot/mavlink) registered for path 'modules/mavlink'
Submodule 'modules/uavcan' (git://github.com/ArduPilot/uavcan.git) registered for path 'modules/uavcan'
Submodule 'modules/waf' (git://github.com/ArduPilot/waf.git) registered for path 'modules/waf'
Cloning into 'modules/PX4Firmware'...
fatal: unable to connect to github.com:
github.com: No address associated with hostname

fatal: clone of 'git://github.com/ArduPilot/PX4Firmware.git' into submodule path 'modules/PX4Firmware' failed

Should I try to clone it directly using git clone?
Hope I’m not bothering too much.
Thanks,
Hugo

you need internet access

I have internet access… but using eduroam… can it be it?

you can try to change the .gitmodules files at the root of ardupilot directory (ctrl-h to make it appear) by :

[submodule “modules/PX4Firmware”]
path = modules/PX4Firmware
url = https://github.com/ArduPilot/PX4Firmware
[submodule “modules/PX4NuttX”]
path = modules/PX4NuttX
url = https://github.com/ArduPilot/PX4NuttX
[submodule “modules/uavcan”]
path = modules/uavcan
url = https://github.com/ArduPilot/uavcan
[submodule “modules/waf”]
path = modules/waf
url = https://github.com/ArduPilot/waf
[submodule “modules/gbenchmark”]
path = modules/gbenchmark
url = https://github.com/google/benchmark
[submodule “modules/mavlink”]
path = modules/mavlink
url = https://github.com/ArduPilot/mavlink
[submodule “gtest”]
path = modules/gtest
url = https://github.com/ArduPilot/googletest

Actually it might be because of eduroam…

I used my phone as hotspot and tried it. It’s working… once it finishes I’ll continue with the rest of the instructions. Let’s see if I can start sim_vehicle.py…

Nope…

I still get the same error as before…[quote=“Hugo_Sardinha, post:3, topic:18653”]
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: “/home/hugo/erle_simulation/ardupilot/ArduCopter/modules/waf/waf-light” “configure” “–board” "sitl"
Traceback (most recent call last):
File “…/Tools/autotest/sim_vehicle.py”, line 745, in <module>
do_build(vehicle_dir, cmd_opts, frame_infos)
File “…/Tools/autotest/sim_vehicle.py”, line 331, in do_build
return do_build_waf(opts, frame_options)
File “…/Tools/autotest/sim_vehicle.py”, line 297, in do_build_waf
run_cmd_blocking(“Configure waf”, cmd_configure, check=True)
File “…/Tools/autotest/sim_vehicle.py”, line 410, in run_cmd_blocking
p = subprocess.Popen(cmd, **kw)
File “/usr/lib/python2.7/subprocess.py”, line 711, in init
errread, errwrite)
File “/usr/lib/python2.7/subprocess.py”, line 1343, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory
SIM_VEHICLE: Killing tasks
[/quote]

It miss waf … but you should have it if your submodules were correctly installed.

if you do ./waf configure , what is the ouput?

Here it is

Setting top to                           : /home/hugo/ardupilot 
Setting out to                           : /home/hugo/ardupilot/build 
Autoconfiguration                        : enabled 
Setting board to                         : sitl 
Checking for 'g++' (C++ compiler)        : /usr/lib/ccache/g++ 
Checking for 'gcc' (C compiler)          : /usr/lib/ccache/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            : no 
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           : 2.7.12 
Checking for program 'python'                  : /usr/bin/python 
Checking for python version >= 2.7.0           : 2.7.12 
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 
'configure' finished successfully (1.411s)

weird …

Are ./waf copter and sim_vehicle.py -v ArduCopter working ?

Pfff… no!

throwing a whole bunch of erros:

[444/789] Compiling libraries/AP_NavEKF2/AP_NavEKF2_core.cpp
In file included from ../../libraries/AP_Math/AP_Math.h:16:0,
                 from ../../libraries/AP_NavEKF3/AP_NavEKF3.h:22,
                 from ../../libraries/AP_NavEKF3/AP_NavEKF3_RngBcnFusion.cpp:5:
../../libraries/AP_Math/quaternion.h: In member function ‘bool Quaternion::is_nan() const’:
../../libraries/AP_Math/quaternion.h:55:24: error: ‘isnan’ was not declared in this scope
         return isnan(q1) || isnan(q2) || isnan(q3) || isnan(q4);
                        ^
compilation terminated due to -Wfatal-errors.

In file included from ../../libraries/AP_Math/AP_Math.h:16:0,
                 from ../../libraries/AP_NavEKF3/AP_NavEKF3.h:22,
                 from ../../libraries/AP_NavEKF3/AP_NavEKF3_GyroBias.cpp:5:
../../libraries/AP_Math/quaternion.h: In member function ‘bool Quaternion::is_nan() const’:
../../libraries/AP_Math/quaternion.h:55:24: error: ‘isnan’ was not declared in this scope
         return isnan(q1) || isnan(q2) || isnan(q3) || isnan(q4);
                        ^
compilation terminated due to -Wfatal-errors.

In file included from ../../libraries/AP_Math/AP_Math.h:16:0,
                 from ../../libraries/AP_NavEKF3/AP_NavEKF3.h:22,
                 from ../../libraries/AP_NavEKF3/AP_NavEKF3_VehicleStatus.cpp:5:
../../libraries/AP_Math/quaternion.h: In member function ‘bool Quaternion::is_nan() const’:
../../libraries/AP_Math/quaternion.h:55:24: error: ‘isnan’ was not declared in this scope
         return isnan(q1) || isnan(q2) || isnan(q3) || isnan(q4);
                        ^
compilation terminated due to -Wfatal-errors.

Waf: Leaving directory `/home/hugo/ardupilot/build/sitl'
Build failed
 -> task in 'objs/AP_Notify' failed (exit status 1): 
	{task 140190447526768: cxx AP_BoardLED.cpp -> AP_BoardLED.cpp.0.o}
['/usr/lib/ccache/g++', '-std=gnu++11', '-fdata-sections', '-ffunction-sections', '-fno-exceptions', '-fsigned-char', '-Wall', '-Wextra', '-Wformat', '-Wshadow', '-Wpointer-arith', '-Wcast-align', '-Wundef', '-Wno-unused-parameter', '-Wno-missing-field-initializers', '-Wno-reorder', '-Wno-redundant-decls', '-Wno-unknown-pragmas', '-Werror=format-security', '-Werror=array-bounds', '-Werror=uninitialized', '-Werror=init-self', '-Werror=switch', '-Wfatal-errors', '-Werror=unused-but-set-variable', '-O3', '-include', 'ap_config.h', '-Ilibraries', '-Ilibraries/GCS_MAVLink', '-I.', '-I../../libraries', '-I../../libraries/AP_Common/missing', '-DSKETCHBOOK="/home/hugo/ardupilot"', '-DCONFIG_HAL_BOARD=HAL_BOARD_SITL', '-DCONFIG_HAL_BOARD_SUBTYPE=HAL_BOARD_SUBTYPE_NONE', '../../libraries/AP_Notify/AP_BoardLED.cpp', '-c', '-o/home/hugo/ardupilot/build/sitl/libraries/AP_Notify/AP_BoardLED.cpp.0.o']
 -> task in 'objs/AP_NavEKF3' failed (exit status 1): 
	{task 140190447459776: cxx AP_NavEKF3_RngBcnFusion.cpp -> AP_NavEKF3_RngBcnFusion.cpp.0.o}
['/usr/lib/ccache/g++', '-std=gnu++11', '-fdata-sections', '-ffunction-sections', '-fno-exceptions', '-fsigned-char', '-Wall', '-Wextra', '-Wformat', '-Wshadow', '-Wpointer-arith', '-Wcast-align', '-Wundef', '-Wno-unused-parameter', '-Wno-missing-field-initializers', '-Wno-reorder', '-Wno-redundant-decls', '-Wno-unknown-pragmas', '-Werror=format-security', '-Werror=array-bounds', '-Werror=uninitialized', '-Werror=init-self', '-Werror=switch', '-Wfatal-errors', '-Werror=unused-but-set-variable', '-O3', '-include', 'ap_config.h', '-Ilibraries', '-Ilibraries/GCS_MAVLink', '-I.', '-I../../libraries', '-I../../libraries/AP_Common/missing', '-DSKETCHBOOK="/home/hugo/ardupilot"', '-DCONFIG_HAL_BOARD=HAL_BOARD_SITL', '-DCONFIG_HAL_BOARD_SUBTYPE=HAL_BOARD_SUBTYPE_NONE', '../../libraries/AP_NavEKF3/AP_NavEKF3_RngBcnFusion.cpp', '-c', '-o/home/hugo/ardupilot/build/sitl/libraries/AP_NavEKF3/AP_NavEKF3_RngBcnFusion.cpp.0.o']
 -> task in 'objs/AP_NavEKF3' failed (exit status 1): 
	{task 140190447459296: cxx AP_NavEKF3_GyroBias.cpp -> AP_NavEKF3_GyroBias.cpp.0.o}
['/usr/lib/ccache/g++', '-std=gnu++11', '-fdata-sections', '-ffunction-sections', '-fno-exceptions', '-fsigned-char', '-Wall', '-Wextra', '-Wformat', '-Wshadow', '-Wpointer-arith', '-Wcast-align', '-Wundef', '-Wno-unused-parameter', '-Wno-missing-field-initializers', '-Wno-reorder', '-Wno-redundant-decls', '-Wno-unknown-pragmas', '-Werror=format-security', '-Werror=array-bounds', '-Werror=uninitialized', '-Werror=init-self', '-Werror=switch', '-Wfatal-errors', '-Werror=unused-but-set-variable', '-O3', '-include', 'ap_config.h', '-Ilibraries', '-Ilibraries/GCS_MAVLink', '-I.', '-I../../libraries', '-I../../libraries/AP_Common/missing', '-DSKETCHBOOK="/home/hugo/ardupilot"', '-DCONFIG_HAL_BOARD=HAL_BOARD_SITL', '-DCONFIG_HAL_BOARD_SUBTYPE=HAL_BOARD_SUBTYPE_NONE', '../../libraries/AP_NavEKF3/AP_NavEKF3_GyroBias.cpp', '-c', '-o/home/hugo/ardupilot/build/sitl/libraries/AP_NavEKF3/AP_NavEKF3_GyroBias.cpp.0.o']
 -> task in 'objs/AP_NavEKF3' failed (exit status 1): 
	{task 140190447459856: cxx AP_NavEKF3_VehicleStatus.cpp -> AP_NavEKF3_VehicleStatus.cpp.0.o}
['/usr/lib/ccache/g++', '-std=gnu++11', '-fdata-sections', '-ffunction-sections', '-fno-exceptions', '-fsigned-char', '-Wall', '-Wextra', '-Wformat', '-Wshadow', '-Wpointer-arith', '-Wcast-align', '-Wundef', '-Wno-unused-parameter', '-Wno-missing-field-initializers', '-Wno-reorder', '-Wno-redundant-decls', '-Wno-unknown-pragmas', '-Werror=format-security', '-Werror=array-bounds', '-Werror=uninitialized', '-Werror=init-self', '-Werror=switch', '-Wfatal-errors', '-Werror=unused-but-set-variable', '-O3', '-include', 'ap_config.h', '-Ilibraries', '-Ilibraries/GCS_MAVLink', '-I.', '-I../../libraries', '-I../../libraries/AP_Common/missing', '-DSKETCHBOOK="/home/hugo/ardupilot"', '-DCONFIG_HAL_BOARD=HAL_BOARD_SITL', '-DCONFIG_HAL_BOARD_SUBTYPE=HAL_BOARD_SUBTYPE_NONE', '../../libraries/AP_NavEKF3/AP_NavEKF3_VehicleStatus.cpp', '-c', '-o/home/hugo/ardupilot/build/sitl/libraries/AP_NavEKF3/AP_NavEKF3_VehicleStatus.cpp.0.o']
SIM_VEHICLE: Build failed
SIM_VEHICLE: Killing tasks

What OS are you using and version ?
What computer type : ARM, x86-x64 ?

what is your gcc version : gcc --version ?
(We will finish by solve everthing ^^)

I’m using Ubuntu 16.04.02 LTS on x86_x64 machine

hugo@hugo-X202E:~/ardupilot/ArduCopter$ uname -i
x86_64


hugo@hugo-X202E:~/ardupilot/ArduCopter$ gcc --version
gcc (Ubuntu 5.4.0-6ubuntu1~16.04.4) 5.4.0 20160609
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


hugo@hugo-X202E:~/ardupilot/ArduCopter$ lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 16.04.2 LTS
Release:	16.04
Codename:	xenial

ok so you should have isnan … I lack of idea on what the problem is … I will try to ask others.
Could you use “sudo apt install build-essential ccache g++ gawk git make wget” just to be sure that g++ was installed ?

you did a fresh git clone on ardupilot repo right ? (git clone https://github.com/ArduPilot/ardupilot.git)

yes…g++ is installed

hugo@hugo-X202E:~/ardupilot/ArduCopter$ sudo apt install build-essential ccache g++ gawk git make wget
[sudo] password for hugo: 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
build-essential is already the newest version (12.1ubuntu2).
ccache is already the newest version (3.2.4-1).
g++ is already the newest version (4:5.3.1-1ubuntu1).
gawk is already the newest version (1:4.1.3+dfsg-0.1).
make is already the newest version (4.1-6).
git is already the newest version (1:2.7.4-0ubuntu1.1).
wget is already the newest version (1.17.1-1ubuntu1.2).
The following packages were automatically installed and are no longer required:
  calligra-data calligra-libs libakonadi-contact4 libakonadi-kde4 libakonadiprotocolinternals1 libappindicator1 libcauchy0.0v5 libdmtx0a libgles1-mesa libindicator7 libkabc4 libkcalcore4 libkldap4
  libkmime4 libkpimutils4 libkresources4 libkrossui4 libm2mml0.0v5 libphononexperimental4 libprison0 libqca2-plugin-ossl libqjson0 libqrencode3 libsoprano4 linux-headers-4.8.0-45
  linux-headers-4.8.0-45-generic linux-headers-4.8.0-46 linux-headers-4.8.0-46-generic linux-headers-4.8.0-49 linux-headers-4.8.0-49-generic linux-image-4.8.0-45-generic linux-image-4.8.0-46-generic
  linux-image-4.8.0-49-generic linux-image-extra-4.8.0-45-generic linux-image-extra-4.8.0-46-generic linux-image-extra-4.8.0-49-generic linux-signed-image-4.8.0-45-generic
  linux-signed-image-4.8.0-46-generic linux-signed-image-4.8.0-49-generic python-appindicator python-lzma python-markupsafe python-parsley python-txsocksx recordmydesktop snap-confine soprano-daemon tor
  tor-geoipdb torsocks ttf-liberation
Use 'sudo apt autoremove' to remove them.
0 to upgrade, 0 to newly install, 0 to remove and 19 not to upgrade.

and yes I did a fresh git clone on the ardupilot repo from that link…

Hey @khancyr,

I found this discussion in google group where apparently there are issues with gcc 5.4 and isnan (https://groups.google.com/forum/#!topic/qmcpack/JHSGBm87_6g).
The suggestion that solved the problem was

"Adding -DCMAKE_CXX_FLAGS="-std=c++11" to the cmake command line is probably the easiest way."

How can I do this for ardupilot?

also note that in ./waf configure in my previous post it yields

Cheers,
Hugo

We are already C++11 .
What I don’t understand is that I am also on ubuntu 16.04 with same gcc version.

Lets clean everything : sudo ccache -C
./waf distclean

Reboot computer (to clear ram etc.)

and then ./waf configure, you should have

╰─$ waf configure
Setting top to : /home/khancyr/Workspace/ardupilot
Setting out to : /home/khancyr/Workspace/ardupilot/build
Autoconfiguration : enabled
Setting board to : sitl
Checking for ‘g++’ (C++ compiler) : /usr/lib/ccache/g++
Checking for ‘gcc’ (C compiler) : /usr/lib/ccache/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 : 2.7.12
Checking for program ‘python’ : /usr/bin/python
Checking for python version >= 2.7.0 : 2.7.12
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
’configure’ finished successfully (0.969s)