Skip to content

Add AckermannDriveStamped control to steering library #1563

New issue

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

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

Already on GitHub? Sign in to your account

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

Conversation

wittenator
Copy link

@wittenator wittenator commented Mar 1, 2025

This PR adds the option to use steering angle and linear velocity for controllers that inherit from the steering library.

To send us a pull request, please:

  • Fork the repository.
  • Modify the source; please focus on the specific change you are contributing. If you also reformat all the code, it will be hard for us to focus on your change.
  • Ensure local tests pass. (colcon test and pre-commit run (requires you to install pre-commit by pip3 install pre-commit)
  • Commit to your fork using clear commit messages.
  • Send a pull request, answering any default questions in the pull request interface.
  • Pay attention to any automated CI failures reported in the pull request, and stay involved in the conversation.

@wittenator wittenator changed the title Add AckermannDriveStamped control to steering library WIP: Add AckermannDriveStamped control to steering library Mar 1, 2025
@wittenator
Copy link
Author

wittenator commented Mar 1, 2025

The tests on HEAD are currently broken, but I wanted to get this PR out in order to track progress.

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.

why WIP?
Please fix the failing jobs, start with the pre-commit and clang job.
The tests on the master branch are green.

@wittenator wittenator changed the title WIP: Add AckermannDriveStamped control to steering library Add AckermannDriveStamped control to steering library Apr 11, 2025
@wittenator
Copy link
Author

@christophfroehlich I fixed all the pre-commit checks and the colcon test checks. I think this should be ready for a first review now.

@wittenator
Copy link
Author

@christophfroehlich Since there is quite a bit of incoming movement in the steering controllers library and the odometry library. Are we holding off with this PR's addition until these parts stabilized again?

@christophfroehlich
Copy link
Contributor

there is only one which i have on the list to be merged soon #836. I try to review yours within the next days

@wittenator
Copy link
Author

No hurry, I need to fix the tests with the newest merge anyway. I'll ping you here, once I am done with this

@wittenator
Copy link
Author

wittenator commented Apr 26, 2025

@christophfroehlich I fixed the tests. This should be ready now

Copy link

codecov bot commented Apr 26, 2025

Codecov Report

Attention: Patch coverage is 91.28440% with 19 lines in your changes missing coverage. Please review.

Project coverage is 84.94%. Comparing base (8c649a3) to head (b42d13a).
Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
...llers_library/src/steering_controllers_library.cpp 76.08% 10 Missing and 1 partial ⚠️
...g_controller/src/ackermann_steering_controller.cpp 0.00% 2 Missing ⚠️
...ing_controller/src/bicycle_steering_controller.cpp 0.00% 2 Missing ⚠️
...st/test_steering_controllers_library_ackermann.hpp 97.22% 1 Missing and 1 partial ⚠️
...ng_controller/src/tricycle_steering_controller.cpp 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1563      +/-   ##
==========================================
+ Coverage   84.77%   84.94%   +0.17%     
==========================================
  Files         127      129       +2     
  Lines       12096    12277     +181     
  Branches     1036     1048      +12     
==========================================
+ Hits        10254    10429     +175     
- Misses       1503     1509       +6     
  Partials      339      339              
Flag Coverage Δ
unittests 84.94% <91.28%> (+0.17%) ⬆️

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

Files with missing lines Coverage Δ
...roller/test/test_ackermann_steering_controller.cpp 100.00% <100.00%> (ø)
...ntroller/test/test_bicycle_steering_controller.cpp 100.00% <100.00%> (ø)
...steering_controllers_library/steering_odometry.hpp 100.00% <ø> (ø)
...ring_controllers_library/src/steering_odometry.cpp 83.61% <100.00%> (+0.18%) ⬆️
...library/test/test_steering_controllers_library.cpp 100.00% <100.00%> (ø)
...library/test/test_steering_controllers_library.hpp 97.22% <100.00%> (ø)
...st/test_steering_controllers_library_ackermann.cpp 100.00% <100.00%> (ø)
...ontrollers_library/test/test_steering_odometry.cpp 100.00% <100.00%> (ø)
...troller/test/test_tricycle_steering_controller.cpp 100.00% <100.00%> (ø)
...g_controller/src/ackermann_steering_controller.cpp 48.97% <0.00%> (-1.03%) ⬇️
... and 4 more
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Contributor

mergify bot commented Apr 27, 2025

This pull request is in conflict. Could you fix it @wittenator?

Copy link
Contributor

@Juliaj Juliaj left a comment

Choose a reason for hiding this comment

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

The changes look good. A few suggestions for improvement: Could we update the relevant documentation to reflect this change? It would be valuable to add more test coverage for the new functionality - particularly in the three controllers modified by this PR.

front_wheel_track: 2.12321
rear_wheel_track: 1.76868
front_wheels_radius: 0.45
rear_wheels_radius: 0.45
Copy link
Contributor

@Juliaj Juliaj Apr 28, 2025

Choose a reason for hiding this comment

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

The names of these parameters have been changed, see #1166. Can we update these accordingly ?

@@ -5,6 +5,7 @@ test_steering_controllers_library:
open_loop: false
velocity_rolling_window_size: 10
position_feedback: false
twist_input: true
Copy link
Contributor

@Juliaj Juliaj Apr 28, 2025

Choose a reason for hiding this comment

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

Being relatively new to ros2_control development, I'm not entirely familiar with the established practices to define params ... I wanted to share a thought on the parameter naming and type choice. The current bool parameter doesn't call out the supported input options. An enum-based parameter named input_type could be an alternative but I'm not sure about the complexity that these introduce.

Copy link
Contributor

Choose a reason for hiding this comment

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

afaik there is no enum-like parameter feature in rclcpp. The only thing we could use is a string array, with a one_of<> validator.
I don't have a strong opinion here, maybe other reviewers have.

@@ -0,0 +1,215 @@
// Copyright (c) 2023, Stogl Robotics Consulting UG (haftungsbeschränkt)
Copy link
Contributor

Choose a reason for hiding this comment

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

nit, could we name this file as ..._library_ackerman_input.cpp ?

unsigned int velocity_rolling_window_size_ = 10;
bool position_feedback_ = false;
std::vector<std::string> rear_wheels_names_ = {"rear_right_wheel_joint", "rear_left_wheel_joint"};
std::vector<std::string> front_wheels_names_ = {
Copy link
Contributor

Choose a reason for hiding this comment

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

Similar to comments above on the changes introduced by #1166, please help update these variable names.

twist_input: {
type: bool,
default_value: true,
description: "Choose whether a Twist/TwistStamped or a AckermannDriveStamped message is used as input.",
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
description: "Choose whether a Twist/TwistStamped or a AckermannDriveStamped message is used as input.",
description: "Choose whether a TwistStamped or a AckermannDriveStamped message is used as input.",

we don't allow unstamped messages from jazzy on, or am I missing something?

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.

I have difficulties to follow your code with mixing phi and angular velocity, can you please clarify this for me? And some minor comments added to those of @Juliaj

@@ -167,3 +167,10 @@ steering_controllers_library:
position_feedback is true then ``HW_IF_POSITION`` is taken as interface type",
read_only: false,
}

twist_input: {
Copy link
Contributor

Choose a reason for hiding this comment

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

should we rename it to use_twist_input? This would make the params_.twist_input code more descriptive.

type: bool,
default_value: true,
description: "Choose whether a Twist/TwistStamped or a AckermannDriveStamped message is used as input.",
read_only: false,
Copy link
Contributor

Choose a reason for hiding this comment

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

does it make sense to change this when the controller is running?

@@ -180,16 +182,18 @@ bool SteeringOdometry::update_from_velocity(

double linear_velocity = get_linear_velocity_double_traction_axle(
right_traction_wheel_vel, left_traction_wheel_vel, steer_pos_);
const double angular_velocity = steer_pos_ * linear_velocity / wheel_base_;
Copy link
Contributor

Choose a reason for hiding this comment

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

oops, the std::tan was missing here?

@@ -252,7 +261,7 @@ std::tuple<std::vector<double>, std::vector<double>> SteeringOdometry::get_comma
}
#endif
// steering angle
phi = SteeringOdometry::convert_twist_to_steering_angle(v_bx, omega_bz);
phi = twist_input ? SteeringOdometry::convert_twist_to_steering_angle(v_bx, omega_bz) : omega_bz;
Copy link
Contributor

Choose a reason for hiding this comment

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

why is this phi=omega_bz for ackermann input?

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_ = {
Copy link
Contributor

Choose a reason for hiding this comment

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

Please fix the typos here, see #1655

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

std::array<std::string, 2> joint_reference_interfaces_ = {{"linear", "angular"}};
Copy link
Contributor

Choose a reason for hiding this comment

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

does it make sense to call this variable joint_?

{
/// Save last linear and angular velocity:
linear_ = v_bx;
angular_ = omega_bz;
angular_ = twist_input ? omega_bz : convert_steering_angle_to_angular_velocity(v_bx, omega_bz);
Copy link
Contributor

Choose a reason for hiding this comment

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

there is no steering angle here?

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

Successfully merging this pull request may close these issues.

3 participants