Skip to content

Commit 3853149

Browse files
committed
Updated dockerfile to build with or without dependencies in the contianer
Fixed bug in numpy array conversion
1 parent 67fade9 commit 3853149

File tree

2 files changed

+82
-53
lines changed

2 files changed

+82
-53
lines changed

docker/Dockerfile.x64

Lines changed: 81 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ ARG USERNAME=ros
1313
ARG USER_UID=1000
1414
ARG USER_GID=$USER_UID
1515
ARG RMW_NAME=zenoh
16+
ARG INSTALL_EMCUPY_ROSDEPS=true
1617

1718
# Environment variables
1819
ENV DEBIAN_FRONTEND=noninteractive \
@@ -121,18 +122,27 @@ RUN python3 -m pip install \
121122
flake8-quotes
122123
# For Python code formatting. Not sure what package uses it
123124
# black==21.12b0\
124-
#### For elevation_mapping_cupy ####
125-
# ruamel.yaml\ # replacing with apt python-ruamel.yaml
126-
# scikit-learn\ # replacing with apt python3-sklearn - might not be needeed
127-
# shapely\ # replacing with apt python3-shapely
128-
# opencv-python\ # replacing with apt installed python3-opencv
129-
# cupy-cuda12x\ # extra rosdeps
130-
# scipy\ # apt install scipy instead
131-
# simple-parsing\ # extra rosdeps
132-
# "numpy<2.0.0" # extra rosdeps
125+
#### For elevation_mapping_cupy ####
126+
RUN if [ "$INSTALL_EMCUPY_ROSDEPS" = true ]; then \
127+
python3 -m pip install \
128+
# rosdep resolves with apt python-ruamel.yaml
129+
# ruamel.yaml\
130+
# rosdep resolves with apt python3-sklearn - might not be needed
131+
scikit-learn\
132+
# rosdep resolves with apt python3-shapely
133+
# shapely\
134+
# rosdep resolves with apt python3-opencv
135+
opencv-python\
136+
# rosdep resolves using extra rosdeps
137+
cupy-cuda12x\
138+
# rosdep resolves using extra rosdeps
139+
simple-parsing\
140+
# rosdep resolves using extra rosdeps
141+
"numpy<2.0.0"; \
142+
fi
133143

134144
# Needed for elevation_mapping_cupy to not have run-time errors
135-
# RUN python3 -m pip install transforms3d -U # Replacing with rosdep python3-transforms3d
145+
RUN python3 -m pip install transforms3d scipy -U
136146

