Skip to content

Commit 91c84ff

Browse files
committed
test: verify open loop timeout using internal state to avoid message lag
Signed-off-by: Ishan1923 <ecdev4ishan@gmail.com>
1 parent 7e34a02 commit 91c84ff

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

steering_controllers_library/src/steering_controllers_library.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -657,8 +657,7 @@ controller_interface::return_type SteeringControllersLibrary::update_and_write_c
657657
RCLCPP_DEBUG(
658658
logger, "Unable to retrieve %s for steering wheel %zu",
659659
!state_interface_value_op.has_value() ? "state interface value"
660-
: "command interface value",
661-
i);
660+
: "command interface value", i);
662661
}
663662
else
664663
{

steering_controllers_library/test/test_steering_controllers_library.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,9 @@ TEST_F(SteeringControllersLibraryTest, test_position_feedback_ref_timeout)
268268
msg.twist.angular.z = TEST_ANGULAR_VELOCITY_Z;
269269
controller_->input_ref_.set(msg);
270270

271+
EXPECT_GT(controller_->command_interfaces_[0].get_optional().value(), 0.0);
272+
EXPECT_GT(controller_->command_interfaces_[1].get_optional().value(), 0.0);
273+
271274
// age_of_last_command > ref_timeout_
272275
ASSERT_FALSE(age_of_last_command <= controller_->ref_timeout_);
273276
ASSERT_EQ(controller_->input_ref_.get().twist.linear.x, TEST_LINEAR_VELOCITY_X);
@@ -363,6 +366,9 @@ TEST_F(SteeringControllersLibraryTest, test_velocity_feedback_ref_timeout)
363366

364367
age_of_last_command = controller_->get_node()->now() - controller_->input_ref_.get().header.stamp;
365368

369+
EXPECT_GT(controller_->command_interfaces_[0].get_optional().value(), 0.0);
370+
EXPECT_GT(controller_->command_interfaces_[1].get_optional().value(), 0.0);
371+
366372
// age_of_last_command > ref_timeout_
367373
ASSERT_FALSE(age_of_last_command <= controller_->ref_timeout_);
368374
ASSERT_EQ(controller_->input_ref_.get().twist.linear.x, TEST_LINEAR_VELOCITY_X);
@@ -467,7 +473,6 @@ TEST_F(SteeringControllersLibraryTest, test_open_loop_update_timeout)
467473

468474
EXPECT_DOUBLE_EQ(controller_->last_linear_velocity_, 0.0);
469475

470-
EXPECT_DOUBLE_EQ(controller_->odom_state_msg_.twist.twist.linear.x, 0.0);
471476
}
472477

473478
int main(int argc, char ** argv)

0 commit comments

Comments
 (0)