Skip to content

Commit eb1a8f5

Browse files
Formatting of the code + adding Beluga API to init, predict, update pose and covariance
1 parent 0fe818f commit eb1a8f5

11 files changed

Lines changed: 1872 additions & 1809 deletions

File tree

docker/images/humble/Dockerfile

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,7 @@ RUN mkdir -p /tmp/ws/src \
2121

2222
FROM ros:humble-ros-base-jammy AS openvdb-builder
2323

24-
RUN sed -i 's|http://archive.ubuntu.com|http://security.ubuntu.com|g' /etc/apt/sources.list
25-
26-
RUN apt-get update -y --fix-missing \
24+
RUN apt-get update \
2725
&& apt-get install --no-install-recommends -y \
2826
git \
2927
libboost-all-dev \
@@ -43,21 +41,17 @@ RUN git clone -b v8.2.0 https://github.com/AcademySoftwareFoundation/openvdb.git
4341
# Build pcl_perception here to avoid installing boost again
4442
RUN mkdir -p /opt/perception/src
4543

46-
RUN sed -i 's|http://archive.ubuntu.com|http://security.ubuntu.com|g' /etc/apt/sources.list
47-
48-
RUN apt-get update -y --fix-missing \
44+
RUN apt-get update \
4945
&& apt-get install --no-install-recommends -y \
5046
libeigen3-dev \
5147
libpcl-dev \
5248
&& rm -rf /var/lib/apt/lists/*
5349

5450
WORKDIR /opt/perception/src
5551

56-
RUN sed -i 's|http://archive.ubuntu.com|http://security.ubuntu.com|g' /etc/apt/sources.list
57-
5852
RUN git clone -b 2.6.1 https://github.com/ros-perception/perception_pcl.git \
5953
&& cd .. \
60-
&& sudo apt-get update -y --fix-missing \
54+
&& sudo apt-get update \
6155
&& . /opt/ros/humble/setup.sh \
6256
&& rosdep update \
6357
&& rosdep install -i -y --from-path src \
@@ -70,9 +64,7 @@ ENV SHELL=/bin/bash
7064

7165
ENV DEBIAN_FRONTEND=noninteractive
7266

73-
RUN sed -i 's|http://archive.ubuntu.com|http://security.ubuntu.com|g' /etc/apt/sources.list
74-
75-
RUN apt-get update -y --fix-missing \
67+
RUN apt-get update \
7668
&& apt-get install --no-install-recommends -y \
7769
ccache \
7870
curl \
@@ -87,10 +79,9 @@ RUN apt-get update -y --fix-missing \
8779
&& rm -rf /var/lib/apt/lists/*
8880

8981
ARG GZ_VERSION="harmonic"
90-
RUN sed -i 's|http://archive.ubuntu.com|http://security.ubuntu.com|g' /etc/apt/sources.list
9182
RUN curl https://packages.osrfoundation.org/gazebo.gpg --output /usr/share/keyrings/pkgs-osrf-archive-keyring.gpg \
9283
&& 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" > /etc/apt/sources.list.d/gazebo-stable.list \
93-
&& apt-get update -y --fix-missing && apt-get install --no-install-recommends -y $(if [[ "${GZ_VERSION}" > "fortress" ]]; then echo gz; else echo ignition; fi)-${GZ_VERSION}
84+
&& apt-get update && apt-get install --no-install-recommends -y $(if [[ "${GZ_VERSION}" > "fortress" ]]; then echo gz; else echo ignition; fi)-${GZ_VERSION}
9485

9586
RUN pip install pre-commit==2.20.0
9687

@@ -158,7 +149,7 @@ COPY --from=openvdb-builder --chown=$USER:$GROUP /opt/perception/install/percept
158149
# Install project dependencies
159150

160151
COPY --from=package_cacher --chown=$USER:$GROUP /tmp/ws/ $USER_WS/
161-
RUN sudo apt-get update -y --fix-missing \
152+
RUN sudo apt-get update \
162153
&& . /opt/ros/humble/setup.sh \
163154
&& rosdep update \
164155
&& rosdep install -i -y --from-path src \
@@ -209,4 +200,4 @@ RUN cd /opt/openvdb/build \
209200
RUN sudo dpkg -r libopenvdb8.1 \
210201
libopenvdb-dev
211202

212-
ENTRYPOINT ["fixuid", "-q", "/ros_entrypoint.sh", "/bin/bash"]
203+
ENTRYPOINT ["fixuid", "-q", "/ros_entrypoint.sh", "/bin/bash"]

localization/beluga_demo_mh_amcl/include/beluga_demo_mh_amcl/map_matcher.hpp

Lines changed: 60 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -27,73 +27,76 @@
2727
#include <tf2/LinearMath/Transform.h>
2828
#include <tf2/transform_datatypes.h>
2929

30-
namespace mh_amcl {
31-
32-
/**
33-
* @brief Struct containing a transform and its associated weight
34-
*/
35-
typedef struct {
36-
float weight;
37-
tf2::Transform transform;
38-
} TransformWeighted;
39-
40-
/**
41-
* @brief Overload of the operator '<' to be able to compare TransformWeighted
42-
* structs
43-
*/
44-
bool operator<(const TransformWeighted &tw1, const TransformWeighted &tw2);
45-
46-
/**
47-
* MapMatcher class
48-
*
49-
* Performs the multi-resolution map matching process. It receives an occupancy
50-
* grid map and laser scan data to find transformations (poses) that align the
51-
* scan data with the map. It weights all potential transformations to select
52-
* the higher quality candidates.
53-
*/
54-
class MapMatcher {
55-
public:
56-
explicit MapMatcher(std::shared_ptr<const nav_msgs::msg::OccupancyGrid> map);
30+
namespace mh_amcl
31+
{
5732

5833
/**
59-
* @brief Get the candidate transformations from the laser information and the
60-
* map
34+
* @brief Struct containing a transform and its associated weight
6135
*/
62-
std::list<TransformWeighted>
63-
get_matches(const sensor_msgs::msg::LaserScan &scan);
36+
typedef struct
37+
{
38+
float weight;
39+
tf2::Transform transform;
40+
} TransformWeighted;
6441

65-
protected:
66-
static const int NUM_LEVEL_SCALE_COSTMAP = 4;
42+
/**
43+
* @brief Overload of the operator '<' to be able to compare TransformWeighted
44+
* structs
45+
*/
46+
bool operator<(const TransformWeighted &tw1, const TransformWeighted &tw2);
6747

6848
/**
69-
* @brief Reduce the resolution of the map to half to perform the
70-
* multi-resolution map-matching
49+
* MapMatcher class
50+
*
51+
* Performs the multi-resolution map matching process. It receives an occupancy
52+
* grid map and laser scan data to find transformations (poses) that align the
53+
* scan data with the map. It weights all potential transformations to select
54+
* the higher quality candidates.
7155
*/
72-
std::shared_ptr<beluga_ros::OccupancyGrid>
73-
half_scale(std::shared_ptr<beluga_ros::OccupancyGrid> costmap_in);
56+
class MapMatcher
57+
{
58+
public:
59+
explicit MapMatcher(std::shared_ptr<const nav_msgs::msg::OccupancyGrid> map);
60+
61+
/**
62+
* @brief Get the candidate transformations from the laser information and the
63+
* map
64+
*/
65+
std::list<TransformWeighted>
66+
get_matches(const sensor_msgs::msg::LaserScan &scan);
67+
68+
protected:
69+
static const int NUM_LEVEL_SCALE_COSTMAP = 4;
70+
71+
/**
72+
* @brief Reduce the resolution of the map to half to perform the
73+
* multi-resolution map-matching
74+
*/
75+
std::shared_ptr<beluga_ros::OccupancyGrid>
76+
half_scale(std::shared_ptr<beluga_ros::OccupancyGrid> costmap_in);
77+
78+
/**
79+
* @brief Transform the LaserScan message in a vector of 3D points
80+
*/
81+
std::vector<tf2::Vector3>
82+
laser2points(const sensor_msgs::msg::LaserScan &scan);
83+
84+
// Auxiliary methods to get the matches between the laser data and the map
85+
std::list<TransformWeighted>
86+
get_matches(int scale, const std::vector<tf2::Vector3> &scan, float min_x,
87+
float min_y, float max_y, float max_x);
88+
float match(int scale, std::shared_ptr<beluga_ros::OccupancyGrid> costmap,
89+
const std::vector<tf2::Vector3> &scan, tf2::Transform &transform);
90+
91+
// Current costmaps
92+
std::vector<std::shared_ptr<beluga_ros::OccupancyGrid>> costmaps_;
93+
};
7494

7595
/**
76-
* @brief Transform the LaserScan message in a vector of 3D points
96+
* @brief wrapper to transform the costmap to ROS Occupancy grid message
7797
*/
78-
std::vector<tf2::Vector3>
79-
laser2points(const sensor_msgs::msg::LaserScan &scan);
80-
81-
// Auxiliary methods to get the matches between the laser data and the map
82-
std::list<TransformWeighted>
83-
get_matches(int scale, const std::vector<tf2::Vector3> &scan, float min_x,
84-
float min_y, float max_y, float max_x);
85-
float match(int scale, std::shared_ptr<beluga_ros::OccupancyGrid> costmap,
86-
const std::vector<tf2::Vector3> &scan, tf2::Transform &transform);
87-
88-
// Current costmaps
89-
std::vector<std::shared_ptr<beluga_ros::OccupancyGrid>> costmaps_;
90-
};
91-
92-
/**
93-
* @brief wrapper to transform the costmap to ROS Occupancy grid message
94-
*/
95-
nav_msgs::msg::OccupancyGrid
96-
toMsg(std::shared_ptr<beluga_ros::OccupancyGrid> costmap);
98+
nav_msgs::msg::OccupancyGrid
99+
toMsg(std::shared_ptr<beluga_ros::OccupancyGrid> costmap);
97100

98101
} // namespace mh_amcl
99102

0 commit comments

Comments
 (0)