Install ardupilot4.0 on ubuntu20.04 and compile error

Hello, after I installed it according to the installation tutorial on the official website (Setting up the Build Environment (Linux/Ubuntu) — Dev documentation), an error was reported. I don’t know how to solve this.

# Option “-e” is deprecated and might be removed in a later version of gnome-terminal.
# Use “-- ” to terminate the options and put the command line to execute after it.
Connect tcp: source_system=255
[Errno 111] Connection refused sleeping
Traceback (most recent call last):
  File "/home/rap/.local/bin/", line 1395, in <module>
    load_module(m, quiet=True)
  File "/home/rap/.local/bin/", line 498, in load_module
    module = m.init(mpstate, **kwargs)
AttributeError: module 'terrain' has no attribute 'init'

And every time I run this command (Tools/environment_install/ -y
) Will look like the picture, I’m not sure if this is normal, I need to exit with ctrl+z.

That is not a compile error.
After the compilation, compiled SITL binary and MAVProxy is automatically started with
when you type on the terminal and press enter, do you see an error message related with the terrain? Or in the MAVProxy terminal, module load terrain? You can start the SITL on its own, without an then connect to it with I made a tutorial here.

After I ran the command (./ -v ArduCopter --map --console) in the /ardupilot/Tools/autotest/ directory, a window flashed and then closed. That window should be a mavproxy window.

I recommend you to run like python3 -w -v ArduCopter --map --console. If it still not working, reinstalling the mavproxy might help.

I have tried uninstalling and installing, and also tried other versions, but still have the same problem.

python3 -m pip install --upgrade mavproxy
and also
python -m pip install --upgrade mavproxy
If it is still not working, you can try fresh installing the environment again.
Follow here and then here.
It should work.

The above error will still be reported. I think it may be a problem with mavproxy, but the problem has not been fixed after reinstalling.

Question are you using the install script as it was from the 4.07 release?
I looked for this output, dpkg-query -l "lsb-release, from your install_script console and it appears in 4.07 but not in 4.2Dev

The 4.07 install script might not work correctly anymore… a lot has changed since in terms of environment and Ubuntu 20.04 wasn’t around then??

  1. Clone your fork of master
  2. use the install_script from 4.2Dev
  3. Check that sitl works on 4.2Dev (if you need to build a board check that works too on master)
  4. Checkout and build for 4.07

Also any reason you want to use 4.07?

I use the command (git checkout Copter-4.0.7) to switch the version to 4.0.7.
I changed the version of ubuntu to 18.04, but the same problem still occurs. After I copied the code that can run on other virtual machines, the same problem still occurred.
I would like to ask whether the installation of ArduPilot uses python3 or python2. I have been using python3 in the environment.
I need to use 4.0.7 to reproduce some work related to the thesis.

It uses python2. Do not use python3 on ArduCopter 4.0.7

You didn’t answer the first question regarding the install script? There are of course other updates that change in those install scripts besides OS as time moves forward.

Did you do any of the steps I suggested?

Please put into a text file the full output from ./waf configure --board=CubeOrange & ./waf copter

I will of course defer to Amilcar on pyhton2 vs 3.

I can easily build 4.07 on my WSL machine with Ubuntu 20.04 for sitl. A real board requires some “intervention” unfortunately…

Couple caveats. And a better dev than I will probably have an easier way to do this…

  1. In the current dev version move out the file Tools/gittools/
    you will need that to fix your submodules. And it wont exist when you checkout 4.07
  2. In the ardupilot directory run script
  3. Build for sitl that should work, ./Tools/autotest/ -v Plane --console -D --speedup 1 --map

Everything below assumes you want to build for an actual board else you dont need to do these
4. You will need to switch to using the arm compilers (g++ 6.3) from that time as the defaults now install (g++ 10)
You will thus need to install arm_6.3 compilers: find them here

Right now I do this by modifying my path to the following
export PATH="/opt/gcc-arm-none-eabi-6-2017-q2-update/bin:$PATH"
And I remove the /opt/gcc-arm-none-eabi-6-2017-q2-update/bin

You should be able to use waf --tool-chain option but that isnt working for me.

  1. If you get permission errors when from do a chmod -R 755 . assuming you are in the ardupilot directory

I am not sure whether the installation script will change after I use git to change the version of arducopter to 4.0.7, so I am not very sure whether I am using the 4.0.7 installation script.
I changed the installed version to 4.1.0. I ran ./waf configure --board=CubeOrange & ./waf copter and got the following output.

