junekimdev / xycar-ros-docker

Containerized Xycar-ROS for Programmers Autonomous Drive Dev Course (K-Digital Training)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Xycar-ROS in Docker

Containerized Xycar-ROS for Programmers Autonomous Drive Dev Course

school logo

Table of Contents

  1. Prerequisites
  2. How to Build
  3. How to Use
  4. How to Stop
  5. Authors
  6. License

Prerequisites

  1. You need docker-engine installed in your machine
  2. You need docker-compose installed in your machine

refer: https://docs.docker.com/engine/install/

If you installed docker-desktop, which includes both packages, you are good to go!


How to Build

In order to run Xycar-ROS, you need to build docker image first.

1. Move to your workspace πŸ“‚

example:

cd ~/kdt_practice

2. Modify Makefile πŸ–ŠοΈ

Change these values in Makefile as you wish:

  • DOCKER_NAME (name for your docker image)
  • DOCKER_TAG
  • NETWORK_NAME
  • ROS_MASTER_URI
  • ROS_HOSTNAME

3. Modify Dockerfile πŸ–ŠοΈ

Choose ENTRYPOINT for master or slave

This might be changed in the future so that the container can choose its running mode according to the environmental variable

4. Build 🚧

make build

This will take a couple of minutes; get some coffee β˜•

At the end, if successful make will ask your password to change ownership of ./xycar_ws/.

5. Aftermath πŸ‘

βœ… During the build, an empty directory (./xycar_ws/) will be created.

./xycar_ws/ will remain empty until you starts a container from the image.

βœ… Make sure image has been created

docker image ls

The image size on my machine is 1.13GB

βœ… Clean up dangling images

make clean

😸 Build is done


How to Use

1. Modify docker-compose.yml πŸ–ŠοΈ

  • image: image name in Makefile
  • networks: network name in Makefile
    • make sure you modify all of network names (hint: 2 places)

2. Start a container by docker-compose 🐳

make
# or
make up

⚠️ This step will populate ./xycar_ws/ automatically by catkin_make inside

If you want to start multiple containers, modify docker-compose.yml accordingly.

By starting multiple containers, you can emulate multiple machines connected to one network. You can practice for remote environment in this way.

Also, you can start a container with a specific command like roslaunch by option command.

3. Open Terminals πŸ’»

If you want to start a master by roscore or want to create ROS packages, or whatever, open interactive terminal for the live docker container which you started in step 2.

docker exec -it {image_name} /bin/bash

4. Use ./xycar_ws/ πŸ‘·

This directory is a bind-mounting volume for your container. You can put any files in this directory and can use it in your container like a virtual machine.

If you have access problem, change the permission of this directory.

make claim

You need to be able to use sudo to do this.

How to Stop

Stop the Container πŸ›‘

If you are done with the container, you can stop it.

make down
  • This will not remove docker-network.
  • This will not remove any works done in ./xycar_ws/.

Next time you start a container, you can continue from where you left off.

Authors

License

This project is licensed under the MIT License

see the LICENSE file for details

About

Containerized Xycar-ROS for Programmers Autonomous Drive Dev Course (K-Digital Training)

License:MIT License


Languages

Language:Dockerfile 62.1%Language:Makefile 37.9%