Below is a detailed guide for installing ArduPilot and MAVProxy on Ubuntu 20.04.
Please note that this guide assumes a clean Ubuntu 20.04 installation.
Open a terminal and run the following commands:
sudo apt update
sudo apt upgrade -y
Clone the ArduPilot repository:
cd ~
sudo apt install git
git clone https://github.com/ArduPilot/ardupilot.git
cd ardupilot
git checkout Copter-3.6
git submodule update --init --recursive
Install dependencies needed for ArduPilot:
sudo apt install python-matplotlib python-serial python-wxgtk3.0 python-wxtools python-lxml python-scipy python-opencv ccache gawk python-pip python-pexpect
sudo apt install -y git python3-dev python3-opencv python3-wxgtk4.0 libxml2-dev
Build ArduPilot using the following commands:
Note:
-
You have already build Copter-3.6.
-
To configure for a specific flight controller, use the following command:
cd ardupilot
./waf configure --board [Board_Type]
Replace [Board_Type] with the appropriate board type.
For example:
- For CubeBlack:
cd ardupilot
./waf configure --board CubeBlack
- For CubeOrange:
cd ardupilot
./waf configure --board CubeOrange
After configuring, build ArduPilot:
./waf copter
To view the available board options for configuring ArduPilot, you can use the following command:
./waf list_boards
sudo apt-get install python3-pip
sudo pip3 install MAVProxy
gedit ~/.bashrc
This command opens the ~/.bashrc file in the gedit text editor. If you prefer a different text editor, you can replace gedit with the name of your preferred editor.
Once the text editor opens, go to the end of the file and add the following lines:
export PATH=$PATH:$HOME/ardupilot/Tools/autotest
export PATH=/usr/lib/ccache:$PATH
These lines add the specified paths to the PATH environment variable. Save the file after making these additions.
Save the changes you made in the text editor and close it.
To apply the changes without restarting your terminal, run the following command:
. ~/.bashrc
This command "sources" the ~/.bashrc file, making the changes take effect in the current terminal session.
Now, the specified directories are included in your PATH, making it convenient to run ArduPilot commands from any directory in the terminal.
Open a terminal and navigate to the ArduCopter directory within your ArduPilot folder:
cd ~/ardupilot/ArduCopter
Start the simulation with the specified vehicle type. Adjust the vehicle type as needed for your simulation:
sim_vehicle.py -v ArduCopter -w --console --map
This command initializes the Software In The Loop (SITL) simulation with the specified ArduCopter vehicle type. It allows you to set parameters and perform testing in a simulated environment.
Open a new terminal window.
Run MAVProxy to establish communication with the SITL instance:
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
--master tcp:127.0.0.1:5760
: Specifies the connection to the SITL instance.
--sitl 127.0.0.1:5501
: Specifies the SITL location.
--out 127.0.0.1:14550 --out 127.0.0.1:14551
: Specifies output ports for communication.
--console
: Opens the MAVProxy console for interaction.
This command establishes a MAVLink connection between MAVProxy and the SITL instance, allowing you to monitor and control the simulated vehicle. The --console option opens an interactive console for sending MAVLink commands.
Ensure that the SITL simulation is running before starting MAVProxy. The provided commands assume that your ArduCopter directory and simulation settings are correctly configured.
MAVProxy commands, ensure you have completed the above steps.
Below is a guide on common MAVProxy commands and examples on how to use them effectively.
MAVProxy Commands and Examples
The error message indicates that the arm-none-eabi-ar program is not found, which is part of the ARM toolchain needed for building ArduPilot. Let's address this by installing the necessary toolchain.
-
Open a terminal.
-
Install the ARM toolchain:
sudo apt-get install gcc-arm-none-eabi -y
- After installing, run the
./waf configure --board CubeBlack
command again:
./waf configure --board CubeBlack
If the issue persists, you may need to install additional packages.
Run the following commands:
sudo apt-get install libncurses5 libncurses5-dev
sudo apt-get install autoconf2.13
After installing these packages, attempt the ./waf configure --board CubeBlack command once more.
- Retry the configuration:
./waf configure --board CubeBlack
- If successful, proceed to build ArduPilot:
./waf copter
If you encounter further issues during the configuration or build process, carefully review the error messages. They often provide insights into missing dependencies or required packages.
sidharth@asus:~/ardupilot$ ./waf configure --board CubeOrange
./waf: /usr/bin/python: bad interpreter: No such file or directory
sidharth@asus:~/ardupilot$ ./waf list_boards
./waf: /usr/bin/python: bad interpreter: No such file or directory
The error bad interpreter: No such file or directory
typically indicates that the Python interpreter specified in the shebang line of the script is not found in the specified path. In this case, it looks like the python executable is not found in /usr/bin/python
.
To resolve this issue, you can follow these steps:
Open a terminal and check the version of Python installed on your system by running:
python --version
If you have Python 3 installed and want to use it instead of Python 2, you can create a symlink from python
to python3
. Run the following commands:
sudo ln -s /usr/bin/python3 /usr/bin/python
If you face additional difficulties, feel free to share the error messages, and I'll do my best to assist you further.
This guide should help you install ArduPilot, MAVProxy. Make sure to refer to the official documentation for any updates or additional configuration steps:
Installing Ardupilot and MAVProxy
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.