Class Amcl
Defined in File amcl.hpp
Class Documentation
-
class Amcl
Implementation of the 2D Adaptive Monte Carlo Localization (AMCL) algorithm. Generic two-dimensional implementation of the Adaptive Monte Carlo Localization (AMCL) algorithm in 2D.
Public Types
-
using motion_model_variant = std::variant<beluga::DifferentialDriveModel2d, beluga::OmnidirectionalDriveModel, beluga::StationaryModel>
Motion model variant type for runtime selection support.
-
using sensor_model_variant = std::variant<beluga::LikelihoodFieldModel<beluga_ros::OccupancyGrid>, beluga::BeamSensorModel<beluga_ros::OccupancyGrid>>
Sensor model variant type for runtime selection support.
-
using execution_policy_variant = std::variant<std::execution::sequenced_policy, std::execution::parallel_policy>
Execution policy variant type for runtime selection support.
Public Functions
-
Amcl(beluga_ros::OccupancyGrid map, motion_model_variant motion_model, sensor_model_variant sensor_model, const AmclParams ¶ms, execution_policy_variant execution_policy)
Constructor.
- Parameters:
map – Occupancy grid map.
motion_model – Variant of motion model.
sensor_model – Variant of sensor model.
params – Parameters for AMCL implementation.
execution_policy – Variant of execution policy.
-
inline const auto &particles() const
Returns a reference to the current set of particles.
-
template<class Distribution>
inline void initialize(Distribution distribution) Initialize particles using a custom distribution.
-
inline void initialize(Sophus::SE2d pose, Sophus::Matrix3d covariance)
Initialize particles with a given pose and covariance.
- Throws:
std::runtime_error – If the provided covariance is invalid.
-
inline void initialize_from_map()
Initialize particles using the default map distribution.
-
void update_map(beluga_ros::OccupancyGrid map)
Update the map used for localization.
-
auto update(Sophus::SE2d base_pose_in_odom, beluga_ros::LaserScan laser_scan) -> std::optional<std::pair<Sophus::SE2d, Sophus::Matrix3d>>
Update particles based on motion and sensor information.
This method performs a particle filter update step using motion and sensor data. It evaluates whether an update is necessary based on the configured update policy and the force_update flag. If an update is required, the motion model and sensor model updates are applied to the particles, and the particle weights are adjusted accordingly. Also, according to the configured resampling policy, the particles are resampled to maintain diversity and prevent degeneracy.
- Parameters:
base_pose_in_odom – Base pose in the odometry frame.
laser_scan – Laser scan data.
- Returns:
An optional pair containing the estimated pose and covariance after the update, or std::nullopt if no update was performed.
-
inline void force_update()
Force a manual update of the particles on the next iteration of the filter.
-
using motion_model_variant = std::variant<beluga::DifferentialDriveModel2d, beluga::OmnidirectionalDriveModel, beluga::StationaryModel>