rap@rap-vm:~/ardupilot/4.1.0/ardupilot$ ./waf configure --board=CubeOrange & ./waf copter
[1] 5311
Setting top to                           : /home/rap/ardupilot/4.1.0/ardupilot 
Setting out to                           : /home/rap/ardupilot/4.1.0/ardupilot/build 
Autoconfiguration                        : enabled 
Setting board to                         : CubeOrange 
Using toolchain                          : arm-none-eabi 
Could not find the program ['arm-none-eabi-ar']
(complete log in /home/rap/ardupilot/4.1.0/ardupilot/build/config.log)
Setting top to                           : /home/rap/ardupilot/4.1.0/ardupilot 
Setting out to                           : /home/rap/ardupilot/4.1.0/ardupilot/build 
Autoconfiguration                        : enabled 
Setting board to                         : sitl 
Using toolchain                          : native 
Checking for 'g++' (C++ compiler)        : /usr/bin/g++ 
Checking for 'gcc' (C compiler)          : /usr/bin/gcc 
Checking for c flags '-MMD'              : yes 
Checking for cxx flags '-MMD'            : yes 
CXX Compiler                             : g++ 7.5.0 
Checking for need to link with librt     : not necessary 
Checking for feenableexcept              : yes 
Checking for HAVE_CMATH_ISFINITE         : yes 
Checking for HAVE_CMATH_ISINF            : yes 
Checking for HAVE_CMATH_ISNAN            : yes 
Checking for header endian.h                   : yes 
Checking for header byteswap.h                 : yes 
Checking for HAVE_MEMRCHR                      : yes 
Checking for program 'python'                  : /usr/bin/python 
Checking for python version >= 2.7.0           : 2.7.17 
Checking for program 'python'                  : /usr/bin/python 
Checking for python version >= 2.7.0           : 2.7.17 
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 
Scripting                                      : enabled 
Scripting runtime checks                       : enabled 
Debug build                                    : disabled 
Coverage build                                 : disabled 
Checking for program 'rsync'                   : /usr/bin/rsync 
Waf: Entering directory `/home/rap/ardupilot/4.1.0/ardupilot/build/sitl'
Embedding file locations.txt:Tools/autotest/locations.txt
Embedding file models/Callisto.json:Tools/autotest/models/Callisto.json
[201/872] Compiling libraries/AP_GPS/AP_GPS.cpp
[215/872] Compiling libraries/AP_IOMCU/AP_IOMCU.cpp
[216/872] Compiling libraries/AP_IRLock/AP_IRLock_SITL_Gazebo.cpp
[217/872] Compiling libraries/AP_IRLock/AP_IRLock_I2C.cpp
[218/872] Compiling libraries/AP_IRLock/IRLock.cpp
[219/872] Compiling libraries/AP_IRLock/AP_IRLock_SITL.cpp
[220/872] Compiling libraries/AP_InertialNav/AP_InertialNav_NavEKF.cpp
[221/872] Compiling libraries/AP_InertialSensor/AP_InertialSensor_SITL.cpp
../../libraries/AP_GPS/AP_GPS.cpp: In member function ‘void AP_GPS::send_mavlink_gps2_raw(mavlink_channel_t)’:
../../libraries/AP_GPS/AP_GPS.cpp:1257:10: error: too many arguments to function ‘void mavlink_msg_gps2_raw_send(mavlink_channel_t, uint64_t, uint8_t, int32_t, int32_t, int32_t, uint16_t, uint16_t, uint16_t, uint16_t, uint8_t, uint8_t, uint32_t, uint16_t)’
         0);                    // TODO one-sigma heading accuracy standard deviation
compilation terminated due to -Wfatal-errors.

Waf: Leaving directory `/home/rap/ardupilot/4.1.0/ardupilot/build/sitl'
Build failed
 -> task in 'objs/AP_GPS' failed (exit status 1): 
	{task 139818370596688: cxx AP_GPS.cpp -> AP_GPS.cpp.0.o}
 (run with -v to display more information)
[1]+  Exit 1                  ./waf configure --board=CubeOrange

The previous error may be because I tried to install mavproxy in python3.8 and then run ardupilot. After I changed python to 2.7, I copied the ardupilot4.0.7 code that can run on another virtual machine to this new virtual machine and ran into this problem.

Yes, when you change the branch from master to 4.07 every file changes to be in the state the repository was at for the 4.07 branch. Thus this include the development environment scripts.

Ok. Please focus on one issue and lets work on that one.

From the screenshot of your desktop it is clear mavproxy did not start. “An exception has occurred from …”

The first thing to do is getting everything working on master.

I have installed my ardupilot, I think the possible reasons for the problem are:

  1. The python version may use python3 before, and the correct one should be python2.
  2. pip install MAVProxy should pay attention to the case of letters, I am not sure if this is the cause of the error, but after I changed it, it ran successfully.
  3. Some commands cannot be executed completely due to network reasons.