-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDockerfile.manipulation.hardware
63 lines (56 loc) · 2.88 KB
/
Dockerfile.manipulation.hardware
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
ARG ROS_DISTRO=humble
FROM husarion/rosbot-xl:$ROS_DISTRO
WORKDIR /ros2_ws
COPY ./healthcheck_manipulation.cpp /
# install everything needed
RUN apt-get update && apt-get install -y \
python3-pip \
ros-dev-tools && \
rm -rf /ros2_ws/* && \
# build & install ROSbot XL packages
source "/opt/ros/$ROS_DISTRO/setup.bash" && \
git clone https://github.com/husarion/rosbot_xl_manipulation_ros.git src/rosbot_xl_manipulation_ros && \
vcs import src < src/rosbot_xl_manipulation_ros/rosbot_xl_manipulation/rosbot_xl_manipulation.repos && \
vcs import src < src/rosbot_xl_ros/rosbot_xl/rosbot_xl_hardware.repos && \
vcs import src < src/open_manipulator_x/open_manipulator_x.repos && \
# it is necessary to remove simulation - otherwise rosdep tries to install dependencies
rm -r src/rosbot_xl_ros/rosbot_xl_gazebo && \
rm -r src/rosbot_xl_manipulation_ros/rosbot_xl_manipulation_gazebo && \
cp -r src/ros2_controllers/diff_drive_controller src && \
cp -r src/ros2_controllers/imu_sensor_broadcaster src && \
rm -rf src/ros2_controllers && \
rm -rf /etc/ros/rosdep/sources.list.d/20-default.list && \
rosdep init && \
rosdep update --rosdistro $ROS_DISTRO && \
rosdep install -i --from-path src --rosdistro $ROS_DISTRO -y && \
# Create healthcheck package
cd src/ && \
ros2 pkg create healthcheck_pkg --build-type ament_cmake --dependencies rclcpp control_msgs nav_msgs && \
sed -i '/find_package(nav_msgs REQUIRED)/a \
add_executable(healthcheck_node src/healthcheck_manipulation.cpp)\n \
ament_target_dependencies(healthcheck_node rclcpp control_msgs nav_msgs)\n \
install(TARGETS healthcheck_node DESTINATION lib/${PROJECT_NAME})' \
/ros2_ws/src/healthcheck_pkg/CMakeLists.txt && \
mv /healthcheck_manipulation.cpp /ros2_ws/src/healthcheck_pkg/src/ && \
cd .. && \
# Build
colcon build --symlink-install --cmake-args -DCMAKE_BUILD_TYPE=Release && \
# Save version
echo $(cat /ros2_ws/src/rosbot_xl_manipulation_ros/rosbot_xl_manipulation/package.xml | grep '<version>' | sed -r 's/.*<version>([0-9]+.[0-9]+.[0-9]+)<\/version>/\1/g') > /version.txt && \
# Size optimalization
export SUDO_FORCE_REMOVE=yes && \
apt-get remove -y \
python3-pip \
ros-dev-tools && \
apt-get autoremove -y && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
# Run healthcheck in background
RUN entrypoint_file=$(if [ -f "/ros_entrypoint.sh" ]; then echo "/ros_entrypoint.sh"; else echo "/vulcanexus_entrypoint.sh"; fi) && \
sed -i '/test -f "\/ros2_ws\/install\/setup.bash" && source "\/ros2_ws\/install\/setup.bash"/a \
ros2 run healthcheck_pkg healthcheck_node &' \
$entrypoint_file
COPY ./healthcheck.sh /
HEALTHCHECK --interval=2s --timeout=1s --start-period=30s --retries=1 \
CMD ["/healthcheck.sh"]
STOPSIGNAL SIGINT