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