Skip to content

Add 6dof support for velocity smoother #5243

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

mini-1235
Copy link
Contributor


Basic Info

Info Please fill out this column
Ticket(s) this addresses #5238
Primary OS tested on (Ubuntu, MacOS, Windows)
Robotic platform tested on (Steve's Robot, gazebo simulation of Tally, hardware turtlebot)
Does this PR contain AI generated software? (No; Yes and it is marked inline in the code)

Description of contribution in a few bullet points

Description of documentation updates required from your changes

ros-navigation/docs.nav2.org#706

Description of how this change was tested


Future work that may be required in bullet points

For Maintainers:

  • Check that any new parameters added are updated in docs.nav2.org
  • Check that any significant change is added to the migration guide
  • Check that any new features OR changes to existing behaviors are reflected in the tuning guide
  • Check that any new functions have Doxygen added
  • Check that any new features have test coverage
  • Check that any new plugins is added to the plugins page
  • If BT Node, Additionally: add to BT's XML index of nodes for groot, BT package's readme table, and BT library lists

Signed-off-by: mini-1235 <mauricepurnawan@gmail.com>
@mini-1235 mini-1235 marked this pull request as draft June 6, 2025 15:25
@mini-1235
Copy link
Contributor Author

Still adding unit tests

Copy link

codecov bot commented Jun 6, 2025

Codecov Report

Attention: Patch coverage is 46.83544% with 42 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
nav2_velocity_smoother/src/velocity_smoother.cpp 46.83% 42 Missing ⚠️
Files with missing lines Coverage Δ
nav2_velocity_smoother/src/velocity_smoother.cpp 80.06% <46.83%> (-13.50%) ⬇️

... 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
Member

@SteveMacenski SteveMacenski left a comment

Choose a reason for hiding this comment

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

There's alot of test gaps, but beyond that LGTM!

The tests for this node are remarkably simple due to its pointedness: https://github.com/ros-navigation/navigation2/blob/main/nav2_velocity_smoother/test/test_velocity_smoother.cpp

I think you just need to add a couple of test cases doing 6DOF and you should be good to go.

@@ -119,18 +119,23 @@ VelocitySmoother::on_configure(const rclcpp_lifecycle::State & state)
node->get_parameter("deadband_velocity", deadband_velocities_);
node->get_parameter("velocity_timeout", velocity_timeout_dbl);
velocity_timeout_ = rclcpp::Duration::from_seconds(velocity_timeout_dbl);
size_t size = max_velocities_.size();
Copy link
Member

Choose a reason for hiding this comment

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

I think the for (unsigned int i = 0; i != 3; i++) { above needs to be updated based on the size for the full 6DOF

{
RCLCPP_ERROR(
get_logger(),
"Invalid setting of kinematic and/or deadband limits!"
" All limits must be size of 3 representing (x, y, theta).");
" All limits must be size of 3 or 6");
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
" All limits must be size of 3 or 6");
" All limits must be size of 3 (x, y, theta) or 6 (x, y, z, r, p, y)");

@@ -333,15 +338,36 @@ void VelocitySmoother::smootherTimer()
}

// Apply absolute velocity restrictions to the command
command_->twist.linear.x = std::clamp(
if(!is_6dof_) {
command_->twist.linear.x = std::clamp(
command_->twist.linear.x, min_velocities_[0],
Copy link
Member

Choose a reason for hiding this comment

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

I think you have some formatting issues. The line extension after the std::clamp should have an intend. Ditto for this entire block

Copy link
Member

Choose a reason for hiding this comment

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

After going through the full thing, it looks like from this point to the end there's alot of lines that should have been indented that weren't from the original code and your added code. Please fix that :-)

RCLCPP_WARN(get_logger(), "Invalid size of parameter %s. Must be size 3",
param_name.c_str());
size_t size = is_6dof_ ? 6 : 3;
if (parameter.as_double_array().size() != 3 && parameter.as_double_array().size() != size) {
Copy link
Member

Choose a reason for hiding this comment

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

I don't understand the first check for 3. Shouldn't the second be enough? It shouldn't be reconfigurable to a different size. It should always be 3 or always be 6, I think

@mini-1235
Copy link
Contributor Author

Thanks Steve for the review, I will aim to complete this over the weekend

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.

2 participants