-
Notifications
You must be signed in to change notification settings - Fork 1.5k
adding the fixes for navigate through poses terminating pre-maturely #5203
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
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -35,6 +35,7 @@ | |||||||||
} | ||||||||||
|
||||||||||
goals_blackboard_id_ = node->get_parameter("goals_blackboard_id").as_string(); | ||||||||||
orient_angle_rad_ = node->get_parameter("orient_angle_rad", orient_angle_rad_); | ||||||||||
|
||||||||||
if (!node->has_parameter("path_blackboard_id")) { | ||||||||||
node->declare_parameter("path_blackboard_id", std::string("path")); | ||||||||||
|
@@ -52,6 +53,12 @@ | |||||||||
// Odometry smoother object for getting current speed | ||||||||||
odom_smoother_ = odom_smoother; | ||||||||||
|
||||||||||
if (!node->has_parameter("orient_angle_rad")) { | ||||||||||
node->declare_parameter("orient_angle_rad", rclcpp::ParameterValue(1.57)); | ||||||||||
} | ||||||||||
|
||||||||||
node->get_parameter("orient_angle_rad", orient_angle_rad_); | ||||||||||
|
||||||||||
if (!node->has_parameter(getName() + ".enable_groot_monitoring")) { | ||||||||||
node->declare_parameter(getName() + ".enable_groot_monitoring", false); | ||||||||||
} | ||||||||||
|
@@ -137,6 +144,15 @@ | |||||||||
result->waypoint_statuses = std::move(waypoint_statuses); | ||||||||||
} | ||||||||||
|
||||||||||
inline double createYawFromQuat(const geometry_msgs::msg::Quaternion & orientation) | ||||||||||
{ | ||||||||||
tf2::Quaternion q(orientation.x, orientation.y, orientation.z, orientation.w); | ||||||||||
tf2::Matrix3x3 m(q); | ||||||||||
double roll, pitch, yaw; | ||||||||||
m.getRPY(roll, pitch, yaw); | ||||||||||
return yaw; | ||||||||||
} | ||||||||||
|
||||||||||
void | ||||||||||
NavigateThroughPosesNavigator::onLoop() | ||||||||||
{ | ||||||||||
|
@@ -169,19 +185,24 @@ | |||||||||
return; | ||||||||||
} | ||||||||||
|
||||||||||
// Get current path points | ||||||||||
// Get current path points and orientation angle | ||||||||||
nav_msgs::msg::Path current_path; | ||||||||||
double orient_angle_rad = orient_angle_rad_; | ||||||||||
res = blackboard->get(path_blackboard_id_, current_path); | ||||||||||
if (res && current_path.poses.size() > 0u) { | ||||||||||
// Find the closest pose to current pose on global path | ||||||||||
auto find_closest_pose_idx = | ||||||||||
[¤t_pose, ¤t_path]() { | ||||||||||
[¤t_pose, ¤t_path, &orient_angle_rad]() { | ||||||||||
size_t closest_pose_idx = 0; | ||||||||||
double curr_min_dist = std::numeric_limits<double>::max(); | ||||||||||
for (size_t curr_idx = 0; curr_idx < current_path.poses.size(); ++curr_idx) { | ||||||||||
double curr_dist = nav2_util::geometry_utils::euclidean_distance( | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instead we could check for the distance not just on XY but XY,Yaw so it would be 3D. |
||||||||||
current_pose, current_path.poses[curr_idx]); | ||||||||||
if (curr_dist < curr_min_dist) { | ||||||||||
double orient_diff = createYawFromQuat(current_pose.pose.orientation) - | ||||||||||
createYawFromQuat(current_path.poses[curr_idx].pose.orientation); | ||||||||||
if (curr_dist < curr_min_dist && | ||||||||||
abs(orient_diff) < orient_angle_rad) | ||||||||||
{ | ||||||||||
Comment on lines
+203
to
+205
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
curr_min_dist = curr_dist; | ||||||||||
closest_pose_idx = curr_idx; | ||||||||||
} | ||||||||||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tf2 Utils has a function that does this
getYaw