Code Monkey home page Code Monkey logo

ros-docker-intro's Introduction

An Introduction On using ROS/Docker

Basic Requirement

Any machine with Docker installed. Learn more about Docker and container here.

Setup ROS in Docker (demo video)

Open a Terminal/Powershell

For x64 machine, run make init will download and initalize the container with ROS Foxy/Noetic.

If you don't have make, just copy and run line 6 in the Makefile.

For arm64 machine, run make init-arm.

A CLI to the container will be granted after this step.

For GUI access, use your broswer to visit this page with [password].

Other operations on the container can be found in the Makefile.

Play a ROS1 Bag File (demo video)

  1. Download a bag file from here and move it to the shared folder rootfs/. Learn more about ROS bag here.

  2. In the container CLI

    • run source /root/rootfs/foxy_setup.sh to initiate ROS 2 environment
    • run rviz2 & to start RViz
    • run ros2 bag play -r 10 -s rosbag_v2 --loop rootfs/16-mcity1.bag to play the downloaded bag file
  3. In the container GUI

    • open config file demo-ROS2.rviz in folder /root/rootfs/ from RViz, it should show the images and point clouds now

Try Some ROS2 Nodes

  1. Image ROS Node (view code | demo video)

    In the container GUI, open mutiple terminals

    • run source /root/rootfs/foxy_setup.sh; ros2 bag play -r 10 -s rosbag_v2 --loop rootfs/16-mcity1.bag in terminal 1
    • run source /root/rootfs/foxy_setup.sh; (ros2 run rqt_image_view rqt_image_view &); python3 /root/rootfs/image_subscriber-ros2.py in terminal 2
    • select image topic /front_camera/image_raw and /img_gray to see the original image and the gray image produced by the ROS node.
  2. PointCloud ROS Node (view code | demo video)

    In the container GUI,

    • run apt install -y python3-pcl ros-foxy-sensor-msgs-py; python3 /root/rootfs/point_cloud_subscriber-ros2.py in terminal 2
    • pointcloud file will be exported to shared folder rootfs/ by the ROS node

    In the host machine, use CouldCompare or Matlab to view the exported pointcloud file

  3. GPS ROS Node (view code)

    In the container GUI,

    • run pip install utm; python3 /root/rootfs/gps_subscriber-ros2.py in terminal 2
    • the ROS node will print the gps coordinates

Create Your ROS Package and Docker Image (ROS1 | ROS2 | Docker Cheat Sheets)

  1. Create a workspace with mkdir -p /root/rootfs/demo_workspace/src and initialize it following the tutorials [ROS 1, ROS 2]

  2. Follow the rest of tutorials to create your ROS package and ROS node [ROS 1, ROS 2]

  3. Add the dependencies of your package to Dockerfile.template and build your image with docker build -f Dockerfile.template --tag=IMAGE_NAME

Trouble shoot

  1. No topic showes up in rqt_image_view
    • Try to run ros2 topic list before running rqt_image_view
  2. Docker does not work on my computer
    • You can use a VM/WSL as an alternative, follow the setup in the Dockerfile (install fresh Ubuntu 20.04 and all the dependencies)
  3. make init or line 6 in the Makefile does not work
    • Replace `pwd` with the absolute path of this tutorial folder
  4. ros2: command not found or No module named 'rclpy'
    • run source /root/rootfs/foxy_setup.sh in your terminal and try again
  5. Get Aborted (core dumped) when running rviz2
    • Restart your docker (exit container then make start) and try again, DO NOT source noetic_setup.sh after sourcing foxy_setup.sh
  6. How to skip the source /root/rootfs/foxy_setup.sh step
    • Add source /root/rootfs/foxy_setup.sh to the end of /root/.bashrc, restart the terminal
  7. Copy and paste to/from noVNC is annoying
    • Add -localhost no the end of the second line in /root/startVNC.sh, restart docker and use ifconfig to show DOCKER_IP, then connect to DOCKER_IP:5901 with an VNC client (CAUTION! This will expose your docker VNC to public IP instead of localhost)

ros-docker-intro's People

Contributors

i0x0i avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.