Skip to content
This repository has been archived by the owner on Mar 17, 2021. It is now read-only.

make install script support ROS kinetic and melodic #761

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 31 additions & 15 deletions build_scripts/ubuntu_sim_ros_gazebo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ if [[ $wget_return_code -ne 0 ]]; then echo "Error downloading 'ubuntu_sim_commo
# Otherwise source the downloaded script.
. <(echo "${common_deps}")

# ROS Kinetic/Gazebo (ROS Kinetic includes Gazebo7 by default)
# Setup gazebo: ROS Kinetic includes Gazebo7, ROS Melodic includes Gazebo9
## Gazebo simulator dependencies
sudo apt-get install protobuf-compiler libeigen3-dev libopencv-dev -y

Expand All @@ -28,12 +28,20 @@ sudo apt-key adv --keyserver hkp://ha.pool.sks-keyservers.net:80 --recv-key 421C
## For keyserver connection problems substitute hkp://pgp.mit.edu:80 or hkp://keyserver.ubuntu.com:80 above.
sudo apt-get update
## Get ROS/Gazebo
sudo apt-get install ros-kinetic-desktop-full -y
if [[ $(lsb_release -sc) == *"bionic"* ]]; then
sudo apt-get install ros-melodic-desktop-full -y
source /opt/ros/melodic/setup.bash
elif [[ $(lsb_release -sc) == *"xenial"* ]]; then
sudo apt-get install ros-kinetic-desktop-full -y
source /opt/ros/kinetic/setup.bash
else
echo "OS version detected as $(lsb_release -sc), could not find valid ROS distro"
fi
## Initialize rosdep
sudo rosdep init
rosdep update
## Setup environment variables
rossource="source /opt/ros/kinetic/setup.bash"
rossource="source /opt/ros/$ROS_DISTRO/setup.bash"
if grep -Fxq "$rossource" ~/.bashrc; then echo ROS setup.bash already in .bashrc;
else echo "$rossource" >> ~/.bashrc; fi
eval $rossource
Expand All @@ -59,34 +67,42 @@ rosinstall_generator mavlink | tee -a /tmp/mavros.rosinstall
### Setup workspace & install deps
wstool merge -t src /tmp/mavros.rosinstall
wstool update -t src
if ! rosdep install --from-paths src --ignore-src --rosdistro kinetic -y; then
if ! rosdep install --from-paths src --ignore-src --rosdistro $ROS_DISTRO -y; then
# (Use echo to trim leading/trailing whitespaces from the unsupported OS name
unsupported_os=$(echo $(rosdep db 2>&1| grep Unsupported | awk -F: '{print $2}'))
rosdep install --from-paths src --ignore-src --rosdistro kinetic -y --os ubuntu:xenial
rosdep install --from-paths src --ignore-src --rosdistro $ROS_DISTRO -y --os ubuntu:$(lsb_release -sc)
fi

echo "Installing geographiclib dependencies"
sudo apt-get install libgeographic-dev -y
sudo apt-get install geographiclib-tools -y
sudo pip install future

## Build!
catkin config --extend /opt/ros/$ROS_DISTRO
catkin build
## Re-source environment to reflect new packages/build environment
catkin_ws_source="source ~/catkin_ws/devel/setup.bash"
if grep -Fxq "$catkin_ws_source" ~/.bashrc; then echo ROS catkin_ws setup.bash already in .bashrc;
else echo "$catkin_ws_source" >> ~/.bashrc; fi
eval $catkin_ws_source

echo "Downloading dependent script 'install_geographiclib_datasets.sh'"
# Source the install_geographiclib_datasets.sh script directly from github
install_geo=$(wget https://raw.githubusercontent.com/mavlink/mavros/master/mavros/scripts/install_geographiclib_datasets.sh -O -)
wget_return_code=$?
# If there was an error downloading the dependent script, we must warn the user and exit at this point.
if [[ $wget_return_code -ne 0 ]]; then echo "Error downloading 'install_geographiclib_datasets.sh'. Sorry but I cannot proceed further :("; exit 1; fi
# Otherwise source the downloaded script.
sudo bash -c "$install_geo"

# Go to the firmware directory
clone_dir=~/src
cd $clone_dir/Firmware

## Edit bashrc to contain firmware related paths
firmware_source="source ~/src/Firmware/Tools/setup_gazebo.bash ~/src/Firmware ~/src/Firmware/build/px4_sitl_default > /dev/null"
if grep -Fxq "$firmware_source" ~/.bashrc; then echo firmware setup already in .bashrc;
else echo "$firmware_source" >> ~/.bashrc; fi
eval $firmware_source

ros_package='export ROS_PACKAGE_PATH=${ROS_PACKAGE_PATH}:/home/tanja/src/Firmware:/home/tanja/src/Firmware/Tools/sitl_gazebo'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we should have hardcoded paths here.

if grep -Fxq "$ros_package" ~/.bashrc; then echo ros package path already in .bashrc;
else echo "$ros_package" >> ~/.bashrc; fi

if [[ ! -z $unsupported_os ]]; then
>&2 echo -e "\033[31mYour OS ($unsupported_os) is unsupported. Assumed an Ubuntu 16.04 installation,"
>&2 echo -e "\033[31mYour OS ($unsupported_os) is unsupported. Assumed an Ubuntu 16.04 or 18.04 installation,"
>&2 echo -e "and continued with the installation, but if things are not working as"
>&2 echo -e "expected you have been warned."
fi