1+ FROM px4io/px4-dev-simulation-jammy
2+ LABEL maintainer="kmk <kmk6061602@gmail.com>"
3+
4+ ENV ROS_DISTRO=humble
5+
6+ RUN apt update && apt install -y \
7+ git \
8+ sudo
9+
10+ RUN echo user ALL=\( root\) NOPASSWD:ALL > /etc/sudoers.d/user \
11+ && chmod 0440 /etc/sudoers.d/user
12+
13+ # install ros2 humble
14+ RUN apt update && apt install -y locales \
15+ && locale-gen en_US en_US.UTF-8 \
16+ && update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8 \
17+ && export LANG=en_US.UTF-8 \
18+ && apt install -y software-properties-common \
19+ && add-apt-repository universe \
20+ && apt update && apt install curl -y \
21+ && curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o /usr/share/keyrings/ros-archive-keyring.gpg \
22+ && echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] http://packages.ros.org/ros2/ubuntu $(. /etc/os-release && echo $UBUNTU_CODENAME) main" | tee /etc/apt/sources.list.d/ros2.list > /dev/null \
23+ && apt update && apt upgrade -y \
24+ && apt install -y ros-$ROS_DISTRO-desktop \
25+ python3-colcon-common-extensions \
26+ && apt -y autoremove \
27+ && apt clean autoclean \
28+ && rm -rf /var/lib/apt/lists/{apt,dpkg,cache,log} /tmp/* /var/tmp/*
29+
30+ RUN git config --global http.postBuffer 524288000
31+
32+ # Install Micro XRCE-DDS Agent v3.0.1
33+ RUN git clone --branch v3.0.1 https://github.com/eProsima/Micro-XRCE-DDS-Agent.git /tmp/Micro-XRCE-DDS-Agent \
34+ && cd /tmp/Micro-XRCE-DDS-Agent \
35+ && mkdir build \
36+ && cd build \
37+ && cmake .. \
38+ && make -j$(nproc) \
39+ && make install && ldconfig \
40+ && rm -rf /tmp/Micro-XRCE-DDS-Agent
41+
42+ WORKDIR /home/user
43+ USER user
44+ RUN mkdir realgazebo
45+ WORKDIR /home/user/realgazebo
46+
47+ RUN git clone --branch realgazebo-1.14 https://github.com/SUV-Lab/RealGazebo-PX4-Autopilot.git --recursive \
48+ && git clone https://github.com/SUV-Lab/RealGazebo-ROS2.git --recursive
49+
50+ RUN cd /home/user/realgazebo/RealGazebo-PX4-Autopilot && ./Tools/setup/ubuntu.sh --no-nuttx
51+
52+ USER root
53+ RUN curl -sSL http://get.gazebosim.org | sh
54+ RUN apt update \
55+ && apt install -y ros-$ROS_DISTRO-gazebo-ros-pkgs \
56+ ros-$ROS_DISTRO-gazebo-ros \
57+ xterm \
58+ && apt-get -y autoremove \
59+ && apt-get clean autoclean \
60+ && rm -rf /var/lib/apt/lists/{apt,dpkg,cache,log} /tmp/* /var/tmp/*
61+
62+ RUN pip3 install gdown
63+
64+ USER user
65+ RUN cd /home/user/realgazebo/RealGazebo-PX4-Autopilot \
66+ && ./Tools/download_ctrack.sh \
67+ && DONT_RUN=1 make px4_sitl_default gazebo-classic \
68+ && cd /home/user/realgazebo/RealGazebo-ROS2 \
69+ && . /opt/ros/humble/setup.sh \
70+ && colcon build --symlink-install
71+
72+ USER root
73+ # Add setup file at bashrc
74+ RUN echo "source /opt/ros/$ROS_DISTRO/setup.bash" >> /home/user/.bashrc \
75+ && echo "source /home/user/realgazebo/RealGazebo-ROS2/install/setup.bash" >> /home/user/.bashrc \
76+ && chown user:user /home/user/.bashrc
77+
78+ # Entrypoint
79+ COPY scripts/entrypoint.sh /usr/local/bin/entrypoint.sh
80+ RUN chmod +x /usr/local/bin/entrypoint.sh
81+ ENTRYPOINT ["/usr/local/bin/entrypoint.sh" ]
82+
83+ CMD ["/bin/bash" ]
0 commit comments