forked from husarion/rosbot-docker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile.hardware
130 lines (105 loc) · 4.31 KB
/
Dockerfile.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
ARG ROS_DISTRO=melodic
## ============================ STM32FLASH =================================
# stm32flash needs an older version of glibc (2.28), which is why ubuntu 18.04 was used
FROM ubuntu:18.04 AS stm32flash_builder
# official releases are only for intel archs, so we need to build stm32flash from sources
RUN apt-get update && apt-get install -y \
git \
build-essential && \
git clone https://github.com/stm32duino/stm32flash.git && \
cd stm32flash/ && \
make all
## =========================== STM32 firmware===============================
# FROM --platform=linux/amd64 ubuntu:18.04 as stm32_firmware_builder
# TODO: wget from releases instead
FROM --platform=linux/amd64 ubuntu:20.04 AS stm32_firmware_builder
ARG ROSBOT_FW_RELEASE=0.16.1
ARG ROS_NOETIC_MSGS=0
SHELL ["/bin/bash", "-c"]
# ENV PIO_VERSION="5.1.0"
RUN apt update && apt install -y \
python3 \
python3-pip \
git \
wget \
tree
# https://docs.platformio.org/en/latest/core/installation.html#system-requirements
# RUN pip3 install -U platformio==${PIO_VERSION}
RUN pip3 install -U platformio
RUN git clone https://github.com/husarion/rosbot-stm32-firmware.git --branch ${ROSBOT_FW_RELEASE} && \
mkdir -p ~/.platformio/packages/framework-mbed/features/ && \
cp rosbot-stm32-firmware/.mbedignore ~/.platformio/packages/framework-mbed/features/.mbedignore
WORKDIR /rosbot-stm32-firmware
RUN git submodule update --init --recursive
# RUN wget https://github.com/husarion/rosbot-stm32-firmware/archive/refs/tags/${ROSBOT_FW_RELEASE}.tar.gz && \
# tar -xf *.tar.gz && \
# mv rosbot-stm32-firmware* rosbot-stm32-firmware && \
# mkdir -p ~/.platformio/packages/framework-mbed/features/ && \
# cp rosbot-stm32-firmware/.mbedignore ~/.platformio/packages/framework-mbed/features/.mbedignore
WORKDIR /rosbot-stm32-firmware
RUN export LC_ALL=C.UTF-8 && \
export LANG=C.UTF-8 && \
pio project init -e core2_diff -O \
"build_flags= \
-I\$PROJECTSRC_DIR/TARGET_CORE2 \
-DPIO_FRAMEWORK_MBED_RTOS_PRESENT \
-DPIO_FRAMEWORK_EVENT_QUEUE_PRESENT \
-DMBED_BUILD_PROFILE_RELEASE \
-DJOINT_STATES_ENABLE=1 \
-DROS_NOETIC_MSGS=${ROS_NOETIC_MSGS} \
-DKINEMATIC_TYPE=0" && \
pio project init -e core2_mec -O \
"build_flags= \
-I\$PROJECTSRC_DIR/TARGET_CORE2 \
-DPIO_FRAMEWORK_MBED_RTOS_PRESENT \
-DPIO_FRAMEWORK_EVENT_QUEUE_PRESENT \
-DMBED_BUILD_PROFILE_RELEASE \
-DJOINT_STATES_ENABLE=1 \
-DROS_NOETIC_MSGS=${ROS_NOETIC_MSGS} \
-DKINEMATIC_TYPE=1" && \
pio run
## =========================== ROS image ===============================
FROM ros:$ROS_DISTRO-ros-core
SHELL ["/bin/bash", "-c"]
RUN apt update && apt install -y \
git \
python3-pip \
ros-$ROS_DISTRO-rosserial-python \
ros-$ROS_DISTRO-rosserial-server \
ros-$ROS_DISTRO-rosserial-client \
ros-$ROS_DISTRO-rosserial-msgs \
ros-$ROS_DISTRO-move-base-msgs \
ros-$ROS_DISTRO-robot-localization \
ros-$ROS_DISTRO-xacro \
ros-$ROS_DISTRO-transmission-interface \
ros-$ROS_DISTRO-controller-manager \
ros-$ROS_DISTRO-robot-state-publisher && \
pip3 install python-periphery && \
pip3 install sh && \
pip3 install pyserial && \
python3 -m pip install --upgrade pyserial && \
# clear ubuntu packages
apt clean && \
rm -rf /var/lib/apt/lists/*
WORKDIR /ros_ws
# clone robot github repositories
RUN mkdir -p src && \
git clone https://github.com/husarion/rosbot_ros.git --branch=melodic src/rosbot_ros && \
git clone https://github.com/husarion/rosbot_ekf.git --branch=master src/rosbot_ekf
# build ROS workspace
RUN source /opt/ros/$ROS_DISTRO/setup.bash && \
catkin_make -DCATKIN_ENABLE_TESTING=0 -DCMAKE_BUILD_TYPE=Release
# copy firmware built in previous stage
COPY --from=stm32_firmware_builder /rosbot-stm32-firmware/.pio/build/core2_diff/firmware.bin /root/firmware_diff.bin
COPY --from=stm32_firmware_builder /rosbot-stm32-firmware/.pio/build/core2_mec/firmware.bin /root/firmware_mecanum.bin
COPY --from=stm32flash_builder /stm32flash/stm32flash /usr/bin/stm32flash
# copy scripts
COPY ./flash-firmware.py /
COPY ./ros_entrypoint.sh /
RUN echo ". /opt/ros/$ROS_DISTRO/setup.bash" >> ~/.bashrc && \
echo ". /ros_ws/devel/setup.bash" >> ~/.bashrc && \
# allows us to run: docker exec -it rosbot bash --login -c "rostopic list"
echo ". /opt/ros/$ROS_DISTRO/setup.bash" >> ~/.profile && \
echo ". /ros_ws/devel/setup.bash" >> ~/.profile
ENTRYPOINT ["/ros_entrypoint.sh"]
CMD ["bash"]