Skip to content

Commit

Permalink
Merge pull request #3 from skim0119/patch-1
Browse files Browse the repository at this point in the history
Patch: Add README with more description of how to use
  • Loading branch information
hanson-hschang authored Aug 17, 2024
2 parents 9dca4a5 + c4b9d66 commit e2b09f0
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 8 deletions.
15 changes: 11 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,9 @@ RUN apt-get update && apt-get install -y \
vim \
&& rm -rf /var/lib/apt/lists/*

RUN echo "source /opt/ros/foxy/setup.bash" >> /root/.bashrc

# Clone the ros2-vicon-receiver package
ENV WS=/vicon_ws
ENV WS /vicon_ws
RUN mkdir -p $WS/src && \
cd $WS/src && \
git clone https://github.com/skim0119/ros2-vicon-receiver && \
Expand All @@ -30,7 +29,15 @@ RUN mkdir -p $WS/src && \
WORKDIR $WS
RUN source /opt/ros/foxy/setup.bash && \
colcon build --symlink-install
RUN echo "source /vicon_ws/install/setup.bash" >> /root/.bashrc

WORKDIR /
RUN source vicon_ws/install/setup.bash

RUN echo ". /opt/ros/foxy/setup.bash" >> /root/.bashrc
RUN echo ". /vicon_ws/install/setup.bash" >> /root/.bashrc

RUN sed -e '/[ -z "$PS1" ] && return/s/^/#/g' -i /root/.bashrc

# Set the entrypoint to use ROS 2
ENTRYPOINT ["/bin/bash", "-c", "ros2 launch vicon_receiver client.lanuch.py && exec \"$@\"", "--"]
ENTRYPOINT ["/bin/bash", "-c", "source ~/.bashrc && exec \"$@\"", "--"]
CMD ["bash"]
68 changes: 64 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[![Publish Docker Image to Docker Hub CI](https://github.com/hanson-hschang/ros2-vicon/actions/workflows/docker-image.yml/badge.svg?branch=main)](https://github.com/hanson-hschang/ros2-vicon/actions/workflows/docker-image.yml)

This repository contains a Dockerfile and associated scripts for creating a Docker image that combines ROS2 (Robot Operating System 2) with Vicon motion capture system integration.
This repository contains a Dockerfile and associated scripts for creating a Docker image that combines ROS2 (Robot Operating System 2) with Vicon motion capture system integration. The image includes this [ros2-node](https://github.com/OPT4SMART/ros2-vicon-receiver) to communicate with external Vicon system.

## Overview

Expand All @@ -20,9 +20,22 @@ This Docker image is designed to provide a pre-configured environment for roboti
- [Docker](https://www.docker.com/) installed on your system
- Git (for cloning this repository)

## Building the Docker Image
## Download the Docker Image

To build the Docker image:
### Method 1: Pull from Docker Hub

Docker image is built using `github-action`, and uploaded to [Docker Hub](https://hub.docker.com/r/hansonhschang/ros2-vicon).

```zsh
docker pull hansonhschang/ros2-vicon:latest
```

> The variable `<name>` in following sections will be `hansonhschang/ros2-vicon`.

### Method 2: Build locally from Dockrfile

To build the Docker image locally:

1. Clone this repostitory
```zsh
Expand All @@ -47,6 +60,7 @@ To build the Docker image:

1. To create and start a new container from the image, run the following command
```zsh
docker run -i -t --rm <name>
docker run -i -t --rm --entrypoint bash <name>
```
| flag&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; | value&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; | function |
Expand Down Expand Up @@ -98,6 +112,52 @@ To build the Docker image:
For GUI applications, you may need to set up X11 forwarding or use other methods to enable GUI support.

## How to use

You can run `ros2` commands as if you have `ros2` installed on local machine. Just prepend `docker run -it --rm <name> ros2`.

> To use your own script or folder outside of the container, you have to create the container without `--rm` flag, and copy the contents inside. Take a look [here](https://docs.docker.com/reference/cli/docker/container/cp/).
### Test Ros2: Talker and Listener

> The structure is similar to [this](https://docs.ros.org/en/foxy/How-To-Guides/Run-2-nodes-in-single-or-separate-docker-containers.html#run-two-nodes-in-two-separate-docker-containers).
Run the following ros2 nodes on each terminal:

```zsh
docker run -it --rm <name> ros2 run demo_nodes_cpp talker
docker run -it --rm <name> ros2 run demo_nodes_cpp listener
```

### Launch Vicon

> The default host ip is `192.168.1.12`.
```zsh
docker run -it --rm <name> ros2 launch vicon_receiver client.launch.py
```

To see the data, you can implement your own listener or use `ros2 topic echo <topic name>`.

#### Mock Vicon System

Mock system can be launched when Vicon system is not available.

```zsh
docker run -it --rm <name> ros2 launch vicon_receiver mock_client.launch.py
```

#### Ros2 Tips

More commands are available in official ROS2 documentation. Here, I'm providing few that will be useful
to debug the `docker` container.

```zsh
docker run -it --rm <name> ros2 pkg list # list all available ros2 packages
docker run -it --rm <name> ros2 topic list # list all available ros2 topics
docker run -it --rm <name> ros2 topic echo <topic name> # listen a topic data
```

## CI/CD

This repository uses GitHub Actions for continuous integration and delivery. On each pull request to the main branch, the workflow will:
Expand All @@ -109,4 +169,4 @@ The workflow can also be manually triggered from the GitHub Actions tab.

## Contributing

Contributions to improve this Docker image are welcome. Please submit issues and pull requests on this GitHub repository.
Contributions to improve this Docker image are welcome. Please submit issues and pull requests on this GitHub repository.

0 comments on commit e2b09f0

Please sign in to comment.