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 C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654Making sure your Debian package is upto-date
sudo apt update
sudo apt upgradeInstall ROS Melodic
sudo apt install ros-melodic-desktop-fullSetting up your Environment
echo "source /opt/ros/melodic/setup.bash" >> ~/.bashrc
source ~/.bashrcInstalling Dependencies for the packages
sudo apt install python-rosdep python-rosinstall python-rosinstall-generator python-wstool build-essentialInstall pip, toml, git, jupyter-lab.
sudo apt install git
sudo apt-get install python3-pip
pip install toml
pip3 install jupyterlabRosdep
sudo apt install python-rosdep
sudo rosdep init
rosdep updatePX4 and Mavros
source ubuntu_sim_ros_melodic.shDownloading Firmware
Go to Home Folder to create src.
mkdir src
cd src
git clone https://github.com/PX4/Firmware.git --recursiveSourcing Gazebo through Bashrc
gedit ~/.bashrcadd 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_gazeboOpen 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 simulatorSimulation 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_msgsDownload 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.bashIn a new Terminal
roslaunch px4 mavros_posix_sitl.launch
#this will start gazebogo back to previous terminal and
rosrun takeoff offb_node
#now you will see drone takeoff in the simulator
#if everything is installed correctlyLast updated
Was this helpful?