-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Path distance feature #5387
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
base: main
Are you sure you want to change the base?
Path distance feature #5387
Conversation
Signed-off-by: silanus23 <berkantali23@outlook.com>
Signed-off-by: silanus23 <berkantali23@outlook.com>
Signed-off-by: silanus23 <berkantali23@outlook.com>
Signed-off-by: silanus23 <berkantali23@outlook.com>
Signed-off-by: silanus23 <berkantali23@outlook.com>
Signed-off-by: silanus23 <berkantali23@outlook.com>
Codecov Report✅ All modified and coverable lines are covered by tests.
... and 4 files with indirect coverage changes 🚀 New features to boost your workflow:
|
* @param target target point | ||
* @return int | ||
*/ | ||
inline double distanceToPoint( |
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.
I think you can just euclidean_distance
which exists above for PoseStamped
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.
Deleted it.
* @param finish End point of target vector | ||
* @return int | ||
*/ | ||
inline double distanceToSegment( |
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.
Follow the naming conventions in this script for distance_to_segment
please :-)
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.
Sorry didn't realize first time
* @return int | ||
*/ | ||
inline double distanceToSegment( | ||
const geometry_msgs::msg::PoseStamped & point, |
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.
I think we can make this point use geometry_msgs/Point which is just the PoseStamped msg.pose.position
since this is a point value.
The start
and end
can be Pose
so that we strip out the header. That can make this more portible to situations where we have geometry_msgs/Pose rather than PoseStamped for little change in the application code of pose
to pose.pose
.
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.
Changed inputs to those.
const geometry_msgs::msg::PoseStamped & start, | ||
const geometry_msgs::msg::PoseStamped & end) | ||
{ | ||
const auto & p = point.pose.position; |
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.
I know this is a common math formulation, but can you add a link to the equation so that someone reading this layer understands where it came from? I typically like to do that for closed form equations to help the reader
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.
Added a wikipedia link hope it's enough.
size_t closest_segment_index; | ||
}; | ||
|
||
PathSearchResult distanceFromPath( |
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.
distance_from_path
nav2_util/src/path_utils.cpp
Outdated
return result; | ||
} | ||
|
||
PathSearchResult distanceFromPath( |
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.
I think you just want this one implementation, where the start_index
is defaulted to 0
when not provided and search_window_length
is set as numerical_limits<float>::max
to remove duplication
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.
Yeap exactly like you said :) sorry couldn't catch this in first.
nav2_util/src/path_utils.cpp
Outdated
{ | ||
PathSearchResult result; | ||
result.closest_segment_index = start_index; | ||
result.distance = std::numeric_limits<double>::infinity(); |
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.
Remove all INF and replace with max in call cases. I don't like to intentionally inject INF and NAN into the system
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.
I believe I handled this.
nav2_util/src/path_utils.cpp
Outdated
return result; | ||
} | ||
|
||
if (search_window_length <= 0.0) { |
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.
I think this can throw - that's a totally invalid use
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.
Done.
double distance; | ||
size_t closest_segment_index; | ||
}; | ||
|
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.
ALl functions and objects need doxygen docs
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.
Added
nav2_util/src/path_utils.cpp
Outdated
double min_distance = std::numeric_limits<double>::max(); | ||
size_t closest_segment = start_index; | ||
size_t segments_checked = 0; | ||
const size_t max_segments = static_cast<size_t>(search_window_length); |
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.
This is a double for a reason, its an actual distance. We should find the distance that each segment covers and add that to a running counter. Stop searching when the total euclidean distance along the path searched is greater than search_window_length
... this is making me a little suspicious that this was generated by AI - was it? I think this is the kind of thing you would know isn't the intent from a double
input. Please make sure to review, in detail, before submitting PRs. That would also explain the code not generally following the styling of the rest of the files. Just a friendly warning, maintainers have limited time for reviews so try to make sure that you would put your name on something it outputs before sending to us to take a look.
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.
I am so sorry this PR costed you. I used helper tools and not copy-pasting I was thinking I was reviewing them enough. But seems I was mistaken. Again and again I am gratefull for your patience and valuable time. I can guess how hard it is for you to deliver this kind of detailed review. I hope this time I met this repo's standarts. I will be even more strict in my future contributions. Thanks.
Signed-off-by: silanus23 <berkantali23@outlook.com>
Signed-off-by: silanus23 <berkantali23@outlook.com>
Basic Info
Description of contribution in a few bullet points
Only path utils as descripted in the issue. It is finding nearest part in the path and current or waited position of robot. It interpolates between points cause the expected nearest point is between points path most of the time. There are 2 versions global version is reccomended and local version can sometimes fail.
Description of documentation updates required from your changes
At this stage none needed.
Description of how this change was tested
I wrote diffirent trajectories. AI help came in here I used it to calculate the numbers. I have tested the local search with clover leaf and retracting windows too but it failed. This was actually expected as the local search is optimized version. I don't think those failings come from a logical issue but the limitations of the approach behind it.
Future work that may be required in bullet points
Future side of the it is planned as you reccomend. Next one will be about creating a new msg type and publishing it from controller_server.
BTW thanks for patience about my last PR as this is my first open source contribution. I am still learning.
For Maintainers:
backport-*
.