Skip to content

Commit

Permalink
Fix problem of atan2
Browse files Browse the repository at this point in the history
  • Loading branch information
kentohirogaki committed Oct 29, 2024
1 parent bad12df commit 7ca20de
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,13 @@ class ActionROS2Node : public BT::StatefulActionNode, public rclcpp::Node
}
double delta_x = obj.x - current_pose.value()->pose.position.x;
double delta_y = obj.y - current_pose.value()->pose.position.y;
const double minimum_delta = 0.1;
if (abs(delta_x) < minimum_delta) {
delta_x = minimum_delta;
}
if (abs(delta_y) < minimum_delta) {
delta_y = minimum_delta;
}
double theta = std::atan2(delta_y, delta_x);
geometry_msgs::msg::Pose p;
p.position.x = obj.x - distance * std::cos(theta);
Expand Down

0 comments on commit 7ca20de

Please sign in to comment.