Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Extend odometry tests for steering controllers #1606

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

AdityaPawar162
Copy link
Contributor

This PR addresses issue #1456 by:
1.Tracking odometry values before and after the timeout.
2.Ensuring position values remain stable.
3.Verifying that linear and angular velocities reset to zero.

Copy link

codecov bot commented Mar 24, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 85.15%. Comparing base (eca84fa) to head (590f747).
Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1606      +/-   ##
==========================================
+ Coverage   85.10%   85.15%   +0.05%     
==========================================
  Files         123      123              
  Lines       11699    11712      +13     
  Branches      995      995              
==========================================
+ Hits         9956     9973      +17     
+ Misses       1432     1428       -4     
  Partials      311      311              
Flag Coverage Δ
unittests 85.15% <100.00%> (+0.05%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...library/test/test_steering_controllers_library.cpp 100.00% <100.00%> (ø)

... and 5 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Contributor

@christophfroehlich christophfroehlich left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for giving a try! But apparently, this does not test the original issue. What I tried: Run colcon build and test with this version, and then with
git revert 2375aca
It succeeds in both cases.

@AdityaPawar162
Copy link
Contributor Author

Hi @christophfroehlich,
I have updated the function as per suggested changes,I have also added a check for the last_linear_velocity_ and last_angular_velocity_.

@christophfroehlich
Copy link
Contributor

tests are failing now

@AdityaPawar162
Copy link
Contributor Author

tests are failing now

Sorry , for the incorrect push.

@AdityaPawar162
Copy link
Contributor Author

Hi @christophfroehlich ,
I have pushed the correct changes, please do suggest any changes to be made.

Copy link
Contributor

@christophfroehlich christophfroehlich left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, the tests for the last*velocity now fails without the bugfix.

I had a look now why the other test does not fail:
1.) The test is in open_loop=false mode
2.) The update_odometry call in update_and_write_commands is overriden in the TestableSteeringControllersLibrary and does not update the odometry class.

We should add a new testfile with a different yaml (see add_rostest_with_parameters_gmock in the CMakeLists file) and add something like this in the TestableSteeringControllersLibrary::update_odometry (from bicycle_steering_controller)

  if (params_.open_loop)
  {
    odometry_.update_open_loop(last_linear_velocity_, last_angular_velocity_, period.seconds());
  }

@AdityaPawar162
Copy link
Contributor Author

Thanks, the tests for the last*velocity now fails without the bugfix.

I had a look now why the other test does not fail: 1.) The test is in open_loop=false mode 2.) The update_odometry call in update_and_write_commands is overriden in the TestableSteeringControllersLibrary and does not update the odometry class.

We should add a new testfile with a different yaml (see add_rostest_with_parameters_gmock in the CMakeLists file) and add something like this in the TestableSteeringControllersLibrary::update_odometry (from bicycle_steering_controller)

  if (params_.open_loop)
  {
    odometry_.update_open_loop(last_linear_velocity_, last_angular_velocity_, period.seconds());
  }

ok

@AdityaPawar162
Copy link
Contributor Author

Hi @christophfroehlich,
As per your suggestion, I created a new YAML file with open_loop set to true and added a separate test file named test_steering_controllers_open_library. I also modified the TestableSteeringControllersLibrary::update_geometry function. However, I'm unsure why the builds are failing.

Copy link
Contributor

@christophfroehlich christophfroehlich left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See my other comments. With these changes, the test runs but fails with

3: /workspaces/ros2_rolling_ws/src/ros2_controllers/steering_controllers_library/test/test_steering_controllers_library.cpp:173: Failure
3: The difference between controller_->command_interfaces_[2].get_value() and 0.575875 is 0.071721078654024661, which exceeds 1e-6, where
3: controller_->command_interfaces_[2].get_value() evaluates to 0.50415392134597536,
3: 0.575875 evaluates to 0.57587500000000003, and
3: 1e-6 evaluates to 9.9999999999999995e-07.
3: 
3: /workspaces/ros2_rolling_ws/src/ros2_controllers/steering_controllers_library/test/test_steering_controllers_library.cpp:174: Failure
3: The difference between controller_->command_interfaces_[3].get_value() and 0.575875 is 0.092000372941643649, which exceeds 1e-6, where
3: controller_->command_interfaces_[3].get_value() evaluates to 0.66787537294164367,
3: 0.575875 evaluates to 0.57587500000000003, and
3: 1e-6 evaluates to 9.9999999999999995e-07.
3: 
3: /workspaces/ros2_rolling_ws/src/ros2_controllers/steering_controllers_library/test/test_steering_controllers_library.cpp:239: Failure
3: The difference between controller_->command_interfaces_[2].get_value() and 0.575875 is 0.071721078654024661, which exceeds 1e-6, where
3: controller_->command_interfaces_[2].get_value() evaluates to 0.50415392134597536,
3: 0.575875 evaluates to 0.57587500000000003, and
3: 1e-6 evaluates to 9.9999999999999995e-07.
3: 
3: /workspaces/ros2_rolling_ws/src/ros2_controllers/steering_controllers_library/test/test_steering_controllers_library.cpp:240: Failure
3: The difference between controller_->command_interfaces_[3].get_value() and 0.575875 is 0.092000372941643649, which exceeds 1e-6, where
3: controller_->command_interfaces_[3].get_value() evaluates to 0.66787537294164367,
3: 0.575875 evaluates to 0.57587500000000003, and
3: 1e-6 evaluates to 9.9999999999999995e-07.

