Skip to content

Commit

Permalink
fixed threshold level to fix missing portions, and moved installing p…
Browse files Browse the repository at this point in the history
…ython dependencies to gazebo package.xml
  • Loading branch information
ZealousGinger committed Jul 2, 2024
1 parent 7a2e0a7 commit 0fe0b69
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
5 changes: 3 additions & 2 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
software-properties-common \
wget \
curl \
python3-pip \
&& rm -rf /var/lib/apt/lists/*

FROM nvidia/cuda:12.1.0-runtime-ubuntu${UBUNTU_VER} as ros2nvidia
Expand Down Expand Up @@ -66,6 +67,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
software-properties-common \
wget \
curl \
python3-pip \
libegl1-mesa \
libglu1-mesa \
libxv1 \
Expand Down Expand Up @@ -218,6 +220,5 @@ RUN if [ ${DEPLOY} == "hardware" ]; then \
WORKDIR /root/linorobot2_ws
RUN source /opt/ros/$ROS_DISTRO/setup.bash \
&& colcon build
RUN sudo apt-get update -y && sudo apt-get install -y python3-pip
RUN pip3 install trimesh numpy pycollada scipy networkx opencv-contrib-python matplotlib

ENTRYPOINT ["/root/entrypoint.sh"]
7 changes: 7 additions & 0 deletions linorobot2_gazebo/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@
<exec_depend>geometry_msgs</exec_depend>
<exec_depend>image_proc</exec_depend>
<exec_depend>depth_image_proc</exec_depend>
<exec_depend>python-trimesh-pip</exec_depend>
<exec_depend>python3-numpy</exec_depend>
<exec_depend>python3-pycollada</exec_depend>
<exec_depend>python3-scipy</exec_depend>
<exec_depend>python3-networkx</exec_depend>
<exec_depend>python3-opencv-contrib-python</exec_depend>
<exec_depend>python3-matplotlib</exec_depend>
<export>
<build_type>ament_cmake</build_type>
</export>
Expand Down
6 changes: 3 additions & 3 deletions linorobot2_gazebo/scripts/map2gazebo.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ def map_callback(self):

# set all -1 (unknown) values to 0 (unoccupied)
map_array[map_array < 0] = 0
contours = self.get_occupied_regions(map_array, map_info['occupied_thresh'])
contours = self.get_occupied_regions(map_array)
print('Processing...')
meshes = [self.contour_to_mesh(c, map_info) for c in contours]

Expand Down Expand Up @@ -324,13 +324,13 @@ def _extract_maps(self, directory_path):
files_dict[base_name] = [os.path.join(directory_path, filename)]
return files_dict

def get_occupied_regions(self, map_array, occupied_thresh):
def get_occupied_regions(self, map_array):
"""
Get occupied regions of map
"""
map_array = map_array.astype(np.uint8)
_, thresh_map = cv2.threshold(
map_array, occupied_thresh*255, 100, cv2.THRESH_BINARY)
map_array, 253, 255, cv2.THRESH_BINARY)
contours, hierarchy = cv2.findContours(
thresh_map, cv2.RETR_CCOMP, cv2.CHAIN_APPROX_NONE)
# Using cv2.RETR_CCOMP classifies external contours at top level of
Expand Down

0 comments on commit 0fe0b69

Please sign in to comment.