Skip to content

Commit

Permalink
Install dependencies for vanilla ubuntu image (aws-robotics#133)
Browse files Browse the repository at this point in the history
* install ros and vcs dependencies

* update comments

* update readme

* take --install-ros arg

* address review comments

* use matrix.gazebo instead of output.gazebo

* improve error msgs

* bump github action tag

Co-authored-by: chengke <[email protected]>
  • Loading branch information
cheng-kevin and chengke authored Jun 17, 2021
1 parent ba62940 commit 1c50fb7
Show file tree
Hide file tree
Showing 3 changed files with 124 additions and 37 deletions.
20 changes: 7 additions & 13 deletions .github/workflows/ros1.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,34 +21,28 @@ jobs:
if: ${{ github.event_name != 'push' || github.ref != 'refs/heads/ros2' }}
name: 'Build and Bundle (ROS1)'
container:
image: rostooling/setup-ros-docker:ubuntu-${{ matrix.ubuntu_distro }}-ros-${{ matrix.distro }}-ros-base-latest
image: ubuntu:${{ matrix.ubuntu_distro }}
outputs:
robot_ws_build_result: ${{ steps.robot_ws_build.outcome }}
simulation_ws_build_result: ${{ steps.simulation_ws_build.outcome }}
steps:
- name: Checkout Branch
uses: actions/checkout@v1
- name: Setup Permissions
run: |
# TODO(ros-tooling/setup-ros-docker#7): calling chown is necessary for now
sudo chown -R rosbuild:rosbuild "$HOME" .
- name: Scan using git-secrets
uses: aws-robotics/aws-robomaker-github-actions/git-secrets-scan-action@2.4.2
uses: aws-robotics/aws-robomaker-github-actions/git-secrets-scan-action@3.0.0
- id: robot_ws_build
name: Build and Bundle Robot Workspace
uses: aws-robotics/aws-robomaker-github-actions/robomaker-sample-app-ci@2.4.2
uses: aws-robotics/aws-robomaker-github-actions/robomaker-sample-app-ci@3.0.0
with:
ros-distro: ${{ matrix.distro }}
gazebo-version: ${{ matrix.gazebo }}
workspace-dir: robot_ws
generate-sources: true
colcon-bundle-retries: 3
- id: simulation_ws_build
name: Build and Bundle Simulation Workspace
uses: aws-robotics/aws-robomaker-github-actions/robomaker-sample-app-ci@2.4.2
uses: aws-robotics/aws-robomaker-github-actions/robomaker-sample-app-ci@3.0.0
with:
ros-distro: ${{ matrix.distro }}
gazebo-version: ${{ matrix.gazebo }}
workspace-dir: simulation_ws
colcon-bundle-retries: 3
- name: Configure AWS Credentials
Expand All @@ -60,20 +54,20 @@ jobs:
if: ${{ github.event_name == 'schedule' && contains(steps.robot_ws_build.outcome, 'success') && contains(steps.simulation_ws_build.outcome, 'success') }}
- id: upload_bundle
name: Upload bundle to S3
uses: aws-robotics/aws-robomaker-github-actions/s3-cp-action@2.4.2
uses: aws-robotics/aws-robomaker-github-actions/s3-cp-action@3.0.0
env:
AWS_S3_BUCKET: ${{ secrets.AWS_S3_BUCKET_ROS1 }}
AWS_REGION: ${{ secrets.AWS_REGION }}
FILES: 'sources.zip sources.tar.gz robot_ws.tar simulation_ws.tar'
DEST: 'travis/hello-world/${{ steps.robot_ws_build.outputs.ros-distro }}/${{ steps.robot_ws_build.outputs.gazebo-version }}/${{ steps.robot_ws_build.outputs.sample-app-version }}.${{ github.run_number }}/'
DEST: 'travis/hello-world/${{ matrix.distro }}/${{ matrix.gazebo }}/${{ steps.robot_ws_build.outputs.sample-app-version }}.${{ github.run_number }}/'
if: ${{ github.event_name == 'schedule' && contains(steps.robot_ws_build.outcome, 'success') && contains(steps.simulation_ws_build.outcome, 'success') }} # upload to S3 on "schedule" build if the build was successful
- name: Get time stamp
id: time
run: echo "::set-output name=timestamp::$(date +%s)"
if: ${{ github.event_name == 'schedule' && contains(steps.robot_ws_build.outcome, 'success') && contains(steps.simulation_ws_build.outcome, 'success') }}
- name: Update App-manifest version number
id: update-app-manifest
uses: aws-robotics/aws-robomaker-github-actions/codecommit-put-file-action@2.4.2
uses: aws-robotics/aws-robomaker-github-actions/codecommit-put-file-action@3.0.0
env:
AWS_CODECOMMIT_REPO_NAME: '${{ secrets.AWS_CODECOMMIT_REPO_NAME_PREFIX_HELLO_WORLD }}-${{ matrix.distro }}-gazebo${{ matrix.gazebo }}'
AWS_CODECOMMIT_BRANCH_NAME: ${{ secrets.AWS_CODECOMMIT_BRANCH_NAME_HELLO_WORLD }}
Expand Down
25 changes: 10 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,39 +4,34 @@ This demonstrates the structure of a ROS project that works with RoboMaker by cr

_RoboMaker sample applications include third-party software licensed under open-source licenses and is provided for demonstration purposes only. Incorporation or use of RoboMaker sample applications in connection with your production workloads or a commercial products or devices may affect your legal rights or obligations under the applicable open-source licenses. Source code information can be found [here](https://s3.console.aws.amazon.com/s3/buckets/robomaker-applications-us-east-1-72fc243f9355/hello-world/?region=us-east-1)._

## Requirements
## Installation

- [ROS Melodic](http://wiki.ros.org/melodic/Installation/Ubuntu) - Other versions may work, however they have not been tested
The following will be installed:
- [Colcon](https://colcon.readthedocs.io/en/released/user/installation.html) - Used for building and bundling the application.
- [vcstool](https://github.com/dirk-thomas/vcstool#how-to-install-vcstool) - Used to pull in sample app dependencies that are only available from source, not from apt or pip.
- [rosdep](http://wiki.ros.org/rosdep#Installing_rosdep) - rosdep is a command-line tool for installing system dependencies of ROS packages.

## Build
### Install requirements
Follow links above for instructions on installing required software.
If ROS is detected, then ROS Installation will be skipped.
- [ROS Melodic](http://wiki.ros.org/melodic/Installation/Ubuntu) - Other versions may work, however they have not been tested

### Pre-build commands

- *Full Setup Including ROS Install*
currently only melodic is supported, ROS Installation will be skipped if its already present.
```bash
sudo apt-get update
rosdep update
source scripts/setup.sh
```

### Robot
## Build

- *Robot Application*
```bash
cd robot_ws
vcs import < .rosinstall
rosdep install --from-paths src --ignore-src -r -y
colcon build
```

### Simulation

- *Simulation Application*
```bash
cd simulation_ws
vcs import < .rosinstall
rosdep install --from-paths src --ignore-src -r -y
colcon build
```

Expand Down
116 changes: 107 additions & 9 deletions scripts/setup.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,112 @@
#!/usr/bin/env bash

set -ex

apt-get update
source /opt/ros/$ROS_DISTRO/setup.sh
rosdep update
while [[ "$#" -gt 0 ]]; do
case $1 in
--install-ros) ros_distro=$2; shift ;;
esac
shift
done

supported_ros_distros=("melodic")

install_ros(){
echo "Installing ROS $ros_distro"
#Install ROS Prerequisites
apt update
apt-get install -y lsb-release gnupg2 curl && apt-get clean all
rm -f "/etc/apt/sources.list.d/ros-latest.list"
sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
curl -sSL 'http://keyserver.ubuntu.com/pks/lookup?op=get&search=0xC1CF6E31E6BADE8868B172B4F42ED6FBAB17C654' | apt-key add -
apt update

#Install ROS $ros_distro
apt install -y ros-$ros_distro-desktop-full
source /opt/ros/$ros_distro/setup.bash
}


setup_sample_app(){
echo "Setting up sample application. Installing tools and dependencies."
#setup key for colcon bundle
apt-key adv --fetch-keys 'http://packages.osrfoundation.org/gazebo.key'
apt update
apt install -y python-rosdep git
if [ ! -f "/etc/ros/rosdep/sources.list.d/20-default.list" ];
then
rosdep init
fi
rosdep update

apt-get install -y python3-apt python3-pip python3-vcstool
pip3 install -U setuptools colcon-common-extensions colcon-ros-bundle

cd robot_ws
vcs import < .rosinstall
rosdep install --from-paths src --ignore-src -r -y
cd ..

cd simulation_ws
vcs import < .rosinstall
rosdep install --from-paths src --ignore-src -r -y
cd ..
}

if [ -d "/opt/ros" ];
then
echo "A ROS installation already exists in your environment."
if [ ! -z "$ros_distro" ];
then
echo "Ignoring request to install $ros_distro because a ROS installation already exists in your environment."
fi

found_supported_ros=false
#check if their ros installation(s) are supported
for distro in $supported_ros_distros
do
if [ -d "/opt/ros/$distro" ]
then
source /opt/ros/$distro/setup.bash
#save to verify installation below
ros_distro=$distro
found_supported_ros=true
break
fi
done

#if supported versions are not found
if [ ! found_supported_ros ]
then
echo "ERROR: your installed ROS Distro(s) is not supported. Exiting."
exit 1
fi

elif [ -z "$ros_distro" ];
then
echo "No ROS Installation was found and no ROS Distro was specified. Defaulting to installing ROS Melodic"
ros_distro="melodic"
install_ros
source /opt/ros/$ros_distro/setup.bash
elif [[ " ${supported_ros_distros[@]} " =~ " ${ros_distro} " ]]; #check if item in list
then
echo "No ROS Installation found. Installing $ros_distro"
install_ros
source /opt/ros/$ros_distro/setup.bash
elif [[ ! " ${supported_ros_distros[@]} " =~ " ${ros_distro} " ]]; #check if item in list
then
echo "The selected ROS Distro $ros_distro is not supported. Exiting."
exit 0
fi

#Verify Installation
if [ $ROS_DISTRO != $ros_distro ];
then
echo "The ROS installation was unsuccessful, Sample Application setup cannot continue. Exiting."
exit 1
else
echo "ROS Installation was successful, continuing with Sample Application setup."
fi

apt-get install -y python3-apt python3-pip
pip3 install -U setuptools
pip3 install -U colcon-common-extensions colcon-ros-bundle

rosdep install --from-paths ./robot_ws/src --ignore-src -r -y
rosdep install --from-paths ./simulation_ws/src --ignore-src -r -y
setup_sample_app

0 comments on commit 1c50fb7

Please sign in to comment.