From 97ebee985c741287d395730a34c689834e9a8ad8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Ellensohn?= Date: Wed, 26 Jul 2023 13:02:21 +0200 Subject: [PATCH] started changes for rmp: need to finish --- controller_startup.sh | 29 +++++++ dependencies.repos | 13 ++++ docker-compose.yaml | 166 ++++++++++++++++++++++++++++++++++++++++ docker/Dockerfile | 59 ++++++++++++++ docker/entrypoint.sh | 25 ++++++ localization_startup.sh | 28 +++++++ overlay.repos | 26 +++++++ 7 files changed, 346 insertions(+) create mode 100644 controller_startup.sh create mode 100644 dependencies.repos create mode 100644 docker-compose.yaml create mode 100644 docker/Dockerfile create mode 100644 docker/entrypoint.sh create mode 100644 localization_startup.sh create mode 100644 overlay.repos diff --git a/controller_startup.sh b/controller_startup.sh new file mode 100644 index 0000000..abc593c --- /dev/null +++ b/controller_startup.sh @@ -0,0 +1,29 @@ +#!/bin/bash +# Basic entrypoint for ROS / Colcon Docker containers + +# Source ROS 2 +source /opt/ros/${ROS_DISTRO}/setup.bash +echo "Sourced ROS 2 ${ROS_DISTRO}" + +# Source the base workspace, if built +if [ -f ${UNDERLAY_WS}/install/setup.bash ] +then + source ${UNDERLAY_WS}/install/setup.bash + #export GAZEBO_MODEL_PATH=$GAZEBO_MODEL_PATH:$(ros2 pkg prefix turtlebot3_gazebo)/share/turtlebot3_gazebo/models + echo "Sourced Bot Mini base workspace" +fi + +# Source the overlay workspace, if built +if [ -f /overlay_ws/install/setup.bash ] +then + source /overlay_ws/install/setup.bash + #export GAZEBO_MODEL_PATH=$GAZEBO_MODEL_PATH:$(ros2 pkg prefix tb3_worlds)/share/tb3_worlds/models + echo "Sourced Bot Mini overlay workspace" +fi + +# Start Robot ROS2 Nodes +ros2 launch bot_mini_bringup robot_controller.launch.py priority:=80 cpu-affinity:=4 lock-memory-size:=100 config-child-threads:=True & +ros2 launch bot_mini_bringup robot_twist_mux.launch.py & +ros2 launch bot_mini_bringup robot_joy_teleop.launch.py + +wait \ No newline at end of file diff --git a/dependencies.repos b/dependencies.repos new file mode 100644 index 0000000..2e412e1 --- /dev/null +++ b/dependencies.repos @@ -0,0 +1,13 @@ +repositories: + + # CPS Bot Mini Dependencies + + odrive_ros2_control: + type: git + url: https://github.com/bjoernellens1/odrive_ros2_control.git + version: humble-fw-v0.5.1 + + Lslidar_ROS2: + type: git + url: https://github.com/bjoernellens1/Lslidar_ROS2_driver + version: N10_V1.0 \ No newline at end of file diff --git a/docker-compose.yaml b/docker-compose.yaml new file mode 100644 index 0000000..20a2328 --- /dev/null +++ b/docker-compose.yaml @@ -0,0 +1,166 @@ +version: "3.9" +services: + # Base image containing dependencies. + base: + image: ghcr.io/bjoernellens1/ros2_rmp/rmp:base + build: + context: . + dockerfile: docker/Dockerfile_arm64 + args: + ROS_DISTRO: humble + target: base + # Interactive shell + stdin_open: true + tty: true + # Networking and IPC for ROS 2 + network_mode: host + ipc: host + # Needed to display graphical applications + privileged: true + environment: + # Allows graphical programs in the container. + - DISPLAY=${DISPLAY} + - QT_X11_NO_MITSHM=1 + - NVIDIA_DRIVER_CAPABILITIES=all + volumes: + # Allows graphical programs in the container. + - /tmp/.X11-unix:/tmp/.X11-unix:rw + - ${XAUTHORITY:-$HOME/.Xauthority}:/root/.Xauthority + + # Overlay image containing the example source code. + overlay: + extends: base + image: ghcr.io/bjoernellens1/ros2_rmp/rmp:overlay + build: + context: . + dockerfile: docker/Dockerfile_arm64 + target: overlay + + + # Robot State Publisher + robot_state_publisher: + extends: overlay + command: > + ros2 launch rmp_bringup rsp.launch.py + stdin_open: true + tty: true + # Networking and IPC for ROS 2 + network_mode: host + ipc: host + + # Controller and teleop + controller: + extends: overlay + command: > + /controller_startup.sh + devices: + - /dev/ttyUSB0:/dev/ttyUSB0 + - /dev/ttyACM0:/dev/ttyACM0 + - /dev/input/js0:/dev/input/js0 + # Interactive shell + stdin_open: true + tty: true + # Networking and IPC for ROS 2 + network_mode: host + ipc: host + # Needed to display graphical applications + privileged: true + depends_on: + - robot_state_publisher + + # MicroRos Agent + microros_agent: + image: microros/micro-ros-agent:humble + command: > + serial --dev /dev/ttyUSB1 -v6 + devices: + - /dev/ttyUSB1:/dev/ttyUSB1 + # Interactive shell + stdin_open: true + tty: true + # Networking and IPC for ROS 2 + network_mode: host + ipc: host + # Needed to display graphical applications + privileged: true + + # sensors + sensors: + extends: overlay + command: > + ros2 launch bot_mini_bringup robot_lidar.launch.py + stdin_open: true + tty: true + # Networking and IPC for ROS 2 + network_mode: host + ipc: host + depends_on: + - robot_state_publisher + + # Localization + localization: + extends: overlay + command: > + ros2 launch bot_mini_bringup robot_localization.launch.py + devices: + - /dev/ttyUSB0:/dev/ttyUSB0 + - /dev/ttyUSB1:/dev/ttyUSB1 + - /dev/ttyACM0:/dev/ttyACM0 + - /dev/input/js0:/dev/input/js0 + # Interactive shell + stdin_open: true + tty: true + # Networking and IPC for ROS 2 + network_mode: host + ipc: host + # Needed to display graphical applications + privileged: true + depends_on: + - controller + - microros_agent + + # mapping + mapping: + extends: overlay + command: > + ros2 launch bot_mini_bringup robot_mapper.launch.py + # Interactive shell + stdin_open: true + tty: true + # Networking and IPC for ROS 2 + network_mode: host + ipc: host + depends_on: + - localization + + # navigation + navigation: + extends: overlay + command: > + ros2 launch bot_mini_bringup robot_navigation.launch.py + map_subscribe_transient_local:=true + stdin_open: true + tty: true + # Networking and IPC for ROS 2 + network_mode: host + ipc: host + depends_on: + - localization + + # # Behavior demo using Python and py_trees + # demo-behavior-py: + # extends: overlay + # command: > + # ros2 launch tb3_autonomy tb3_demo_behavior_py.launch.py + # tree_type:=${BT_TYPE:?} + # enable_vision:=${ENABLE_VISION:?} + # target_color:=${TARGET_COLOR:?} + + # # Behavior demo using C++ and BehaviorTree.CPP + # demo-behavior-cpp: + # extends: overlay + # command: > + # ros2 launch tb3_autonomy tb3_demo_behavior_cpp.launch.py + # tree_type:=${BT_TYPE:?} + # enable_vision:=${ENABLE_VISION:?} + # target_color:=${TARGET_COLOR:?} diff --git a/docker/Dockerfile b/docker/Dockerfile new file mode 100644 index 0000000..a1d61d3 --- /dev/null +++ b/docker/Dockerfile @@ -0,0 +1,59 @@ +ARG ROS_DISTRO=humble +ARG UNDERLAY_WS=/bot_mini_ws + +######################################## +# Base Image for Bot Mini Control # +######################################## +FROM osrf/ros:${ROS_DISTRO}-desktop as base +ENV ROS_DISTRO=${ROS_DISTRO} +SHELL ["/bin/bash", "-c"] + +# Create Colcon workspace with external dependencies +RUN mkdir -p /bot_mini_ws/src +WORKDIR /bot_mini_ws/src +COPY dependencies.repos . +RUN vcs import < dependencies.repos + +# Build the base Colcon workspace, installing dependencies first. +WORKDIR /bot_mini_ws +RUN source /opt/ros/${ROS_DISTRO}/setup.bash \ + && apt-get update -y \ + && rosdep install --from-paths src --ignore-src --rosdistro ${ROS_DISTRO} -y \ + && colcon build --symlink-install + +# Use Cyclone DDS as middleware +RUN apt-get update && apt-get install -y --no-install-recommends \ + ros-${ROS_DISTRO}-rmw-cyclonedds-cpp +ENV RMW_IMPLEMENTATION=rmw_cyclonedds_cpp + +ENV UNDERLAY_WS=${UNDERLAY_WS} + +########################################### +# Overlay Image for Bot Mini Control # +########################################### +FROM base AS overlay + +# Create an overlay Colcon workspace +RUN mkdir -p /overlay_ws/src +WORKDIR /overlay_ws/src +COPY overlay.repos . +RUN vcs import < overlay.repos + +WORKDIR /overlay_ws +# COPY ./tb3_autonomy/ ./src/tb3_autonomy/ +# COPY ./tb3_worlds/ ./src/tb3_worlds/ +RUN source /bot_mini_ws/install/setup.bash \ + && colcon build --symlink-install \ + && rosdep install --from-paths src --ignore-src --rosdistro ${ROS_DISTRO} -y + +# Set up the entrypoint +COPY ./docker/entrypoint.sh / +RUN chmod +x /entrypoint.sh + +COPY ./controller_startup.sh / +RUN chmod +x /controller_startup.sh + +COPY ./localization_startup.sh / +RUN chmod +x /localization_startup.sh + +ENTRYPOINT [ "/entrypoint.sh" ] \ No newline at end of file diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh new file mode 100644 index 0000000..14fbec7 --- /dev/null +++ b/docker/entrypoint.sh @@ -0,0 +1,25 @@ +#!/bin/bash +# Basic entrypoint for ROS / Colcon Docker containers + +# Source ROS 2 +source /opt/ros/${ROS_DISTRO}/setup.bash +echo "Sourced ROS 2 ${ROS_DISTRO}" + +# Source the base workspace, if built +if [ -f ${UNDERLAY_WS}/install/setup.bash ] +then + source ${UNDERLAY_WS}/install/setup.bash + #export GAZEBO_MODEL_PATH=$GAZEBO_MODEL_PATH:$(ros2 pkg prefix turtlebot3_gazebo)/share/turtlebot3_gazebo/models + echo "Sourced Bot Mini base workspace" +fi + +# Source the overlay workspace, if built +if [ -f /overlay_ws/install/setup.bash ] +then + source /overlay_ws/install/setup.bash + #export GAZEBO_MODEL_PATH=$GAZEBO_MODEL_PATH:$(ros2 pkg prefix tb3_worlds)/share/tb3_worlds/models + echo "Sourced Bot Mini overlay workspace" +fi + +# Execute the command passed into this entrypoint +exec "$@" \ No newline at end of file diff --git a/localization_startup.sh b/localization_startup.sh new file mode 100644 index 0000000..5f6475a --- /dev/null +++ b/localization_startup.sh @@ -0,0 +1,28 @@ +#!/bin/bash +# Basic entrypoint for ROS / Colcon Docker containers + +# Source ROS 2 +source /opt/ros/${ROS_DISTRO}/setup.bash +echo "Sourced ROS 2 ${ROS_DISTRO}" + +# Source the base workspace, if built +if [ -f ${UNDERLAY_WS}/install/setup.bash ] +then + source ${UNDERLAY_WS}/install/setup.bash + #export GAZEBO_MODEL_PATH=$GAZEBO_MODEL_PATH:$(ros2 pkg prefix turtlebot3_gazebo)/share/turtlebot3_gazebo/models + echo "Sourced Bot Mini base workspace" +fi + +# Source the overlay workspace, if built +if [ -f /overlay_ws/install/setup.bash ] +then + source /overlay_ws/install/setup.bash + #export GAZEBO_MODEL_PATH=$GAZEBO_MODEL_PATH:$(ros2 pkg prefix tb3_worlds)/share/tb3_worlds/models + echo "Sourced Bot Mini overlay workspace" +fi + +# Start Robot ROS2 Nodes +ros2 launch bot_mini_bringup robot_lidar.launch.py & +ros2 launch bot_mini_bringup robot_localization.launch.py + +wait \ No newline at end of file diff --git a/overlay.repos b/overlay.repos new file mode 100644 index 0000000..6366047 --- /dev/null +++ b/overlay.repos @@ -0,0 +1,26 @@ +repositories: + + cps_rmp220_support: + type: git + url: https://github.com/bjoernellens1/cps_rmp220_support.git + version: main + + rmp220_teleop: + type: git + url: https://github.com/bjoernellens1/rmp220_teleop.git + version: main + + cam_openCV: + type: git + url: https://github.com/bjoernellens1/ros2_cam_openCV.git + version: main + + segwayrmp: + type: git + url: https://github.com/bjoernellens1/segwayrmp.git + version: humble-arm64 + + segway_msgs: + type: git + url: https://github.com/bjoernellens1/segway_msgs.git + version: main \ No newline at end of file