added dockerfile and docker compose

This commit is contained in:
2026-02-10 13:11:58 +01:00
parent 1a25dcb977
commit fb103aaa99
8 changed files with 217 additions and 4 deletions

43
Dockerfile Normal file
View File

@@ -0,0 +1,43 @@
FROM ros:jazzy-ros-base
ENV DEBIAN_FRONTEND=noninteractive
# ---------- System dependencies ----------
RUN apt-get update && apt-get install -y \
python3-colcon-common-extensions \
python3-rosdep \
build-essential \
udev \
git
# ---------- Initialize rosdep ----------
RUN rosdep init || true
RUN rosdep update
# ---------- Workspace ----------
WORKDIR /ros_ws
# ---------- Copy package.xml files ----------
COPY toid_bot_description/package.xml toid_bot_description/package.xml
COPY toid_control/package.xml toid_control/package.xml
COPY toid_msgs/package.xml toid_msgs/package.xml
COPY toid_odometry/package.xml toid_odometry/package.xml
COPY toid_spinner_controller/package.xml toid_spinner_controller/package.xml
#COPY toid_navigation/package.xml toid_navigation/package.xml
# ---------- Install dependencies ----------
RUN . /opt/ros/jazzy/setup.sh && \
rosdep install --from-paths ./ --ignore-src -r -y \
&& rm -rf /var/lib/apt/lists/*
RUN rm -rf ./*
RUN cat <<EOF >> /root/.bashrc
source /opt/ros/jazzy/setup.bash
if [[-f ./install/setup.bash ]]
source ./install/setup.bash
if
EOF
CMD ["sleep", "infinity"]

15
docker-compose.yaml Normal file
View File

@@ -0,0 +1,15 @@
services:
toid:
image: toid
container_name: toid
privileged: true
network_mode: host
volumes:
- ./:/ros_ws/src
entrypoint: ["sleep","infinity"]
profiles:
- base

54
scripts/docker_build.sh Executable file
View File

@@ -0,0 +1,54 @@
#!/bin/bash
usage() {
cat <<EOF
Usage:
docker_build.sh <target> <registry> [<args>]
docker_build.sh -h
Build and push a docker image to a arm64v8 registry
Targets:
base The pacakges aimed at running on the raspberry pi
EOF
}
TARGET="$1"
REGISTRY="$2"
ARGS="$2"
if [[ $TARGET == "-h" || $TARGET == "--help" ]]; then
usage
exit 0
fi
if [[ $# -lt 2 ]]; then
echo "Error: Expected at least 2 arguments."
usage
exit 1
fi
trap "trap - SIGTERM && kill -- -$$" SIGINT SIGTERM EXIT
case $TARGET in
"base")
ssh -N \
-o StrictHostKeyChecking=no \
-o UserKnownHostsFile=/dev/null \
-L 0.0.0.0:5000:localhost:5000 \
$REGISTRY &
echo "Building target: base"
sudo docker buildx build \
--platform linux/arm64 \
-t localhost:5000/toid:latest \
-f Dockerfile \
--output type=registry \
.
;;
*)
echo "Target not defined"
exit 1
;;
esac

View File

@@ -0,0 +1,63 @@
cmake_minimum_required(VERSION 3.8)
project(toid_control)
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra -Wpedantic)
endif()
set(library_name toid_control)
set(PACKAGE_DEPS
rclcpp
pluginlib
hardware_interface
rclcpp_lifecycle
rclcpp_components
)
# find dependencies
find_package(ament_cmake REQUIRED)
foreach(PACKAGE ${PACKAGE_DEPS})
find_package(${PACKAGE} REQUIRED)
endforeach()
add_library(
${library_name}
SHARED
src/toid_control.cpp
)
target_include_directories(
${library_name}
PRIVATE
include
)
ament_target_dependencies(${library_name}
${PACKAGE_DEPS}
)
pluginlib_export_plugin_description_file(hardware_interface toid_control_interfaces.xml)
install(
TARGETS ${library_name}
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin
)
install(
DIRECTORY
launch
params
rviz
DESTINATION share/${PROJECT_NAME}/
)
ament_export_include_directories(include)
ament_export_libraries(${library_name})
ament_export_dependencies(${PACKAGE_DEPS})
ament_package()

View File

@@ -0,0 +1,35 @@
<?xml version="1.0"?>
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="3">
<name>toid_control</name>
<version>0.0.1</version>
<description>Ros2 control compatible drivers for magrob</description>
<maintainer email="82343504+Pimpest@users.noreply.github.com">Pimpest</maintainer>
<license>Apache-2.0</license>
<buildtool_depend>ament_cmake</buildtool_depend>
<depend>ros2launch</depend>
<depend>rclcpp</depend>
<depend>rclcpp_lifecycle</depend>
<depend>rclcpp_components</depend>
<depend>pluginlib </depend>
<depend>ros2_control</depend>
<depend>hardware_interface</depend>
<depend>controller_manager</depend>
<depend>diff_drive_controller</depend>
<depend>robot_state_publisher</depend>
<depend>joint_state_broadcaster</depend>
<depend>boost</depend>
<test_depend>ament_lint_auto</test_depend>
<test_depend>ament_lint_common</test_depend>
<export>
<build_type>ament_cmake</build_type>
</export>
</package>

View File

@@ -0,0 +1,7 @@
<library path="toid_behaviors">
<class
name="toid_behaviors/MoveAhead"
type="toid::MoveAheadBehavior"
base_class_type="nav2_core::Behavior"
/>
</library>

View File

@@ -10,9 +10,7 @@
<buildtool_depend>ament_cmake</buildtool_depend>
<exec_depend>joint_state_publisher</exec_depend>
<exec_depend>joint_state_publisher_gui</exec_depend>
<exec_depend>robot_state_publisher</exec_depend>
<exec_depend>rviz2</exec_depend>
<exec_depend>xacro</exec_depend>
<test_depend>ament_lint_auto</test_depend>

View File

@@ -8,7 +8,6 @@
<license>MIT</license>
<buildtool_depend>ament_cmake</buildtool_depend>
<depend>navigation2</depend>
<depend>robot_state_publisher</depend>
<depend>nav2_behaviors</depend>
<depend>nav2_planner</depend>
@@ -17,7 +16,6 @@
<depend>nav2_lifecycle_manager</depend>
<depend>nav2_bringup</depend>
<depend>ros2_control</depend>
<depend>rviz2</depend>
<depend>rsl</depend>
<test_depend>ament_lint_auto</test_depend>