137147
# Set up non-root user
138148
RUN groupadd --gid $USER_GID $USERNAME \
@@ -153,40 +163,53 @@ RUN distribution=$(. /etc/os-release;echo $ID$VERSION_ID) \
153163
&& apt clean \
154164
&& rm -rf /var/lib/apt/lists/*
155165

156-
# RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
157-
# apt update && apt install -y --no-install-recommends \
158-
# For elevation_mapping_cupy
159-
# libboost-all-dev\ # resolved by rosdep as boost
160-
# && apt clean && \
161-
# rm -rf /var/lib/apt/lists/*
162-
163-
# RUN apt update && \
164-
# DEBIAN_FRONTEND=${DEBIAN_FRONTEND} apt install -y \
165-
#### For elevation_mapping_cupy ####
166-
# ros-${ROS_DISTRO}-grid-map-msgs\ # rosdep grid_map_msgs
167-
# ros-${ROS_DISTRO}-grid-map-ros\ # rosdep grid_map_ros
168-
# ros-${ROS_DISTRO}-image-transport\ # rosdep image_transport
169-
# ros-${ROS_DISTRO}-pcl-ros\# rosdep pcl_ros
170-
# ros-${ROS_DISTRO}-cv-bridge\ # rosdep cv_bridge
171-
# ros-${ROS_DISTRO}-tf-transformations\ # rosdep tf-transformations
172-
# ros-${ROS_DISTRO}-rviz2\ # rosdep rviz2
173-
# ros-${ROS_DISTRO}-gazebo-ros\ # replacing with rosdep gazebo_ros_pkgs
174-
# ros-${ROS_DISTRO}-grid-map-cv\ # rosdep grid_map_cv
175-
# ros-${ROS_DISTRO}-grid-map-core\ # rosdep grid_map_core
176-
# ros-${ROS_DISTRO}-grid-map-demos\ # rosdep grid_map_demos
177-
##################################
178-
#### For debugging elevation_mapping_cupy by setting up turtlebot3_simulations####
179-
# ros-${ROS_DISTRO}-turtlebot3*\
180-
# ros-${ROS_DISTRO}-camera-calibration-parsers\
181-
# ros-${ROS_DISTRO}-camera-info-manager\
182-
# ros-${ROS_DISTRO}-gazebo-plugins\
183-
# ros-${ROS_DISTRO}-turtlebot3-msgs\
184-
# ros-${ROS_DISTRO}-turtlebot3-teleop\
185-
# ros-${ROS_DISTRO}-gazebo-ros-pkgs\ # replacing with rosdep gazebo_ros_pkgs
186-
##############################################
187-
# && apt clean && \
188-
# rm -rf /var/lib/apt/lists/*
189166

167+
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
168+
if [ "$INSTALL_EMCUPY_ROSDEPS" = true ]; then \
169+
apt update && DEBIAN_FRONTEND=${DEBIAN_FRONTEND} apt install -y --no-install-recommends \
170+
# resolved by rosdep as boost
171+
libboost-all-dev\
172+
### For elevation_mapping_cupy ####
173+
# rosdep grid_map_msgs
174+
ros-${ROS_DISTRO}-grid-map-msgs\
175+
# rosdep grid_map_ros
176+
ros-${ROS_DISTRO}-grid-map-ros\
177+
# rosdep image_transport
178+
ros-${ROS_DISTRO}-image-transport\
179+
# rosdep pcl_ros
180+
ros-${ROS_DISTRO}-pcl-ros\
181+
# rosdep cv_bridge
182+
ros-${ROS_DISTRO}-cv-bridge\
183+
# rosdep tf-transformations
184+
ros-${ROS_DISTRO}-tf-transformations\
185+
# rosdep rviz2
186+
ros-${ROS_DISTRO}-rviz2\
187+
# replacing with rosdep gazebo_ros_pkgs
188+
ros-${ROS_DISTRO}-gazebo-ros\
189+
# rosdep grid_map_cv
190+
ros-${ROS_DISTRO}-grid-map-cv\
191+
# rosdep grid_map_core
192+
ros-${ROS_DISTRO}-grid-map-core\
193+
# rosdep grid_map_demos
194+
ros-${ROS_DISTRO}-grid-map-demos\
195+
ros-${ROS_DISTRO}-point-cloud-transport\
196+
python3-shapely\
197+
python3-scipy\
198+
python3-ruamel.yaml\
199+
#################################
200+
### For debugging elevation_mapping_cupy by setting up turtlebot3_simulations####
201+
# ros-${ROS_DISTRO}-turtlebot3*\
202+
ros-${ROS_DISTRO}-camera-calibration-parsers\
203+
ros-${ROS_DISTRO}-camera-info-manager\
204+
ros-${ROS_DISTRO}-gazebo-plugins\
205+
ros-${ROS_DISTRO}-turtlebot3-msgs\
206+
ros-${ROS_DISTRO}-turtlebot3-teleop\
207+
# replacing with rosdep gazebo_ros_pkgs
208+
ros-${ROS_DISTRO}-gazebo-ros-pkgs\
209+
#############################################
210+
&& apt clean && \
211+
rm -rf /var/lib/apt/lists/* ;\
212+
fi
190213
# Development stage
191214
FROM dev as dev2
192215
ARG WORKSPACE="/home/${USERNAME}/workspace"
@@ -195,17 +218,23 @@ RUN mkdir -p ${WORKSPACE}/src/elevation_mapping_cupy && chown -R ${USER_UID}:${U
195218
RUN echo "if [ -f ${WORKSPACE}/install/setup.bash ]; then source ${WORKSPACE}/install/setup.bash; fi" >> /home/ros/.bashrc
196219
WORKDIR ${WORKSPACE}
197220

198-
# TODO: move up later before commiting
221+
199222
# Setup rosdep
200-
# Could cache this, but since we are linking extra-rosdeps.yaml instead of copying this doesn't do anything
223+
RUN rosdep init
224+
# COPY docker/extra_rosdeps.yaml /etc/ros/rosdep/sources.list.d/emcupy-rosdeps-fixed.yaml
225+
# Setup rosdep with extra rosdeps and install them for elevation_mapping_cupy
201226
# RUN --mount=type=cache,target=/home/${USERNAME}/.ros/rosdep/sources.cache \
202-
RUN rosdep init \
203-
&& ln -s ${WORKSPACE}/src/elevation_mapping_cupy/docker/extra_rosdeps.yaml /etc/ros/rosdep/sources.list.d/emcupy-rosdeps.yaml\
204-
&& echo "yaml file:///etc/ros/rosdep/sources.list.d/emcupy-rosdeps.yaml" | tee /etc/ros/rosdep/sources.list.d/00-emcupy-rosdeps.list
205-
# Linking only works if you don't run rosdep update here and wait until it is loaded, otherwise can use copy
206-
# The benefit is that you can update the rosdeps in your workspace and they will be used
207-
# COPY docker/extra_rosdeps.yaml /etc/ros/rosdep/sources.list.d/emcupy-rosdeps.yaml
208-
# RUN rosdep update
227+
# RUN if [ "$INSTALL_EMCUPY_ROSDEPS" = true ]; then \
228+
# echo "yaml file:///etc/ros/rosdep/sources.list.d/emcupy-rosdeps-fixed.yaml" | tee /etc/ros/rosdep/sources.list.d/01-emcupy-rosdeps.list && \
229+
# rosdep update && \
230+
# # This install doesn't seem to actually install anything, so removing
231+
# apt update && \
232+
# rosdep install --from-paths . --ignore-src -y -r; \
233+
# fi
234+
# Now add the same file again, but this one is symlinked so will change if you change the file in your workspace
235+
RUN ln -s ${WORKSPACE}/src/elevation_mapping_cupy/docker/extra_rosdeps.yaml /etc/ros/rosdep/sources.list.d/emcupy-rosdeps.yaml && \
236+
echo "yaml file:///etc/ros/rosdep/sources.list.d/emcupy-rosdeps.yaml" | tee /etc/ros/rosdep/sources.list.d/00-emcupy-rosdeps.list;
237+
209238

210239
# Switch to non-root user
211240
USER $USERNAME

elevation_mapping_cupy/scripts/elevation_mapping_node.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ def pointcloud_callback(self, msg: PointCloud2, sub_key: str) -> None:
383383
# Append additional channels to pts
384384
for channel in additional_channels:
385385
if channel in points.dtype.names:
386-
data = points[channel]
386+
data = points[channel].flatten()
387387
if data.ndim == 1:
388388
data = data[:, np.newaxis]
389389
pts = np.hstack((pts, data))

0 commit comments

Comments
 (0)