Skip to content

Commit

Permalink
Modified dockerfile and added "docking_control" ROS noetic pkg
Browse files Browse the repository at this point in the history
  • Loading branch information
rakeshv24 committed Jun 10, 2024
1 parent f97c1ab commit 9dc9ed9
Show file tree
Hide file tree
Showing 69 changed files with 5,416 additions and 112 deletions.
4 changes: 2 additions & 2 deletions .devcontainer/nouveau/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
FROM ghcr.io/robotic-decision-making-lab/ros-template:noetic-desktop
FROM ghcr.io/robotic-decision-making-lab/underwater_docking:noetic-desktop

# Install ROS dependencies
# This is done in a previous stage, but we include it again here in case anyone wants to
# add new dependencies during development
ENV USERNAME=ros
ENV USER_WORKSPACE=/home/$USERNAME/ws_ros
ENV USER_WORKSPACE=/home/$USERNAME/ws_dock
WORKDIR $USER_WORKSPACE

COPY --chown=$USER_UID:$USER_GID . src/$PROJECT_NAME
Expand Down
6 changes: 3 additions & 3 deletions .devcontainer/nouveau/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"name": "ROS Dev Container",
"name": "nouveau",
"dockerFile": "Dockerfile",
"context": "../..",
"workspaceMount": "source=${localWorkspaceFolder},target=/home/ros/ws_ros/src/ros-template,type=bind",
"workspaceFolder": "/home/ros/ws_ros/src/ros-template",
"workspaceMount": "source=${localWorkspaceFolder},target=/home/ros/ws_dock/src/underwater_docking,type=bind",
"workspaceFolder": "/home/ros/ws_dock/src/underwater_docking",
"remoteUser": "ros",
"runArgs": [
"--network=host",
Expand Down
4 changes: 2 additions & 2 deletions .devcontainer/nvidia/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
FROM ghcr.io/robotic-decision-making-lab/ros-template:noetic-desktop-nvidia
FROM ghcr.io/robotic-decision-making-lab/underwater_docking:noetic-desktop-nvidia

# Install ROS dependencies
# This is done in a previous stage, but we include it again here in case anyone wants to
# add new dependencies during development
ENV USERNAME=ros
ENV USER_WORKSPACE=/home/$USERNAME/ws_ros
ENV USER_WORKSPACE=/home/$USERNAME/ws_dock
WORKDIR $USER_WORKSPACE

COPY --chown=$USER_UID:$USER_GID . src/$PROJECT_NAME
Expand Down
6 changes: 3 additions & 3 deletions .devcontainer/nvidia/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"name": "ROS NVIDIA Dev Container",
"name": "nvidia",
"dockerFile": "Dockerfile",
"context": "../..",
"workspaceMount": "source=${localWorkspaceFolder},target=/home/ros/ws_ros/src/ros-template,type=bind",
"workspaceFolder": "/home/ros/ws_ros/src/ros-template",
"workspaceMount": "source=${localWorkspaceFolder},target=/home/ros/ws_dock/src/underwater_docking,type=bind",
"workspaceFolder": "/home/ros/ws_dock/src/underwater_docking",
"remoteUser": "ros",
"runArgs": [
"--network=host",
Expand Down
49 changes: 40 additions & 9 deletions .docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ ARG ROS_DISTRO=noetic
FROM ros:$ROS_DISTRO-ros-base as ci

ENV DEBIAN_FRONTEND=noninteractive
WORKDIR /root/ws_ros
WORKDIR /root/ws_dock

# Update to be your project's name
ENV PROJECT_NAME=ros-template
ENV PROJECT_NAME=underwater_docking

COPY . src/$PROJECT_NAME

Expand All @@ -21,6 +21,14 @@ RUN apt-get -q update \
clang-tools \
python3-pip \
python3-dev \
python3-rosdep \
python3-rosinstall \
python3-rosinstall-generator \
python3-wstool \
python3-catkin-tools \
build-essential \
nano \
vim \
apt-utils \
software-properties-common \
&& apt-get autoremove -y \
Expand Down Expand Up @@ -56,13 +64,36 @@ USER $USERNAME
ENV USER=$USERNAME

ENV DEBIAN_FRONTEND=noninteractive
ENV USER_WORKSPACE=/home/$USERNAME/ws_ros
WORKDIR $USER_WORKSPACE

# Install MAVROS dependencies
WORKDIR /home/$USERNAME
RUN wget https://raw.githubusercontent.com/mavlink/mavros/ros2/mavros/scripts/install_geographiclib_datasets.sh \
&& chmod +x install_geographiclib_datasets.sh \
&& sudo ./install_geographiclib_datasets.sh

# Install acados
WORKDIR /home/$USERNAME
RUN git clone https://github.com/acados/acados.git \
&& cd acados \
&& git submodule update --recursive --init \
&& mkdir -p build \
&& cd build \
&& cmake -DACADOS_WITH_QPOASES=ON -DACADOS_WITH_OSQP=ON ..\
&& make install -j4

# Install acados python interface
WORKDIR /home/$USERNAME
RUN pip install -e /home/$USERNAME/acados/interfaces/acados_template \
&& export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:"/home/$USERNAME/acados/lib" \
&& export ACADOS_SOURCE_DIR="/home/$USERNAME/acados"


ENV USER_WORKSPACE=/home/$USERNAME/ws_dock
WORKDIR $USER_WORKSPACE
COPY --chown=$USER_UID:$USER_GID . src/$PROJECT_NAME

# Uncomment to download and install external repos used by the project
# RUN vcs import src < src/$PROJECT_NAME/ros2.repos
# RUN vcs import src < src/$PROJECT_NAME/ros.repos

# Install all ROS dependencies
WORKDIR $USER_WORKSPACE
Expand All @@ -83,16 +114,16 @@ RUN . "/opt/ros/${ROS_DISTRO}/setup.sh" \
FROM robot as desktop

ENV DEBIAN_FRONTEND=noninteractive
ENV USER_WORKSPACE=/home/$USERNAME/ws_ros
ENV USER_WORKSPACE=/home/$USERNAME/ws_dock
WORKDIR $USER_WORKSPACE

# Install Gazebo packages
# Install Gazebo and RViz
RUN sudo apt-get update \
&& sudo apt-get -q -y upgrade \
&& curl -sSL http://get.gazebosim.org | sh \
&& sudo apt-get -q install --no-install-recommends -y \
ros-$ROS_DISTRO-gazebo-ros-pkgs \
ros-$ROS_DISTRO-gazebo-ros-control \
ros-$ROS_DISTRO-gazebo* \
ros-$ROS_DISTRO-rviz \
&& sudo apt-get autoremove -y \
&& sudo apt-get clean -y \
&& sudo rm -rf /var/lib/apt/lists/*
Expand Down
2 changes: 1 addition & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
!requirements-dev.txt

# Allow your ROS packages here, e.g.:
!example_pkg
!bluerov2_docking
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ env:
jobs:
test:
name: Test Implementation
runs-on: ubuntu-latest
runs-on: ubuntu-20.04

strategy:
fail-fast: false
Expand All @@ -37,7 +37,7 @@ jobs:
- name: Run ROS Industrial CI
uses: ros-industrial/industrial_ci@master
env:
DOCKER_IMAGE: ghcr.io/robotic-decision-making-lab/ros-template:${{ matrix.env.IMAGE }}
DOCKER_IMAGE: ghcr.io/robotic-decision-making-lab/underwater_docking:${{ matrix.env.IMAGE }}
CXXFLAGS: >-
-Wall -Wextra -Wpedantic -Wwrite-strings -Wunreachable-code -Wpointer-arith -Wredundant-decls
CC: ${{ env.CLANG_TIDY && 'clang' }}
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ on:
workflow_dispatch:

env:
PUSH: ${{ (github.event_name != 'pull_request') && (github.repository == 'robotic-decision-making-lab/ros-template') }}
PUSH: ${{ (github.event_name != 'pull_request') && (github.repository == 'robotic-decision-making-lab/underwater_docking') }}

jobs:
ci:
strategy:
fail-fast: false
matrix:
ROS_DISTRO: [noetic]
runs-on: ubuntu-latest
runs-on: ubuntu-20.04
permissions:
packages: write
contents: read
Expand Down Expand Up @@ -60,7 +60,7 @@ jobs:
fail-fast: false
matrix:
ROS_DISTRO: [noetic]
runs-on: ubuntu-latest
runs-on: ubuntu-20.04
permissions:
packages: write
contents: read
Expand Down Expand Up @@ -108,7 +108,7 @@ jobs:
fail-fast: false
matrix:
ROS_DISTRO: [noetic]
runs-on: ubuntu-latest
runs-on: ubuntu-20.04
permissions:
packages: write
contents: read
Expand Down Expand Up @@ -149,7 +149,7 @@ jobs:
fail-fast: false
matrix:
ROS_DISTRO: [noetic]
runs-on: ubuntu-latest
runs-on: ubuntu-20.04
permissions:
packages: write
contents: read
Expand Down
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,9 @@
devel
install
log

*.tar.gz
*.png
*.pyc
*.bag
.DS_Store
145 changes: 116 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,39 +1,126 @@
# ROS Project Template
# docking_control

Setting up a new ROS project often requires a significant amount of
preparation and boilerplate configuration, costing you valuable robot
development time 🤖. Recognizing this, we have put together this template
repository configured with a ROS development environment, continuous
integration, and more. This project is the result of much trial and error
across many projects, and we hope that this helps you save some effort in
setting up your own projects.
This package was developed to control a BlueROV2 to perform autonomous underwater docking. This package utilizes Model Predictive Control (MPC) to achieve optimal control of the vehicle.

## Features
This repository is a modified version of the [bluerov_ros_playground](https://github.com/patrickelectric/bluerov_ros_playground) repo authored by [patrickelectric](https://github.com/patrickelectric).

The main features of this template are:
## Getting Started

- A development environment for Visual Studio Code including a [development container](https://code.visualstudio.com/docs/devcontainers/containers)
and configurations for linting and auto-formatting your code
- Docker images that support deployment to a variety of systems (e.g., arm64
systems)
- Continuous integration and deployment pipelines using GitHub Actions
- GitHub Issue and Pull Request templates
### Requirements

## Quick start
- [Python](https://www.python.org/downloads/) 3.6 or newer
- [Numpy](https://pypi.org/project/numpy/)
- [OpenCV](https://pypi.org/project/opencv-python/)
- [PyYAML](https://pypi.org/project/PyYAML/)
- [Gi & Gobject](https://wiki.ubuntu.com/Novacut/GStreamer1.0)
- [CasADi](https://pypi.org/project/casadi/)
- [acados](https://docs.acados.org/index.html)
- [Pandas](https://pypi.org/project/pandas/)
- [ROS](http://wiki.ros.org/ROS/Installation)
- kinetic or newer
- Geographlib
- [imutils](https://github.com/PyImageSearch/imutils)
- [MAVROS](http://wiki.ros.org/mavros)

Using this template is as easy as 1, 2, 3...
### Installation

1. Use this repository [as a template](https://docs.github.com/en/repositories/creating-and-managing-repositories/creating-a-repository-from-a-template)
for your project
2. Replace all instances of "ros-template" with your own project's name and all
instances of "robotic-decision-making-lab" with your own user's name
3. Replace the source code with your own project!
#### Installing ROS: *Ubuntu 20.04* (See [ROS wiki](http://wiki.ros.org/ROS/Installation) for other OS)

Feel free to remove any unused configurations/pipelines and to adjust things as
you see fit for your project!
1. Set up sources.list
- `sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'`
2. Set up keys
- `sudo apt install curl`
- `curl -s https://raw.githubusercontent.com/ros/rosdistro/master/ros.asc | sudo apt-key add -`
3. Installation
- `sudo apt update`
- Pick how much ROS you want to install: must be either Desktop or Desktop-Full
- ROS Desktop (includes rqt and rviz)
- `sudo apt install ros-noetic-desktop`
- Desktop-Full (includes Desktop and 2D/3D simulators)
- `sudo apt install ros-noetic-desktop-full`
4. Set up environment
- You must source this script in every bash terminal you use ROS in
- `source /opt/ros/noetic/setup.bash`
- To automatically source this script every time a new shell is launched, run
- `echo "source /opt/ros/noetic/setup.bash" >> ~/.bashrc`
- `source ~/.bashrc`
- Check that *source /opt/ros/noetic/setup.bash* has been added to the end of .bashrc
5. Install dependencies for building packages
- `sudo apt install python3-rosdep python3-rosinstall python3-rosinstall-generator python3-wstool build-essential`
6. Initialize rosdep
- `sudo apt install python3-rosdep`
- `sudo rosdep init`
- `rosdep update`

## Getting help
#### Building a Catkin Workspace

If you have questions regarding usage of this project or would like to
contribute, please ask a question on our [Discussions](https://github.com/Robotic-Decision-Making-Lab/ros-template/discussions)
board!
1. Create and build workspace
- `mkdir -p ~/catkin_ws/src`
- `cd ~/catkin_ws/`
- `catkin_make`
- This will create a workspace with 'build', 'devel', and 'src' folders and a *CMakeLists.txt* in 'src'
2. Source
- `source devel/setup.bash`
- To automatically source this script every time a new shell is launched, run
- `echo "source /home/<username>/catkin_ws/devel/setup.bash" >> ~/.bashrc`
- `source ~/.bashrc`
- Check that *source /home/< username>/catkin_ws/devel/setup.bash* has been added to the end of .bashrc
3. Make sure the ROS_PACKAGE_PATH includes the directory
- `echo $ROS_PACKAGE_PATH`
/home/youruser/catkin_ws/src:/opt/ros/noetic/share

#### Installing CasADi

`pip install casadi`

#### Installing acados

Please follow the instructions provided in the following two links:

- [Source Installation](https://docs.acados.org/installation/index.html)
- [Python Interface](https://docs.acados.org/python_interface/)

#### Installing MAVROS

`sudo apt-get install ros-noetic-mavros ros-noetic-mavros-extras`

#### Installing Geographlib

`sudo /opt/ros/noetic/lib/mavros/install_geographiclib_datasets.sh`

#### Installing imutils

`pip install imutils`

#### Installing Pandas

`pip install pandas`

#### Installing OpenCV

1. Make sure python-opencv is not installed
- `pip uninstall opencv-python`
2. Install opencv-contrib-python
- `pip install opencv-contrib-python`

#### Cloning Project

1. Go to your ROS package source directory:
- `cd catkin_ws/src`
2. Clone this project
- `git clone https://github.com/rakeshv24/bluerov2_dock`
3. Go back to your workspace:
- `cd ../`
4. Build and install the project:
- `catkin_make --pkg bluerov2_dock`
5. Reload your ROS env.
- `source devel/setup.sh`

## Usage

- Before proceeding further, make sure that all the steps mentioned in the guide for [Software Setup](https://bluerobotics.com/learn/bluerov2-software-setup
) has been followed.
- From a terminal, run `roslaunch bluerov2_dock mission_control.launch`
- If the terminal initially outputs *Controller error:'joy'*, move the sticks to clear the error.
- Press button "A" on the joystick to enable autonomous docking mode.
- To switch back to manual mode, move either of the sticks in any direction.
Loading

0 comments on commit 9dc9ed9

Please sign in to comment.