Skip to content

Commit 2375aca

Browse files
Fix open-loop odometry in case of ref timeout (#1454)
Co-authored-by: Dr. Denis <[email protected]>
1 parent 97d7475 commit 2375aca

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

steering_controllers_library/src/steering_controllers_library.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -378,23 +378,23 @@ controller_interface::return_type SteeringControllersLibrary::update_and_write_c
378378

379379
if (!std::isnan(reference_interfaces_[0]) && !std::isnan(reference_interfaces_[1]))
380380
{
381-
// store (for open loop odometry) and set commands
382-
last_linear_velocity_ = reference_interfaces_[0];
383-
last_angular_velocity_ = reference_interfaces_[1];
384-
385381
const auto age_of_last_command = time - (*(input_ref_.readFromRT()))->header.stamp;
386382
const auto timeout =
387383
age_of_last_command > ref_timeout_ && ref_timeout_ != rclcpp::Duration::from_seconds(0);
388384

385+
// store (for open loop odometry) and set commands
386+
last_linear_velocity_ = timeout ? 0.0 : reference_interfaces_[0];
387+
last_angular_velocity_ = timeout ? 0.0 : reference_interfaces_[1];
388+
389389
auto [traction_commands, steering_commands] = odometry_.get_commands(
390-
last_linear_velocity_, last_angular_velocity_, params_.open_loop,
390+
reference_interfaces_[0], reference_interfaces_[1], params_.open_loop,
391391
params_.reduce_wheel_speed_until_steering_reached);
392392

393393
if (params_.front_steering)
394394
{
395395
for (size_t i = 0; i < params_.rear_wheels_names.size(); i++)
396396
{
397-
command_interfaces_[i].set_value(timeout ? 0. : traction_commands[i]);
397+
command_interfaces_[i].set_value(timeout ? 0.0 : traction_commands[i]);
398398
}
399399
for (size_t i = 0; i < params_.front_wheels_names.size(); i++)
400400
{
@@ -406,7 +406,7 @@ controller_interface::return_type SteeringControllersLibrary::update_and_write_c
406406
{
407407
for (size_t i = 0; i < params_.front_wheels_names.size(); i++)
408408
{
409-
command_interfaces_[i].set_value(timeout ? 0. : traction_commands[i]);
409+
command_interfaces_[i].set_value(timeout ? 0.0 : traction_commands[i]);
410410
}
411411
for (size_t i = 0; i < params_.rear_wheels_names.size(); i++)
412412
{

0 commit comments

Comments
 (0)