-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
109 lines (85 loc) · 3.56 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
ARG ROS_DISTRO=humble
FROM osrf/ros:${ROS_DISTRO}-desktop
# Avoid prompts from apt
ENV DEBIAN_FRONTEND=noninteractive
# Declare an ARG for setting RUN_MODE at build time (optional)
ARG RUN_MODE=cli
# Set an ENV variable based on the ARG (to make it available at runtime)
ENV RUN_MODE=${RUN_MODE}
# Ignore setup.py warnings in building phase
ENV PYTHONWARNINGS="ignore:setup.py install is deprecated::setuptools.command.install"
# Install required apps
RUN apt-get update \
&& apt-get install -y \
nano \
git \
python3-pip \
&& rm -rf /var/lib/apt/list/*
# Install gazebo dependencies
RUN apt-get update \
&& apt-get install -y \
curl \
lsb-release \
gnupg \
python3-colcon-common-extensions \
&& rm -rf /var/lib/apt/list/*
# Set up colcon_cd for future bash sessions
RUN echo "source /usr/share/colcon_cd/function/colcon_cd.sh" >> ~/.bashrc
RUN echo "export _colcon_cd_root=/opt/ros/humble/" >> ~/.bashrc
RUN echo "source /usr/share/colcon_argcomplete/hook/colcon-argcomplete.bash" >> ~/.bashrc
# Add Gazebo repository
RUN 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" | sudo tee /etc/apt/sources.list.d/gazebo-stable.list > /dev/null
# Set up the gazebo version
ARG GZ_VERSION=fortress
# Install Gazebo
RUN apt-get update \
&& apt-get install -y \
gz-${GZ_VERSION} \
ros-${ROS_DISTRO}-ros-gz-sim \
ros-${ROS_DISTRO}-ros-gz-bridge \
&& rm -rf /var/lib/apt/lists/*
# Set up the environment
ENV GZ_RESOURCE_PATH=/usr/share/gazebo-${GZ_VERSION}
# Create the necessary directories
RUN mkdir -p /root/crazyflie_mapping_demo/simulation_ws \
&& mkdir -p /root/crazyflie_mapping_demo/ros2_ws/src
# Set the working directory inside the container
WORKDIR /home/crazyflie_mapping_demo/simulation_ws
# Clone the repositorys into ros2 workspace
RUN git clone https://github.com/captain-bender/crazyflie-simulation.git
# Set the working directory inside the container
WORKDIR /home/crazyflie_mapping_demo/ros2_ws/src
# Clone the repository into simulation_ws
RUN git clone https://github.com/knmcguire/crazyflie_ros2_multiranger.git \
&& git clone https://github.com/knmcguire/ros_gz_crazyflie \
&& git clone https://github.com/IMRCLab/crazyswarm2 --recursive
# Install necessary tools and dependencies
RUN apt-get update \
&& apt-get install -y \
libboost-program-options-dev \
libusb-1.0-0-dev \
python3-colcon-common-extensions \
ros-${ROS_DISTRO}-motion-capture-tracking \
ros-${ROS_DISTRO}-tf-transformations \
ros-${ROS_DISTRO}-teleop-twist-keyboard \
&& rm -rf /var/lib/apt/lists/*
# Install Python packages
RUN pip3 install cflib transform3D bresenham
# Change permissions
RUN sudo chmod 777 -R /home/crazyflie_mapping_demo/ros2_ws
# Set working directory to ros2_ws and build using colcon
WORKDIR /home/crazyflie_mapping_demo/ros2_ws
# Build
RUN . /opt/ros/${ROS_DISTRO}/setup.sh \
&& colcon build --cmake-args -DBUILD_TESTING=ON
# Source ROS 2 workspace setup and set environment variable for GZ_SIM_RESOURCE_PATH
RUN echo "source /home/crazyflie_mapping_demo/ros2_ws/install/setup.bash" >> ~/.bashrc \
&& echo 'export GZ_SIM_RESOURCE_PATH="/home/crazyflie_mapping_demo/simulation_ws/crazyflie-simulation/simulator_files/gazebo/"' >> ~/.bashrc
# Entrypoint
COPY entrypoint.sh /
RUN chmod +x /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]
# Interactive bash shell
CMD ["/bin/bash"]
# CMD ["sleep", "infinity"]