Skip to content

Commit

Permalink
Sort constraints for reduced cardinality
Browse files Browse the repository at this point in the history
Signed-off-by: methylDragon <[email protected]>
  • Loading branch information
methylDragon committed Nov 21, 2023
1 parent 6e5b963 commit f166c89
Showing 1 changed file with 56 additions and 0 deletions.
56 changes: 56 additions & 0 deletions nexus_motion_planner/src/motion_plan_cache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,34 @@ MotionPlanCache::extract_and_append_plan_goal_to_query(
{
orientation_constraints.push_back(orientation_constraint);
}

// Also sort for even less cardinality.
std::sort(
joint_constraints.begin(), joint_constraints.end(),
[](
const moveit_msgs::msg::JointConstraint& l,
const moveit_msgs::msg::JointConstraint& r)
{
return l.joint_name < r.joint_name;
});

std::sort(
position_constraints.begin(), position_constraints.end(),
[](
const moveit_msgs::msg::PositionConstraint& l,
const moveit_msgs::msg::PositionConstraint& r)
{
return l.link_name < r.link_name;
});

std::sort(
orientation_constraints.begin(), orientation_constraints.end(),
[](
const moveit_msgs::msg::OrientationConstraint& l,
const moveit_msgs::msg::OrientationConstraint& r)
{
return l.link_name < r.link_name;
});
}

// Joint constraints
Expand Down Expand Up @@ -742,6 +770,34 @@ MotionPlanCache::extract_and_append_plan_goal_to_metadata(
{
orientation_constraints.push_back(orientation_constraint);
}

// Also sort for even less cardinality.
std::sort(
joint_constraints.begin(), joint_constraints.end(),
[](
const moveit_msgs::msg::JointConstraint& l,
const moveit_msgs::msg::JointConstraint& r)
{
return l.joint_name < r.joint_name;
});

std::sort(
position_constraints.begin(), position_constraints.end(),
[](
const moveit_msgs::msg::PositionConstraint& l,
const moveit_msgs::msg::PositionConstraint& r)
{
return l.link_name < r.link_name;
});

std::sort(
orientation_constraints.begin(), orientation_constraints.end(),
[](
const moveit_msgs::msg::OrientationConstraint& l,
const moveit_msgs::msg::OrientationConstraint& r)
{
return l.link_name < r.link_name;
});
}

// Joint constraints
Expand Down

0 comments on commit f166c89

Please sign in to comment.