-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
165 lines (134 loc) · 6.23 KB
/
Dockerfile
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
# Base image with ROS2 Humble
ARG BASE_IMAGE=osrf/ros:humble-desktop
FROM ${BASE_IMAGE} AS downloader
# Determine Webots version and download it
ARG WEBOTS_VERSION=R2023b
ARG WEBOTS_PACKAGE_PREFIX=
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && \
apt-get install --yes wget bzip2 && \
rm -rf /var/lib/apt/lists/* && \
wget https://github.com/cyberbotics/webots/releases/download/$WEBOTS_VERSION/webots-$WEBOTS_VERSION-x86-64$WEBOTS_PACKAGE_PREFIX.tar.bz2 && \
tar xjf webots-*.tar.bz2 && rm webots-*.tar.bz2
# Start a new stage from base image
FROM ${BASE_IMAGE}
# Install tools and dependencies
RUN apt-get update && \
apt-get install --yes \
build-essential \
cmake \
git \
python3-pip \
python3-colcon-common-extensions \
wget \
libboost-program-options-dev \
libusb-1.0-0-dev \
&& rm -rf /var/lib/apt/lists/*
RUN pip3 install cflib transform3D
# Disable interactive dialogs
ENV DEBIAN_FRONTEND=noninteractive
# Install Webots runtime dependencies
RUN apt-get update && \
apt-get install --yes wget xvfb locales && \
rm -rf /var/lib/apt/lists/* && \
wget https://raw.githubusercontent.com/cyberbotics/webots/master/scripts/install/linux_runtime_dependencies.sh && \
chmod +x linux_runtime_dependencies.sh && ./linux_runtime_dependencies.sh && \
rm ./linux_runtime_dependencies.sh && \
rm -rf /var/lib/apt/lists/*
# Install Webots
WORKDIR /usr/local
COPY --from=downloader /webots /usr/local/webots/
ENV QTWEBENGINE_DISABLE_SANDBOX=1
ENV WEBOTS_HOME /usr/local/webots
ENV PATH /usr/local/webots:${PATH}
# Enable OpenGL capabilities
ENV NVIDIA_DRIVER_CAPABILITIES graphics,compute,utility
# Set user name to fix a warning
ENV USER root
# Set the locales
RUN locale-gen en_US.UTF-8
ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8'
# Source ROS 2 environment
SHELL ["/bin/bash", "-c"]
RUN echo "source /opt/ros/humble/setup.bash" >> ~/.bashrc
# Install Gazebo
RUN apt-get update && \
apt-get install -y curl \
lsb-release \
gnupg && \
curl https://packages.osrfoundation.org/gazebo.gpg --output /usr/share/keyrings/pkgs-osrf-archive-keyring.gpg && \
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/pkgs-osrf-archive-keyring.gpg] http://packages.osrfoundation.org/gazebo/ubuntu-stable $(lsb_release -cs) main" | tee /etc/apt/sources.list.d/gazebo-stable.list > /dev/null && \
apt-get update && \
apt-get install -y gz-harmonic && \
rm -rf /var/lib/apt/lists/*
# Install ROS 2 dependencies
RUN apt-get update && \
apt-get install -y \
ros-humble-motion-capture-tracking \
ros-humble-tf-transformations \
ros-humble-teleop-twist-keyboard \
ros-humble-ros-gzharmonic
# Clone Crazyflie simulator repository
WORKDIR /root
RUN git clone https://github.com/bitcraze/crazyflie-simulation.git
RUN git clone https://github.com/bitcraze/crazyflie-lib-python.git && \
cd crazyflie-lib-python && \
pip3 install .
# Download the bresenham package
RUN pip install bresenham
# Use a shell script to find the line number and replace the line
RUN line_number=$(grep -n "sys.path.append('../../../../../../python/crazyflie-lib-python/examples/multiranger/wall_following')" /root/crazyflie-simulation/simulator_files/webots/controllers/crazyflie_controller_py_wallfollowing/crazyflie_controller_py_wallfollowing.py | cut -d: -f1) && \
if [ -n "$line_number" ]; then \
sed -i "${line_number}s|.*|sys.path.append('/root/crazyflie-lib-python/examples/multiranger/wall_following')|" /root/crazyflie-simulation/simulator_files/webots/controllers/crazyflie_controller_py_wallfollowing/crazyflie_controller_py_wallfollowing.py; \
else \
echo "Text not found in the file."; \
fi
# Crazyradio 2.0 settings
# Add plugdev group and add root to it
RUN getent group plugdev || groupadd plugdev && usermod -a -G plugdev root
# Create udev rules for Crazyflie and Crazyradio
RUN mkdir -p /etc/udev/rules.d && \
echo 'SUBSYSTEM=="usb", ATTRS{idVendor}=="1915", ATTRS{idProduct}=="7777", MODE="0664", GROUP="plugdev"' > /etc/udev/rules.d/99-bitcraze.rules && \
echo 'SUBSYSTEM=="usb", ATTRS{idVendor}=="1915", ATTRS{idProduct}=="0101", MODE="0664", GROUP="plugdev"' >> /etc/udev/rules.d/99-bitcraze.rules && \
echo 'SUBSYSTEM=="usb", ATTRS{idVendor}=="0483", ATTRS{idProduct}=="5740", MODE="0664", GROUP="plugdev"' >> /etc/udev/rules.d/99-bitcraze.rules
# Build Crazyflie controller
WORKDIR /root/crazyflie-simulation/simulator_files/webots/controllers/crazyflie_controller_c
RUN make
# # Set environment for Crazyflie simulation
# WORKDIR /root
# RUN export GZ_SIM_RESOURCE_PATH="/root/crazyflie-simulation/simulator_files/gazebo/"
# Create workspaces for both simulation and ROS
RUN mkdir -p /root/crazyflie_mapping_demo/simulation_ws && \
mkdir -p /root/crazyflie_mapping_demo/ros2_ws/src
# Clone the simulation repository
WORKDIR /root/crazyflie_mapping_demo/simulation_ws
RUN git clone https://github.com/bitcraze/crazyflie-simulation.git
# Clone the ROS2 projects
WORKDIR /root/crazyflie_mapping_demo/ros2_ws/src
RUN git clone https://github.com/knmcguire/crazyflie_ros2_multiranger.git && \
git clone https://github.com/knmcguire/ros_gz_crazyflie && \
git clone --recursive https://github.com/IMRCLab/crazyswarm2.git
# Build the ROS2 workspace
WORKDIR /root/crazyflie_mapping_demo/ros2_ws
RUN source /opt/ros/humble/setup.bash && \
colcon build --cmake-args -DBUILD_TESTING=ON
WORKDIR /root
# Source the ROS2 workspace
RUN echo "source /root/crazyflie_mapping_demo/ros2_ws/install/setup.bash" >> ~/.bashrc
ENV GZ_SIM_RESOURCE_PATH="/root/Shared/crazyflie_mapping_demo/simulation_ws/crazyflie-simulation/simulator_files/gazebo/"
# Copy download_models.sh and run it
COPY download_models.sh /root/
COPY models_links.txt /root/
# Run the download_models.sh script
RUN chmod +x /root/download_models.sh && \
./download_models.sh
# Install PyTorch for depth estimation
RUN pip install torch torchvision --index-url https://download.pytorch.org/whl/cu124
# Install the rest of the dependencies
COPY neural_network_model/requirements.txt /root/
RUN pip install -r requirements.txt && \
rm requirements.txt
RUN pip install onnx2torch
RUN pip uninstall cv_bridge -y
RUN pip install cv_bridge
RUN pip install --upgrade transforms3d