ROS and Gazebo
Ros and Gazebo Installation for Ubuntu 18.04LTS
Installing Ros Melodic
Setup your computer to accept software from packages.ros.org.
sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
Setup your keys
sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
Making sure your Debian package is upto-date
sudo apt update
sudo apt upgrade
Install ROS Melodic
sudo apt install ros-melodic-desktop-full
Setting up your Environment
echo "source /opt/ros/melodic/setup.bash" >> ~/.bashrc
source ~/.bashrc
Installing Dependencies for the packages
sudo apt install python-rosdep python-rosinstall python-rosinstall-generator python-wstool build-essential
Install pip, toml, git, jupyter-lab.
sudo apt install git
sudo apt-get install python3-pip
pip install toml
pip3 install jupyterlab
Rosdep
sudo apt install python-rosdep
sudo rosdep init
rosdep update
PX4 and Mavros
source ubuntu_sim_ros_melodic.sh
Downloading Firmware
Go to Home Folder to create src.
mkdir src
cd src
git clone https://github.com/PX4/Firmware.git --recursive
Sourcing Gazebo through Bashrc
gedit ~/.bashrc
add the following lines at the end of the bashrc
source ~/sim_ws/devel/setup.bash
source ~/src/Firmware/Tools/setup_gazebo.bash ~/src/Firmware ~/src/Firmware/build/px4_sitl_default
export ROS_PACKAGE_PATH=$ROS_PACKAGE_PATH:~/src/Firmware
export ROS_PACKAGE_PATH=$ROS_PACKAGE_PATH:~/src/Firmware/Tools/sitl_gazebo
Open new Terminal then
cd src/Firmware
make px4_sitl gazebo
#this might open gazebo close it and continue
make px4_sitl_default gazebo
#after this command you should see a drone in the simulator
Simulation Example
mkdir sim_ws
cd sim_ws
mkdir src
catkin_make
#In a new terminal
cd sim_ws/src
catkin_create_pkg takeoff roscpp mavros geometry_msgs
Download the top file and paste it in ~/sim_ws/src/takeoff/(there will be a CMakeLists.txt delete and paste this.
Download the above file and paste it in ~/sim_ws/src/takeoff/src/
Now open a new terminal
cd sim_ws
catkin_make
source devel/setup.bash
In a new Terminal
roslaunch px4 mavros_posix_sitl.launch
#this will start gazebo
go back to previous terminal and
rosrun takeoff offb_node
#now you will see drone takeoff in the simulator
#if everything is installed correctly
Last updated
Was this helpful?