Skip to content

Commit d65b903

Browse files
Addressed comments and studied new approach for weight and hits
Signed-off-by: JesusSilvaUtrera <jesus.silva@ekumenlabs.com>
1 parent 95f042f commit d65b903

8 files changed

Lines changed: 44 additions & 33 deletions

File tree

docker/images/humble/Dockerfile

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ FROM ros:humble-ros-base-jammy AS openvdb-builder
2323

2424
RUN apt-get update \
2525
&& apt-get install --no-install-recommends -y \
26-
git \
27-
libboost-all-dev \
28-
libtbb-dev \
29-
libblosc-dev \
26+
git \
27+
libboost-all-dev \
28+
libtbb-dev \
29+
libblosc-dev \
3030
&& rm -rf /var/lib/apt/lists/*
3131

3232
WORKDIR /opt
@@ -66,16 +66,16 @@ ENV DEBIAN_FRONTEND=noninteractive
6666

6767
RUN apt-get update \
6868
&& apt-get install --no-install-recommends -y \
69-
ccache \
70-
curl \
71-
gdb \
72-
gnupg \
73-
git \
74-
python3-pip \
75-
python3-venv \
76-
mc \
77-
lsb-release \
78-
tmux \
69+
ccache \
70+
curl \
71+
gdb \
72+
gnupg \
73+
git \
74+
python3-pip \
75+
python3-venv \
76+
mc \
77+
lsb-release \
78+
tmux \
7979
&& rm -rf /var/lib/apt/lists/*
8080

8181
ARG GZ_VERSION="harmonic"
@@ -186,18 +186,18 @@ RUN mkdir -p ~/.gazebo/models \
186186
# Cache Gazebo Fuel models
187187
COPY --from=gz_model_cacher --chown=$USER:$GROUP /tmp/ws/ $USER_WS/
188188
RUN find src -name '*.world' -or -name '*.sdf' | \
189-
grep -Roh -e 'https://fuel.gazebosim.org[^<]*' src | \
190-
sort | uniq | xargs -I{} gz fuel download -u {}
189+
grep -Roh -e 'https://fuel.gazebosim.org[^<]*' src | \
190+
sort | uniq | xargs -I{} gz fuel download -u {}
191191

192192
ENV GZ_SIM_RESOURCE_PATH=/home/$USER/.gazebo/models
193193

194194
#
195195
# Install OpenVDB files
196196
COPY --from=openvdb-builder --chown=$USER:$GROUP /opt/openvdb/ /opt/openvdb
197197
RUN cd /opt/openvdb/build \
198-
&& sudo make install \
199-
&& sudo rm -rf /opt/openvdb
198+
&& sudo make install \
199+
&& sudo rm -rf /opt/openvdb
200200
RUN sudo dpkg -r libopenvdb8.1 \
201-
libopenvdb-dev
201+
libopenvdb-dev
202202

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

experimental/beluga_demo_mh_amcl/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Beluga Multi-Hypotheses AMCL demo
22

3-
## How the algorithm work
3+
## How the algorithm works
44

55
Traditional AMCL is extended by managing multiple populations of particles (each population is a hypothesis). Particles are created, destroyed, or merged based on their consistency with sensory data, choosing the best fitting hypothesis in each iteration.
66

@@ -23,8 +23,8 @@ The map-matching is done with 4 levels of resolution to improve computational co
2323

2424
### Steps for managing the hypotheses
2525

26-
1. Start: At the start of the robot operation, P(0,t0) (first set of particles, hypothesis) is started at the robot’s initial position, if known.
27-
2. Creation: Periodically, a cascade map matching algorithm is used to determine which map positions the latest sensory readings could be obtained. If a position with a high match is found (high hit field), a new P(k,t) is started at this position.
26+
1. Start: At the start of the robot operation, P(0,t0) (first set of particles, hypothesis) is started at the robot initial position, if known.
27+
2. Creation: Periodically, a cascade map matching algorithm is used to determine in which map positions the latest sensor readings could have been obtained. If a position with a high match is found (high hit field), a new P(k,t) is initialized at this position.
2828
3. Destruction: If Quality(P(k,t)) is less than some threshold and |Pt| > 0, then P(k,t) is considered to be wrong, and it is removed.
2929
4. Merge: Even if two P(i,t) and P(j,t), start at different positions, they could end up converging to the same position. In this case, they are mixed in a P(k,t) containing the particles with more weight.
3030

experimental/beluga_demo_mh_amcl/config/mh_amcl_params.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,5 @@ mh_amcl:
3535
# Bond timeout
3636
bond_timeout: 8.0
3737

38-
# Standard deviation for the LiDAR
39-
distance_perception_error: 0.01
38+
# Standard deviation for the LiDAR (shouldn't be below 0.2 for the correct computation of the qualities)
39+
distance_perception_error: 0.5

experimental/beluga_demo_mh_amcl/include/beluga_demo_mh_amcl/mh_amcl.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ namespace mh_amcl
5151
message_filters::Subscriber<sensor_msgs::msg::LaserScan, rclcpp_lifecycle::LifecycleNode>;
5252
using LaserScanFilter = tf2_ros::MessageFilter<sensor_msgs::msg::LaserScan>;
5353

54+
// TODO (jesus): Review if the lifecycle approach is worth it or use a basic ROS 2 node
5455
/**
5556
* MH_AMCL_Node class
5657
*
@@ -109,6 +110,7 @@ namespace mh_amcl
109110
rclcpp::TimerBase::SharedPtr publish_particles_timer_;
110111
rclcpp::TimerBase::SharedPtr publish_position_timer_;
111112

113+
// TODO (jesus): This should be a struct of parameters, also merge with the 'particles_distribution' params
112114
// Configurable params
113115
bool use_sim_time_;
114116
int max_hypotheses_;

experimental/beluga_demo_mh_amcl/include/beluga_demo_mh_amcl/particles_distribution.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ namespace mh_amcl
161161
// Costmap and Likelihood Field Sensor model
162162
std::shared_ptr<beluga_ros::OccupancyGrid> costmap_;
163163

164+
// TODO (jesus): This should be a struct of parameters
164165
// MH-AMCL Parameters
165166
int max_particles_;
166167
int min_particles_;

experimental/beluga_demo_mh_amcl/include/beluga_demo_mh_amcl/reweight_and_update_hits_action.hpp

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717

1818
#include <range/v3/functional/bind_back.hpp>
1919

20-
#include <sensor_msgs/msg/laser_scan.hpp>
2120
#include <beluga_ros/occupancy_grid.hpp>
21+
#include <sensor_msgs/msg/laser_scan.hpp>
2222
#include <tf2/transform_datatypes.h>
2323
#include <tf2_geometry_msgs/tf2_geometry_msgs.hpp>
2424

@@ -57,7 +57,7 @@ namespace mh_amcl::actions
5757

5858
tf2::Transform laser2point = utils::get_transform_to_read(scan, static_cast<int>(j));
5959
double err_m = utils::get_error_distance_to_obstacle(
60-
map2bf, base_to_laser_tf, laser2point, scan, costmap, distance_perception_error);
60+
map2bf, base_to_laser_tf, laser2point, scan, costmap);
6161

6262
if (!std::isinf(err_m))
6363
{
@@ -73,9 +73,16 @@ namespace mh_amcl::actions
7373
if (valid_beams > 0)
7474
{
7575
particle.weight += total_prob;
76-
// TODO: Review if hits should be computed like this
7776
particle.hits = total_prob / static_cast<float>(scan.ranges.size());
7877
}
78+
// TODO: Review if hits should be computed like this (not having good results so far)
79+
// // Update the particle's weight and hits using the average likelihood
80+
// if (valid_beams > 0)
81+
// {
82+
// const float average_likelihood = total_prob / static_cast<float>(valid_beams);
83+
// particle.weight *= average_likelihood;
84+
// particle.hits = average_likelihood;
85+
// }
7986
else
8087
{
8188
// Assign a small weight and 0 hits if no valid beams
@@ -104,4 +111,4 @@ namespace mh_amcl::actions
104111

105112
} // namespace mh_amcl::actions
106113

107-
#endif // MH_AMCL__REWEIGHT_UPDATE_HITS_ACTION_HPP_
114+
#endif // MH_AMCL__REWEIGHT_UPDATE_HITS_ACTION_HPP_

experimental/beluga_demo_mh_amcl/include/beluga_demo_mh_amcl/utils.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ namespace utils
122122
const tf2::Transform &map2bf, const tf2::Transform &bf2laser,
123123
const tf2::Transform &laser2point,
124124
const sensor_msgs::msg::LaserScan &scan,
125-
std::shared_ptr<beluga_ros::OccupancyGrid> costmap, double o);
125+
std::shared_ptr<beluga_ros::OccupancyGrid> costmap);
126126

127127
signed char get_cost(const tf2::Transform &transform,
128128
std::shared_ptr<beluga_ros::OccupancyGrid> costmap);

experimental/beluga_demo_mh_amcl/src/mh_amcl/utils.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -239,8 +239,7 @@ namespace utils
239239
double get_error_distance_to_obstacle(
240240
const tf2::Transform &map2bf, const tf2::Transform &bf2laser,
241241
const tf2::Transform &laser2point, const sensor_msgs::msg::LaserScan &scan,
242-
std::shared_ptr<beluga_ros::OccupancyGrid> costmap,
243-
double distance_perception_error)
242+
std::shared_ptr<beluga_ros::OccupancyGrid> costmap)
244243
{
245244
if (std::isinf(laser2point.getOrigin().x()) ||
246245
std::isnan(laser2point.getOrigin().x()))
@@ -261,7 +260,9 @@ namespace utils
261260
}
262261

263262
float dist = costmap->resolution();
264-
while (dist < (3.0 * distance_perception_error))
263+
// TODO (jesus): Review value of this constant and how it affects performance and result of the filter
264+
const float max_obstacle_search_distance = 0.3;
265+
while (dist < max_obstacle_search_distance)
265266
{
266267
uvector.setOrigin(unit * dist);
267268
// For positive

0 commit comments

Comments
 (0)