Sign inSign up

dnewmon/ros2

By dnewmon

•Updated over 3 years ago

ros2, ros2-control, navigation2, rplidar

Image
0

545

dnewmon/ros2 repository overview

⁠ROS 2 Terminal Scripts

Create a project folder, and inside, create these scripts:

start-ros.sh: The purpose of this is to launch a ROS 2 container and bring up a terminal.

#!/bin/bash
docker run -ti --rm --name ros2 -v "$(pwd)/code/:/opt/code/" dnewmon/ros2:latest bash

ros.sh: The purpose of this script is to launch an additional ROS 2 terminal in the same Docker container.

#!/bin/bash
docker exec -ti --workdir "/opt/code/" ros2 bash

⁠Workspace Scripts

Within the $(pwd)/code/ path, create these additional scripts.

base-ros.sh: The purpose of this script is to source the base ROS 2 system (setup environment variables/paths/etc).

#!/bin/bash
source /opt/ros/${ROS_DISTRO}/setup.bash

ros.sh: The purpose of this script is to source the ROS 2 system + the current workspace (setup environment variables/paths/etc).

#!/bin/bash
source /opt/ros/${ROS_DISTRO}/setup.bash
source ./install/local_setup.bash

⁠Example Workflow:

  1. Open a terminal to your project folder.
  2. Execute ./start-ros.sh
  3. Execute source base-ros.sh
  4. Execute ros2 pkg create --build-type ament_cmake my_cbot
  5. Execute colcon build
  6. Execute source ros.sh
  7. Execute ros2 launch <project> <launch>

In another terminal:

  1. Open a terminal to your project folder.
  2. Execute ./ros.sh
  3. Execute source ros.sh
  4. Execute ros2 topic list

On the host machine, you and develop against the project files. Chances are you'll run into permissions issues with files created from within the Docker container. These two commands will allow access across the entire workspace for both container + host (or anybody else):

sudo chmod -R a+rxw .
sudo chown -R david:david .

Tag summary

Content type

Image

Digest

sha256:98d1a6a9c…

Size

889.5 MB

Last updated

over 3 years ago

docker pull dnewmon/ros2