Setting up the simulation environment from scratch requires some effort, but results in the most performant setup, with less chance of driver issues.
Prerequisites: Ubuntu 20.04.
Install ROS Noetic using the official installation manual (Desktop or Full install).
Add sourcing ROS'
setup.bash initialization script to your
echo "source /opt/ros/noetic/setup.bash" >> ~/.bashrc source ~/.bashrc
Install required tools:
sudo apt install build-essential git python3-pip python3-rosdep
Create a workspace for the simulation:
mkdir -p ~/catkin_ws/src cd ~/catkin_ws catkin_make echo "source ~/catkin_ws/devel/setup.bash" >> ~/.bashrc source ~/.bashrc
Clone Clover sources:
cd ~/catkin_ws/src git clone --depth 1 https://github.com/CopterExpress/clover git clone --depth 1 https://github.com/CopterExpress/ros_led git clone --depth 1 https://github.com/ethz-asl/mav_comm
Install all dependencies using
cd ~/catkin_ws sudo rosdep init rosdep update rosdep install --from-paths src --ignore-src -y
Install Python dependencies:
sudo /usr/bin/python3 -m pip install -r ~/catkin_ws/src/clover/clover/requirements.txt
PX4 will be built along with the other packages in our workspace. You may clone it directly into the workspace or put it somewhere and symlink to
~/catkin_ws/src. We will need to put its
mavlink submodules into
~/catkin_ws/src as well.
Clone PX4 sources and make the required symlinks:
git clone --recursive --depth 1 --branch v1.12.3 https://github.com/PX4/PX4-Autopilot.git ~/PX4-Autopilot ln -s ~/PX4-Autopilot ~/catkin_ws/src/ ln -s ~/PX4-Autopilot/Tools/sitl_gazebo ~/catkin_ws/src/ ln -s ~/PX4-Autopilot/mavlink ~/catkin_ws/src/
You may use more recent PX4 version, but there would be more risk of something would not be working.
PX4 comes with its own script for dependency installation. We may as well leverage it:
cd ~/catkin_ws/src/PX4-Autopilot/Tools/setup sudo ./ubuntu.sh
This will install everything required to build PX4 and its SITL environment.
You may want to skip installing the ARM toolchain if you're not planning on compiling PX4 for your flight controller. To do this, use the
sudo ./ubuntu.sh --no-nuttx.
Install more required Python packages:
pip3 install --user toml
Add the Clover airframe to PX4 using the command:
ln -s ~/catkin_ws/src/clover/clover_simulation/airframes/* ~/PX4-Autopilot/ROMFS/px4fmu_common/init.d-posix/airframes/
mavros package requires geographiclib datasets to be present:
Build your workspace:
cd ~/catkin_ws catkin_make
If building fails with RAM issues (
c++: fatal error: Killed signal terminated program cc1plus), reduce the number of parallel jobs using
-jkey. For example, to use only two parallel jobs use
In order to be sure that everything was built correctly, try running the simulator for the first time:
roslaunch clover_simulation simulator.launch
You can test autonomous flight using example scripts in
To make it possible to run Gazebo simulation environment without Clover (
gazebo command), add into your
.bashrc sourcing Gazebo's initialization script:
echo "source /usr/share/gazebo/setup.sh" >> ~/.bashrc
Optionally, install roscore systemd service to have roscore running in background:
sed -i "s/pi/$USER/g" ~/catkin_ws/src/clover/builder/assets/roscore.service sudo cp ~/catkin_ws/src/clover/builder/assets/roscore.service /etc/systemd/system sudo systemctl enable roscore sudo systemctl start roscore
Install any web server to serve Clover's web tools (
~/.ros/www directory), e. g. Monkey:
wget https://github.com/CopterExpress/clover_vm/raw/master/assets/packages/monkey_1.6.9-1_$(dpkg --print-architecture).deb -P /tmp sudo dpkg -i /tmp/monkey_*.deb sed "s/pi/$USER/g" ~/catkin_ws/src/clover/builder/assets/monkey | sudo tee /etc/monkey/sites/default sudo sed -i 's/SymLink Off/SymLink On/' /etc/monkey/monkey.conf sudo cp ~/catkin_ws/src/clover/builder/assets/monkey.service /etc/systemd/system/monkey.service sudo systemctl enable monkey sudo systemctl start monkey