-
Notifications
You must be signed in to change notification settings - Fork 701
Handle compound state space for AORRTC #1345
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
Open
Jaeyoung-Lim
wants to merge
1
commit into
ompl:main
Choose a base branch
from
Jaeyoung-Lim:pr-aorrtc
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -39,6 +39,7 @@ | |
|
|
||
| #include "ompl/datastructures/NearestNeighbors.h" | ||
| #include "ompl/base/OptimizationObjective.h" | ||
| #include "ompl/base/spaces/RealVectorStateSpace.h" | ||
| #include "ompl/geometric/planners/PlannerIncludes.h" | ||
| #include <ompl/geometric/planners/rrt/RRTConnect.h> | ||
|
|
||
|
|
@@ -192,9 +193,39 @@ namespace ompl | |
| /** \brief Free the memory allocated by this planner */ | ||
| void freeMemory(); | ||
|
|
||
| /** \brief Compute euclidian distance between motions */ | ||
| /** \brief Compute euclidian distance between motions | ||
| * | ||
| * For compound state spaces, this extracts the position components and | ||
| * computes actual Euclidean distance, rather than using the state space's | ||
| * distance() which may return path-based non-metric distances. | ||
| */ | ||
| double euclideanDistanceFunction(const Motion *a, const Motion *b) const | ||
| { | ||
| // Try to get actual Euclidean distance for compound state spaces | ||
| auto *stateSpace = si_->getStateSpace().get(); | ||
| if (stateSpace->isCompound()) | ||
| { | ||
| auto *compoundSpace = stateSpace->as<base::CompoundStateSpace>(); | ||
| // Get the first subspace which should be the position component (RealVectorStateSpace) | ||
| auto *subspace = compoundSpace->getSubspace(0).get(); | ||
| if (subspace->getType() == base::STATE_SPACE_REAL_VECTOR) | ||
| { | ||
| auto *rvSpace = subspace->as<base::RealVectorStateSpace>(); | ||
|
Member
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. No need to reimplement RealVectorStateSpace::distance. I think you can just call |
||
| const auto *aCompound = a->state->as<base::CompoundStateSpace::StateType>(); | ||
| const auto *bCompound = b->state->as<base::CompoundStateSpace::StateType>(); | ||
| const double *aVals = aCompound->as<base::RealVectorStateSpace::StateType>(0)->values; | ||
| const double *bVals = bCompound->as<base::RealVectorStateSpace::StateType>(0)->values; | ||
| unsigned int dim = rvSpace->getDimension(); | ||
| double dist = 0.0; | ||
| for (unsigned int i = 0; i < dim; ++i) | ||
| { | ||
| double diff = aVals[i] - bVals[i]; | ||
| dist += diff * diff; | ||
| } | ||
| return std::sqrt(dist); | ||
| } | ||
| } | ||
| // Fallback to state space distance for non-compound spaces | ||
| return si_->distance(a->state, b->state); | ||
| } | ||
|
|
||
|
|
||
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.
This is not guaranteed. Rephrase as: