@@ -51,6 +51,9 @@ class AmclNodeUnderTest : public beluga_amcl::AmclNode {
5151
5252 // / Expose propagation timer callback for testing
5353 void propagation_timer_callback () { AmclNode::propagation_timer_callback (); }
54+
55+ // / Expose odometry_motion_buffer_ for testing
56+ const auto & odometry_motion_buffer () const { return odometry_motion_buffer_; }
5457};
5558
5659// / Base node fixture class with common utilities.
@@ -705,7 +708,7 @@ TEST_F(TestNode, TransformValue) {
705708}
706709
707710TEST_F (TestNode, PropagationTimerNotCreatedWhenDisabled) {
708- amcl_node_->set_parameter (rclcpp::Parameter{" increase_propagation " , 0.0 });
711+ amcl_node_->set_parameter (rclcpp::Parameter{" propagation_rate " , 0.0 });
709712 amcl_node_->configure ();
710713 amcl_node_->activate ();
711714 tester_node_->publish_map ();
@@ -716,7 +719,7 @@ TEST_F(TestNode, PropagationTimerNotCreatedWhenDisabled) {
716719}
717720
718721TEST_F (TestNode, PropagationTimerCreatedWhenEnabled) {
719- amcl_node_->set_parameter (rclcpp::Parameter{" increase_propagation " , 10.0 });
722+ amcl_node_->set_parameter (rclcpp::Parameter{" propagation_rate " , 10.0 });
720723 amcl_node_->configure ();
721724 amcl_node_->activate ();
722725 tester_node_->publish_map ();
@@ -727,32 +730,45 @@ TEST_F(TestNode, PropagationTimerCreatedWhenEnabled) {
727730}
728731
729732TEST_F (TestNode, PropagationTimerIntegrationTest) {
730- amcl_node_->set_parameter (rclcpp::Parameter{" increase_propagation " , 5.0 });
733+ amcl_node_->set_parameter (rclcpp::Parameter{" propagation_rate " , 5.0 });
731734 amcl_node_->set_parameter (rclcpp::Parameter{" set_initial_pose" , true });
732735 amcl_node_->configure ();
733736 amcl_node_->activate ();
734737 tester_node_->publish_map ();
735738 ASSERT_TRUE (wait_for_initialization ());
736739
740+ tester_node_->publish_odom_to_base_tf (Sophus::SE2d{});
741+
742+ // Wait for several timer executions to fill the odometry buffer
743+ spin_for (500ms, amcl_node_, tester_node_);
744+
745+ // Check that odometry_motion_buffer_ has values before laser scan
746+ EXPECT_FALSE (amcl_node_->odometry_motion_buffer ().empty ());
747+ const auto buffer_size_before = amcl_node_->odometry_motion_buffer ().size ();
748+
737749 // Configure TF so get_base_pose_in_odom works by publishing a laser scan with transform
738750 tester_node_->publish_laser_scan_with_odom_to_base (Sophus::SE2d{});
739751
740- // Wait for several timer executions
741- spin_for (500ms, amcl_node_, tester_node_);
752+ // Wait for the callback to process the buffer
753+ spin_for (100ms, amcl_node_, tester_node_);
754+
755+ // Check that odometry_motion_buffer_ was consumed up to the lidar timestamp
756+ EXPECT_LT (amcl_node_->odometry_motion_buffer ().size (), buffer_size_before);
742757
743758 // Verify particle filter still exists and has particles
744759 EXPECT_TRUE (amcl_node_->particle_filter () != nullptr );
745760 EXPECT_GT (amcl_node_->particle_filter ()->particles ().size (), 0UL );
746761}
747762
748763TEST_F (TestNode, PropagationTimerWithoutParticles) {
764+ // Verify that particle filter remains uninitialized
765+ EXPECT_FALSE (amcl_node_->particle_filter () != nullptr );
766+
749767 // Call propagation timer callback when particle filter is not initialized
750- // This should trigger early return due to !particle_filter_ check
751768 amcl_node_->propagation_timer_callback ();
752769
753- // Verify that particle filter remains uninitialized
754- // The callback should have returned early without creating the filter
755- EXPECT_FALSE (amcl_node_->particle_filter () != nullptr );
770+ // The callback should have returned early without filling the queue
771+ EXPECT_TRUE (amcl_node_->odometry_motion_buffer ().empty ());
756772}
757773
758774TEST_F (TestNode, PropagationTimerWithoutBaseToOdom) {
@@ -766,17 +782,12 @@ TEST_F(TestNode, PropagationTimerWithoutBaseToOdom) {
766782 EXPECT_TRUE (amcl_node_->is_initialized ());
767783 EXPECT_TRUE (amcl_node_->particle_filter () != nullptr );
768784
769- // Capture the current particles before calling the propagation callback
770- const auto particles_before = amcl_node_->particle_filter ()->particles ();
771- EXPECT_GT (particles_before.size (), 0UL );
772-
773785 // Call propagation callback without any transform data
774786 // This should return early because get_base_pose_in_odom() will fail
775787 amcl_node_->propagation_timer_callback ();
776788
777- // Verify particles remain unchanged since no propagation occurred
778- const auto particles_after = amcl_node_->particle_filter ()->particles ();
779- EXPECT_EQ (particles_before.size (), particles_after.size ());
789+ // The callback should have returned early without filling the queue
790+ EXPECT_TRUE (amcl_node_->odometry_motion_buffer ().empty ());
780791}
781792
782793class TestParameterValue : public ::testing::TestWithParam<rclcpp::Parameter> {};
0 commit comments