Option A: Automated bash script installation
We made for you one automated way to get into Swarm In Blocks full software on your machine.
If you have already one configuration for Apache that is serving another application, go with manual installation and be careful.
The installation script is presented in this link: install_swarm_in_blocks.sh . The script will install ROS, clone Swarm in Blocks, Clover and PX4 repositories, install dependencies, compile the workspace, install and configure Apache webserver.
Step 1: Download the script
Step 2: Run the script
Copy ./install_swarm_in_blocks.sh
Step 3: Run the simulation
Copy roslaunch swarm_in_blocks simulation.launch num:= 4 new_blocks_page:= true
Option B: Manual installation
If you encounter any problems with the above script, you can resort to manual installation (mostly for debugging).
Prerequisites: Ubuntu 20.04 .
Step 1: Updating apt (installation package)
Copy sudo apt-get update
sudo apt-get upgrade
Step 2: Installing required tools
Copy sudo apt install build-essential git python3-pip python3-rosdep nodejs npm
Step 3: Installing ROS
We recommend installing ROS Noetic for best compatibility:
Copy sudo apt-get install -y curl
sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.lis\t'
sudo apt-get update ; apt-get install -y python3-pip python3-rosdep python3-rosinstall-generator python3-wstool build-essen \t ial ros-noetic-desktop
Copy echo "source /opt/ros/noetic/setup.bash" >> ~/.bashrc
source /opt/ros/noetic/setup.bash
Copy sudo -E sh -c 'rosdep init'
rosdep update
If you prefer, you can install ROS Noetic using the official installation manual (Desktop or Full install).
Step 4: Creating Catkin workspace
Create a workspace for the simulation (we recommend the name "Catkin" for default):
Copy mkdir -p ~/catkin_ws/src
cd ~/catkin_ws
catkin_make
echo "source ~/catkin_ws/devel/setup.bash" >> ~/.bashrc
source ~/catkin_ws/devel/setup.bash
Step 5: Getting Swarm in Blocks sources and dependencies
Cloning from our GIthub repository:
Copy cd ~/catkin_ws/src
git clone https://github.com/Grupo-SEMEAR-USP/swarm_in_blocks.git
Installing the necessary dependencies:
Copy /usr/bin/python3 -m pip install -r ~/catkin_ws/src/swarm_in_blocks/requirements.txt
Step 6: Getting Clover sources
Cloning Clover and PX4 dependencies from Github repositorys:
It's important to note that the Clover repository that you must install is from our fork (Semear Group)
Copy cd ~/catkin_ws/src
git clone --single-branch --branch swarm_in_blocks https://github.com/Grupo-SEMEAR-USP/clover.git
git clone --depth 1 https://github.com/CopterExpress/ros_led
git clone --depth 1 https://github.com/ethz-asl/mav_comm
Also, you should make a symbolic link in order to allow the swarm_station
package to find the clovers meshes:
Copy ln -s ~/catkin_ws/src/clover/clover_description/meshes/clover4/ ~/catkin_ws/src/swarm_in_blocks/swarm_station/meshes/
Step 7: Installing dependencies with npm and rosdep
Rosdep:
Copy cd ~/catkin_ws
rosdep install --from-paths src --ignore-src -y
Npm:
Copy cd ~/catkin_ws/src/swarm_in_blocks/swarm_station/src/web_terminal
npm install
Step 8: Installing Clover's Python dependencies
Copy /usr/bin/python3 -m pip install -r ~/catkin_ws/src/clover/clover/requirements.txt
Step 9: Downloading PX4
Copy git clone --recursive --depth 1 --branch v1.12.0 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/
Step 10: Installing PX4 dependencies
Copy ~ /PX4-Autopilot/Tools/setup/ubuntu.sh
pip3 install --user toml
Step 11: Addding Clover airframe
Copy ln -s ~/catkin_ws/src/clover/clover_simulation/airframes/* ~/PX4-Autopilot/ROMFS/px4fmu_common/init.d-posix/airframes/
Step 12: Installing geographiclib datasets
Mavros package requires geographiclib datasets to be present:
Copy sudo -E sh -c '/opt/ros/noetic/lib/mavros/install_geographiclib_datasets.sh'
Step 13: Building the workspace
Build your workspace (it takes 10~20min):
Copy cd ~/catkin_ws
catkin_make
Step 14: Installing QGroundControl
Copy sudo -E sh -c "usermod -a -G dialout $USER"
sudo -E sh -c 'apt-get remove -y modemmanager; apt-get install -y gstreamer1.0-plugins-bad gstreamer1.0-libav'
curl https://s3-us-west-2.amazonaws.com/qgroundcontrol/latest/QGroundControl.AppImage -o ${HOME} /QGroundControl.AppImage
chmod a+x ${HOME} /QGroundControl.AppImage
Step 15: Installing Firefox web browser
Installing the recommended Browser:
Copy sudo apt-get update ; apt-get install -y firefox
Step 16: Installing apache webserver
Apache will be used for the front-end interface:
Copy sudo apt install apache2
Step 17: Configure apache webserver to serve swarm_in_blocks
directory:
Copy sudo sed -i 's@/var/www/html@'"${HOME}"'/catkin_ws/src/swarm_in_blocks@' /etc/apache2/sites-available/000-default.conf
sudo sed -i 's@/var/www/@'"${HOME}"'/catkin_ws/src/swarm_in_blocks@' /etc/apache2/apache2.conf
sudo a2ensite 000-default.conf
service apache2 reload
This way, to access our homepage you only need to access your localhost through a web browser, by just typing localhost
on the address place.
Step 18: Cleaning up
Copy sudo apt-get -y autoremove ; apt-get -y autoclean ; apt-get -y clean ; fstrim -v /
Step 19: Run the simulator
In order to be sure that everything was built correctly, try running the simulator for the first time:
Copy roslaunch swarm_in_blocks simulation.launch num:= 2 new_blocks_page:= true