I'm not sure why these are different in open_loop mode, but haven't investigated further now

@AdityaPawar162
Copy link
Contributor Author

Hi @christophfroehlich,
I have made suggested changes, please do take a look.

Copy link
Contributor

@christophfroehlich christophfroehlich left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests are failing now with the output I posted above. Please have a look why this differs in open-loop mode

@christophfroehlich
Copy link
Contributor

While checking the test class, I see that there are some unused/duplicate constants.

Could you clean them up as well please?

static constexpr double WHEELBASE_ = 3.24644;
static constexpr double FRONT_WHEEL_TRACK_ = 2.12321;
static constexpr double REAR_WHEEL_TRACK_ = 1.76868;
static constexpr double FRONT_WHEELS_RADIUS_ = 0.45;
static constexpr double REAR_WHEELS_RADIUS_ = 0.45;

double reference_timeout_ = 2.0;
bool front_steering_ = true;
bool open_loop_ = false;
unsigned int velocity_rolling_window_size_ = 10;

std::vector<std::string> joint_names_ = {
rear_wheels_names_[0], rear_wheels_names_[1], front_wheels_names_[0], front_wheels_names_[1]};
std::vector<std::string> rear_wheels_preceeding_names_ = {
"pid_controller/rear_right_wheel_joint", "pid_controller/rear_left_wheel_joint"};
std::vector<std::string> front_wheels_preceeding_names_ = {
"pid_controller/front_right_steering_joint", "pid_controller/front_left_steering_joint"};
std::vector<std::string> preceeding_joint_names_ = {
rear_wheels_preceeding_names_[0], rear_wheels_preceeding_names_[1],
front_wheels_preceeding_names_[0], front_wheels_preceeding_names_[1]};

double wheelbase_ = 3.24644;
double front_wheel_track_ = 2.12321;
double rear_wheel_track_ = 1.76868;
double front_wheels_radius_ = 0.45;
double rear_wheels_radius_ = 0.45;

std::string preceeding_prefix_ = "pid_controller";


if (params_.front_steering)
// calculate new commands if not in timeout
if (!timeout)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see the necessity of this change.
In case of timeout it SHOULD set the appropriate commands see L397, L401 or L409/413, respectively.

Copy link
Contributor Author

@AdityaPawar162 AdityaPawar162 Mar 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, I specifically wanted to update traction_commands and steering_commands when the timeout is false, so I thought there is a need to add this
auto [traction_commands, steering_commands] = odometry_.get_commands( reference_interfaces_[0], reference_interfaces_[1], params_.open_loop, params_.reduce_wheel_speed_until_steering_reached); inside the flag.

@AdityaPawar162
Copy link
Contributor Author

static constexpr double WHEELBASE_ = 3.24644;
static constexpr double FRONT_WHEEL_TRACK_ = 2.12321;
static constexpr double REAR_WHEEL_TRACK_ = 1.76868;
static constexpr double FRONT_WHEELS_RADIUS_ = 0.45;
static constexpr double REAR_WHEELS_RADIUS_ = 0.45;

This is getting used in the function configure_odometry
controller_interface::CallbackReturn configure_odometry()
{
set_interface_numbers(NR_STATE_ITFS, NR_CMD_ITFS, NR_REF_ITFS);
odometry_.set_wheel_params(FRONT_WHEELS_RADIUS_, WHEELBASE_, REAR_WHEEL_TRACK_);
odometry_.set_odometry_type(steering_odometry::ACKERMANN_CONFIG);
return controller_interface::CallbackReturn::SUCCESS;
}

@christophfroehlich
Copy link
Contributor

This is getting used in the function configure_odometry

only FRONT_WHEELS_RADIUS_, WHEELBASE_, REAR_WHEEL_TRACK_

@AdityaPawar162
Copy link
Contributor Author

Hi @christophfroehlich,
The joint_command_values are hardcoded to 2.2 and 4.4, I think so because of this the steering angle is not getting updated ?

std::array<double, 4> joint_command_values_ = {{1.1, 3.3, 2.2, 4.4}};

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants