Skip to content

Commit cfac903

Browse files
Fix open-loop odometry in case of ref timeout (backport #1454) (#1460)
Co-authored-by: Christoph Fröhlich <christophfroehlich@users.noreply.github.com>
1 parent 67628b5 commit cfac903

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

steering_controllers_library/src/steering_controllers_library.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -432,22 +432,22 @@ controller_interface::return_type SteeringControllersLibrary::update_and_write_c
432432

433433
if (!std::isnan(reference_interfaces_[0]) && !std::isnan(reference_interfaces_[1]))
434434
{
435-
// store (for open loop odometry) and set commands
436-
last_linear_velocity_ = reference_interfaces_[0];
437-
last_angular_velocity_ = reference_interfaces_[1];
438-
439435
const auto age_of_last_command = time - (*(input_ref_.readFromRT()))->header.stamp;
440436
const auto timeout =
441437
age_of_last_command > ref_timeout_ && ref_timeout_ != rclcpp::Duration::from_seconds(0);
442438

439+
// store (for open loop odometry) and set commands
440+
last_linear_velocity_ = timeout ? 0.0 : reference_interfaces_[0];
441+
last_angular_velocity_ = timeout ? 0.0 : reference_interfaces_[1];
442+
443443
auto [traction_commands, steering_commands] = odometry_.get_commands(
444-
last_linear_velocity_, last_angular_velocity_, params_.open_loop,
444+
reference_interfaces_[0], reference_interfaces_[1], params_.open_loop,
445445
params_.reduce_wheel_speed_until_steering_reached);
446446
if (params_.front_steering)
447447
{
448448
for (size_t i = 0; i < params_.rear_wheels_names.size(); i++)
449449
{
450-
command_interfaces_[i].set_value(timeout ? 0. : traction_commands[i]);
450+
command_interfaces_[i].set_value(timeout ? 0.0 : traction_commands[i]);
451451
}
452452
for (size_t i = 0; i < params_.front_wheels_names.size(); i++)
453453
{
@@ -459,7 +459,7 @@ controller_interface::return_type SteeringControllersLibrary::update_and_write_c
459459
{
460460
for (size_t i = 0; i < params_.front_wheels_names.size(); i++)
461461
{
462-
command_interfaces_[i].set_value(timeout ? 0. : traction_commands[i]);
462+
command_interfaces_[i].set_value(timeout ? 0.0 : traction_commands[i]);
463463
}
464464
for (size_t i = 0; i < params_.rear_wheels_names.size(); i++)
465465
{

0 commit comments

Comments
 (0)