19#ifndef EASYNAV_NAVMAP_LOCALIZER__AMCLLOCALIZER_HPP_
20#define EASYNAV_NAVMAP_LOCALIZER__AMCLLOCALIZER_HPP_
24#include <Eigen/Geometry>
27#include "geometry_msgs/msg/pose_array.hpp"
28#include "geometry_msgs/msg/pose_with_covariance_stamped.hpp"
29#include "nav_msgs/msg/odometry.hpp"
31#include "tf2/LinearMath/Transform.hpp"
32#include "tf2_ros/transform_broadcaster.hpp"
34#include "navmap_core/NavMap.hpp"
36#include "easynav_core/LocalizerMethodBase.hpp"
51 ::navmap::NavCelId
last_cid = std::numeric_limits<uint32_t>::max();
85 void update_rt(NavState & nav_state)
override;
94 void update(NavState & nav_state)
override;
121 void publishTF(
const tf2::Transform & map2bf);
140 void predict(NavState & nav_state);
147 void correct(NavState & nav_state);
161 rclcpp::Publisher<geometry_msgs::msg::PoseWithCovarianceStamped>::SharedPtr
estimate_pub_;
164 rclcpp::Subscription<nav_msgs::msg::Odometry>::SharedPtr
odom_sub_;
215 tf2::Transform
odom_{tf2::Transform::getIdentity()};
double min_noise_yaw_
Minimum yaw noise threshold.
Definition AMCLLocalizer.hpp:201
void update(NavState &nav_state) override
General update of the localization state.
Definition AMCLLocalizer.cpp:515
std::shared_ptr< Bonxai::ProbabilisticMap > bonxai_map_
Internal static map.
Definition AMCLLocalizer.hpp:235
double top_keep_fraction_
Definition AMCLLocalizer.hpp:211
double min_noise_xy_
Minimum translation noise threshold.
Definition AMCLLocalizer.hpp:198
std::unique_ptr< tf2_ros::TransformBroadcaster > tf_broadcaster_
TF broadcaster to publish map to base_footprint transform.
Definition AMCLLocalizer.hpp:155
std::vector< Particle > particles_
List of particles representing the belief distribution.
Definition AMCLLocalizer.hpp:180
~AMCLLocalizer()
Destructor.
rclcpp::Time last_reseed_
Timestamp of the last reseed event.
Definition AMCLLocalizer.hpp:227
double reseed_time_
Time interval (in seconds) after which the particles should be reseeded.
Definition AMCLLocalizer.hpp:224
rclcpp::Publisher< geometry_msgs::msg::PoseWithCovarianceStamped >::SharedPtr estimate_pub_
Publisher for the estimated robot pose with covariance.
Definition AMCLLocalizer.hpp:161
void update_odom_from_tf()
Update odom from TFs instead of a odom topic.
Definition AMCLLocalizer.cpp:478
void update_rt(NavState &nav_state) override
Real-time update of the localization state.
Definition AMCLLocalizer.cpp:509
tf2::Transform pose_
Current estimated odometry-based pose.
Definition AMCLLocalizer.hpp:186
void publishEstimatedPose(const tf2::Transform &est_pose)
Publishes the estimated pose with covariance.
Definition AMCLLocalizer.cpp:1032
rclcpp::Time last_input_time_
Timestamp of the last input message (odometry or initial pose).
Definition AMCLLocalizer.hpp:230
rclcpp::Subscription< nav_msgs::msg::Odometry >::SharedPtr odom_sub_
Subscriber for odometry messages.
Definition AMCLLocalizer.hpp:164
double weights_tau_
Definition AMCLLocalizer.hpp:209
double noise_translation_to_rotation_
Coupling noise between translation and rotation.
Definition AMCLLocalizer.hpp:195
void publishTF(const tf2::Transform &map2bf)
Publishes a TF transform between map and base footprint.
Definition AMCLLocalizer.cpp:950
void odom_callback(nav_msgs::msg::Odometry::UniquePtr msg)
Callback for receiving odometry updates.
Definition AMCLLocalizer.cpp:470
tf2::Transform odom_
Last odometry transform received.
Definition AMCLLocalizer.hpp:215
tf2::Transform last_odom_
Previous odometry transform (used to compute deltas).
Definition AMCLLocalizer.hpp:218
void predict(NavState &nav_state)
Applies the motion model to update particle poses.
Definition AMCLLocalizer.cpp:525
nav_msgs::msg::Odometry get_pose()
Gets the current estimated pose as an Odometry message.
Definition AMCLLocalizer.cpp:1087
double noise_rotation_
Rotational noise standard deviation.
Definition AMCLLocalizer.hpp:192
std::size_t correct_max_points_
Definition AMCLLocalizer.hpp:208
std::mt19937 rng_
Random number generator used for sampling noise.
Definition AMCLLocalizer.hpp:183
rclcpp::Publisher< geometry_msgs::msg::PoseArray >::SharedPtr particles_pub_
Publisher for visualization of the particle cloud.
Definition AMCLLocalizer.hpp:158
void publishParticles()
Publishes the current set of particles.
Definition AMCLLocalizer.cpp:966
::navmap::NavCelId last_cid_
Definition AMCLLocalizer.hpp:236
virtual void on_initialize() override
Initializes the localization method.
Definition AMCLLocalizer.cpp:365
tf2::Transform getEstimatedPose() const
Gets the current estimated pose as a transform.
Definition AMCLLocalizer.cpp:986
double noise_translation_
Translational noise standard deviation.
Definition AMCLLocalizer.hpp:189
bool initialized_odom_
Flag indicating if the odometry has been initialized.
Definition AMCLLocalizer.hpp:221
double downsampled_cloud_size_
Definition AMCLLocalizer.hpp:212
void reseed()
Re-initializes the particle cloud if necessary.
Definition AMCLLocalizer.cpp:802
void correct(NavState &nav_state)
Applies the sensor model to update particle weights.
Definition AMCLLocalizer.cpp:690
double inflation_prob_min_
Definition AMCLLocalizer.hpp:207
AMCLLocalizer()
Default constructor.
Definition AMCLLocalizer.cpp:347
double inflation_stddev_
Definition AMCLLocalizer.hpp:206
bool compute_odom_from_tf_
Whether to use TFs to compute odom.
Definition AMCLLocalizer.hpp:204
void initializeParticles()
Initializes the set of particles.
Definition AMCLLocalizer.hpp:41
Provides a mapping for often used cost values.
Definition cost_values.hpp:41
Structure representing a single particle in the AMCL algorithm.
Definition AMCLLocalizer.hpp:45
::navmap::NavCelId last_cid
Definition AMCLLocalizer.hpp:51
float hits
Number of sensor matches (hits) for this particle.
Definition AMCLLocalizer.hpp:47
double weight
Normalized importance weight of the particle.
Definition AMCLLocalizer.hpp:49
float possible_hits
Maximum number of possible hits.
Definition AMCLLocalizer.hpp:48
tf2::Transform pose
Estimated pose of the particle.
Definition AMCLLocalizer.hpp:46
std::size_t last_surface
Definition AMCLLocalizer.hpp:52