-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathDockerfile
More file actions
175 lines (126 loc) · 5.2 KB
/
Dockerfile
File metadata and controls
175 lines (126 loc) · 5.2 KB
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
166
167
168
169
170
171
172
173
174
175
#Created By Jagadeesh-P
#03-08-2024
FROM osrf/ros:humble-desktop
# Install necessary programs
RUN apt-get update \
&& apt-get install -y \
nano \
vim \
git \
curl \
lsb-release \
gnupg \
sudo \
&& rm -rf /var/lib/apt/lists/*
# Create a non-root user
ARG USERNAME=ros
ARG USER_UID=1000
ARG USER_GID=$USER_UID
RUN groupadd --gid $USER_GID $USERNAME \
&& useradd -s /bin/bash --uid $USER_UID --gid $USER_GID -m $USERNAME \
&& mkdir /home/$USERNAME/.config && chown $USER_UID:$USER_GID /home/$USERNAME/.config
# Set up sudo
RUN echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \
&& chmod 0440 /etc/sudoers.d/$USERNAME
# Install gz-harmonic
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" | tee /etc/apt/sources.list.d/gazebo-stable.list > /dev/null \
&& apt-get update \
&& apt-get install -y gz-harmonic
####################################################################################################
# Set up ROS 2 workspace
USER $USERNAME
WORKDIR /home/$USERNAME
#COPY ardupilot /home/${USERNAME}/ardupilot
#COPY Micro-XRCE-DDS-Gen /home/${USERNAME}/Micro-XRCE-DDS-Gen
RUN sudo apt install default-jre \
&& sudo apt-get install gitk git-gui \
&& sudo apt-get install gcc-arm-none-eabi -y
RUN cd ~/ \
&& git clone --recurse-submodules https://github.com/ardupilot/Micro-XRCE-DDS-Gen.git
RUN cd ~/Micro-XRCE-DDS-Gen \
&& ./gradlew assemble
RUN cd ~/ \
&& git clone https://github.com/ArduPilot/ardupilot.git \
&& cd ardupilot \
&& git submodule update --init --recursive \
&& git submodule init \
&& git submodule update \
&& git status
RUN cd ~/ardupilot \
&& ./waf distclean \
&& ./waf distclean \
&& ./waf configure --board MatekF405-Wing
# Extra WS
RUN mkdir -p ~/ws/src \
&& cd ~/ws
COPY extra.repos /home/${USERNAME}/ws/extra.repos
RUN cd ~/ws/ \
&& vcs import --recursive --input https://raw.githubusercontent.com/Jagadeesh-pradhani/ROS2_ardupilot_Iris_docker/main/extra.repos src \
&& sudo apt update \
&& rosdep update \
&& /bin/bash -c "source /opt/ros/humble/setup.bash" \
&& rosdep install -y --from-paths src --ignore-src
#BUild ws
RUN cd ~/ws \
&& colcon build || true
RUN /bin/bash -c "source ~/ws/install/setup.bash"
#### ROS2 WS
RUN mkdir -p ~/ros2_ws/src \
&& cd ~/ros2_ws
COPY ros2.repos /home/${USERNAME}/ros2_ws/ros2.repos
COPY ros2_gz.repos /home/${USERNAME}/ros2_ws/ros2_gz.repos
RUN cd ~/ros2_ws/ \
&& vcs import --recursive --input https://raw.githubusercontent.com/Jagadeesh-pradhani/ROS2_ardupilot_Iris_docker/main/ros2.repos src \
&& sudo apt update \
&& rosdep update \
&& /bin/bash -c "source /opt/ros/humble/setup.bash" \
&& rosdep install -y --from-paths src --ignore-src
#BUild
RUN cd ~/ros2_ws \
&& colcon build --packages-up-to ardupilot_dds_tests || true
RUN /bin/bash -c "source ~/ros2_ws/install/setup.bash"
RUN sudo rm /home/${USERNAME}/ardupilot/Tools/environment_install/install-prereqs-ubuntu.sh
COPY install-prereqs-ubuntu.sh /home/${USERNAME}/ardupilot/Tools/environment_install/install-prereqs-ubuntu.sh
RUN cd ~/ardupilot \
&& sudo apt-get install -y python3-pip \
&& sudo pip3 install future \
&& Tools/environment_install/install-prereqs-ubuntu.sh -y || true \
&& sudo apt-get install -y python3-pexpect \
&& ./waf clean \
&& ./waf configure --board sitl \
&& ./waf copter -v
RUN cd ~/ardupilot/Tools/autotest \
&& sudo pip3 install MAVProxy \
&& sudo pip3 install MAVProxy[joystick]
#ROS2 with SITL
RUN /bin/bash -c "source /opt/ros/humble/setup.bash"
#Build
RUN cd ~/ros2_ws/ \
&& colcon build --packages-up-to ardupilot_sitl || true
RUN /bin/bash -c "source ~/ros2_ws/install/setup.bash"
#ROS2 with SITL in GAZEBO
RUN cd ~/ros2_ws \
&& vcs import --input https://raw.githubusercontent.com/Jagadeesh-pradhani/ROS2_ardupilot_Iris_docker/main/ros2_gz.repos --recursive src || true \
&& /bin/bash -c "source /opt/ros/humble/setup.bash" \
&& sudo apt update \
&& rosdep update \
&& rosdep install -y --from-paths src --ignore-src -r || true
#Build
RUN cd ~/ros2_ws \
&& colcon build --packages-up-to ardupilot_gz_bringup || true
RUN /bin/bash -c "source ~/ros2_ws/install/setup.bash"
RUN cd ~/ros2_ws/src/ \
&& git clone https://github.com/ArduPilot/ardupilot_ros.git \
&& cd ~/ros2_ws/ \
&& rosdep install --from-paths src --ignore-src -r -y --skip-keys gazebo-ros-pkgs \
&& colcon build --packages-up-to ardupilot_ros --parallel-workers 12 || true
# Copy local src folder to ros_ws
COPY ./src/ /home/ros/ros2_ws/src/
####################################################################################################
# Copy the entrypoint and bashrc scripts so we have our container's environment set up correctly
COPY entrypoint.sh /entrypoint.sh
COPY bashrc /home/${USERNAME}/.bashrc
# Set up entrypoint and default command
ENTRYPOINT ["/bin/bash", "/entrypoint.sh"]
CMD ["bash"]