Skip to content
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

fix bug in use of v_angular_min_in_place #4813

Merged
merged 1 commit into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion nav2_graceful_controller/src/graceful_controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ geometry_msgs::msg::Twist GracefulController::rotateToTarget(double angle_to_tar
geometry_msgs::msg::Twist vel;
vel.linear.x = 0.0;
vel.angular.z = params_->rotation_scaling_factor * angle_to_target * params_->v_angular_max;
vel.angular.z = std::copysign(1.0, vel.angular.z) * std::min(abs(vel.angular.z),
vel.angular.z = std::copysign(1.0, vel.angular.z) * std::max(abs(vel.angular.z),
params_->v_angular_min_in_place);
return vel;
}
Expand Down
13 changes: 13 additions & 0 deletions nav2_graceful_controller/test/test_graceful_controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,19 @@ TEST(GracefulControllerTest, rotateToTarget) {
// Check results: it must be a negative rotation
EXPECT_EQ(cmd_vel.linear.x, 0.0);
EXPECT_EQ(cmd_vel.angular.z, -0.25);

// Set very high v_angular_min_in_place velocity
results = params->set_parameters_atomically(
{rclcpp::Parameter("test.v_angular_min_in_place", 1.0)});
rclcpp::spin_until_future_complete(node->get_node_base_interface(), results);

// Set a new angle to target
angle_to_target = 0.5;
cmd_vel = controller->rotateToTarget(angle_to_target);

// Check results: positive velocity, at least as high as min_in_place
EXPECT_EQ(cmd_vel.linear.x, 0.0);
EXPECT_EQ(cmd_vel.angular.z, 1.0);
}

TEST(GracefulControllerTest, setSpeedLimit) {
Expand Down
Loading