Giter Club home page Giter Club logo

ros2-docker's Introduction

ros2-docker

1. Overview

This project is unofficial project. You can develop ros2 application without native ros2 environment. This is support script for easily ros2 with docker development.

demo

2. Requirement

  • Docker
  • Operation system is macOS or Linux

3. Install

Do don't need install. only build docker image for ros2.

$git clone https://github.com/masato-ka/ros2-docker.git
$cd ros2-docker/app_build_container
$docker build -t <Own image name> .
$cd ../
$sudo chmod +x ros2-docker.sh
$export PATH=$PATH:$PWD/ros2-docker.sh

4. Usage

command overview

$ros-docker.sh [Options] <workspace> <command> [Command Options]

Options Description
-i [container image name] Set a custom Docker image to be used when executing the command.
-g Used to run ros2 run or launch with GUI.
-t [container image name] Set the name of the docker image to be created when rosdep is executed.
command Description
create create ros pkg.
build build ros pkg.
run run ros node.
launch launch ros launch file
bundle bundle ros package.
vcs run vcs
rosdep run rosdep
rviz run rviz
gazebo run gazebo

For example

$mkdir -p ros_ws/src
$git clone clone https://github.com/ros2/demos.git ./ros_ws/src
$cd ros_ws/src/demo && git checkout foxy
$cd ../../
$ros2-docker.sh -o ros2-sample-image:latest ros_ws rosdep install --from-paths src --ignore-src -r -y
$ros2-docker.sh -i ros2-sample-image ros_ws build
$ros2-docker.sh ros_ws launch dummy_robot_bringup dummy_robot_bringup.launch.py
## Other terminal
$ros2-docker.sh ros_ws rviz

## You can see rviz by VNC (localhost:5900).
$mkdir -p moveit_ws/src
$curl wget https://raw.githubusercontent.com/ros-planning/moveit2/main/moveit2.repos -o moveit_ws/.rosintall
$ros2-docker moveit_ws vcs
## Attention: You need all download directory move to src folder manually.

## rosdep subcommand create new docker image that is resolve dependencies for moveit. 
$ros2-docker -t moveit_depends_image moveit_ws rosdep install -r --from-paths . --ignore-src --rosdistro foxy -y

## Take many time for build.
## Attention: Builded pkg is not contain in docker image. Therefor if you need moveit for your own pkg, create new docker image manually.
$ros2-docker -i moveit_depends_image moveit_ws build --event-handlers desktop_notification- status- --cmake-args -DCMAKE_BUILD_TYPE=Release
 
## You 
$ros20docker -i moveit_depends_image -g ros2 launch run_moveit_cpp run_moveit_cpp.launch.py
## You can see rviz by VNC (localhost:5900).
  • Attention

If VNC show black screen you need change rviz setting. Please open file moveit_ws/install/run_moveit_cpp/share/run_moveit_cpp/launch/run_moveit_cpp.rviz with some editor. Then change to 0 Window Geometry X and Y.

Create ros2 package

Execute ros2 create commmand to workspace/src directory.

$mkdir -p workspace/src
$ros2-docker.sh workspace create <pkg_name> --build-type ament_cmake --node-name own_node

Build package

Execute ros2 build command to workspace.

$ros2-docker.sh workspace build

Run node

Execute ros2 run command to run your own node.

$ros2-docker.sh workspace run <pkg_name> <node_name>

If your own node need X display.

$ros2-docker -g workspace run <pkg_name> <node_name>

After connect localhost:5900 by VNC tool(macOS recommend Tiger VNC.)

Launch

Execute ros2 launch command to run your own launch file.

$ros2-docker.sh workspace launch <pkg_name> <launch file>

If you contain gui application in your launch file.

$ros2-docker.sh -g workspace launch <pkg_name> <node_name>

After connect localhost:5900 by VNC tool(macOS recommend Tiger VNC.)

Rviz

Execute the rviz command to run the rviz GUI, which will be drawn on a virtual buffer in X Window and served outside the container via VNC from port 5900.

$ros2-docker.sh workspace rviz

After connect localhost:5900 by VNC tool(macOS recommend Tiger VNC.)

Gazebo

Execute the gazebo command to run the gazebo GUI, which will be drawn on a virtual buffer in X Window and served outside the container via VNC from port 5900.

$ros2-docker.sh workspace gazebo

After connect localhost:5900 by VNC tool(macOS recommend Tiger VNC.)

vcs import

Run vcs import < .rosinstall under the specified workspace. The current version will only process .rosinstall files under the workspace.

.rosinstall if it exists directly under the workspace
$ros2-docker.sh workspace vcs

rosdep

Run the rosdep command under the workspace to resolve the dependency. Create a new Docker image containing the resolved dependencies with the name specified by -o.

$ros2-docker.sh -o <new docker image name> <workspacename> \
rosdep install -r --from-paths . --ignore-src --rosdistro foxy -y 

5. Release note

  • 2021/01/30 version 0.1.0 First release shell script version.

6. Contribution

If you find bug or want to new functions, please write issue.

If you fix your self, please fork and send pull request.

7. LICENSE

This software license under MIT licence.

8. Author

masato-ka

ros2-docker's People

Contributors

masato-ka avatar msinvent avatar

Stargazers

 avatar ¯\_(ツ)_/¯ avatar Marcelo Jacinto avatar Rémi Ratajczak avatar Song Jie avatar Jung, Hong-ryul avatar Yossi Ovcharik avatar  avatar

Watchers

James Cloos avatar  avatar

ros2-docker's Issues

cannot allocate memory error

Hi,
I am fairly new to docker containers in general so forgive my ignorance.

I tried the first example you provide. However, on trying to build the demo, i get the following error in my docker container.

Finished <<< demo_nodes_py [0.72s]
Starting >>> quality_of_service_demo_cpp
--- stderr: dummy_map_server
c++: fatal error: Killed signal terminated program cc1plus
compilation terminated.
make[2]: *** [CMakeFiles/dummy_map_server.dir/build.make:63: CMakeFiles/dummy_map_server.dir/src/dummy_map_server.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:78: CMakeFiles/dummy_map_server.dir/all] Error 2
make: *** [Makefile:141: all] Error 2
Failed <<< dummy_map_server [12.9s, exited with code 2]
Aborted <<< dummy_sensors [12.9s]
Aborted <<< demo_nodes_cpp_native [13.0s]
[14.747s] ERROR:colcon.colcon_core.event_reactor:Exception in event handler extension 'event_log': [Errno 12] Cannot allocate memory
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/colcon_core/event_reactor.py", line 78, in _notify_observers
retval = observer(event)
File "/usr/lib/python3/dist-packages/colcon_output/event_handler/event_log.py", line 50, in call
self._file_handle.flush()
OSError: [Errno 12] Cannot allocate memory

At the start of build I get the following warning:

Start build
WARNING: Your kernel does not support swap limit capabilities or the cgroup is not mounted. Memory limited without swap.

Any suggestion on how to solve this?

Thanks!

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.