-
Notifications
You must be signed in to change notification settings - Fork 935
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
Add test for PlanningContextManager in ompl interface #2248
Conversation
Travis fails because I did not add |
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.
Looks good to me. Just make sure copyright is assigned to KU Leuven, not Willow Garage.
I will fix the package.xml file tomorrow and remove the WIP tag. |
d6762af
to
51ca003
Compare
Codecov Report
@@ Coverage Diff @@
## master #2248 +/- ##
==========================================
- Coverage 57.94% 56.42% -1.51%
==========================================
Files 327 287 -40
Lines 25645 24451 -1194
==========================================
- Hits 14858 13795 -1063
+ Misses 10787 10656 -131
Continue to review full report at Codecov.
|
Woohoo, I don't think |
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.
Looks good to me!
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'm not sure the tests are very specific. Other than some nitpicks, I'm fine with it.
moveit_planners/ompl/ompl_interface/test/test_planning_context_manager.cpp
Outdated
Show resolved
Hide resolved
moveit_planners/ompl/ompl_interface/test/test_planning_context_manager.cpp
Show resolved
Hide resolved
moveit_planners/ompl/ompl_interface/test/test_planning_context_manager.cpp
Outdated
Show resolved
Hide resolved
// TODO(jeroendm) As the joint_model_group_ has not IK solver initialized, we still get a joint model state space | ||
// here, it would be nice if we could load an IK solver for the robot to test the PoseModelStateSpace. | ||
auto ss = dynamic_cast<ompl_interface::JointModelStateSpace*>(pc->getOMPLStateSpace().get()); | ||
EXPECT_NE(ss, nullptr); |
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.
If I'm not mistaken, you validate that you don't get a JointModelStateSpace
here. This contradicts the comment.
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 updated the comment to:
// As the joint_model_group_ has no IK solver initialized, we expect a joint model state space
I tried this summer, but I did not manage to figure out how to manually load an IK solver for the joint model group.
EXPECT_TRUE(success); | ||
} | ||
|
||
void testPathConstraints(const std::vector<double>& start, const std::vector<double>& goal) |
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.
The test here doesn't differ from testSimpleRequest()
except that path constraints are created. Particularly, the test doesn't verify that the constraints are correctly created and used.
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 added tests to see if the path constraints are added to the planning context and properly used by the planner. (The specific start and goal state used maybe a bit too trivial, but I'll leave this as future work if that's ok. Otherwise, I fear I might never finish this PR and continue working on the constrained planning PR.)
// Are the path constraints created in the planning context?
auto path_constraints = pc->getPathConstraints();
EXPECT_FALSE(path_constraints->empty());
EXPECT_EQ(path_constraints->getOrientationConstraints().size(), 1);
EXPECT_TRUE(path_constraints->getPositionConstraints().empty());
EXPECT_TRUE(path_constraints->getJointConstraints().empty());
EXPECT_TRUE(path_constraints->getVisibilityConstraints().empty());
// Check if all the states in the solution satisfy the path constraints.
// A detailed response returns 3 solutions: the ompl solution, the simplified solution and the interpolated
// solution. We test all of them here.
for (const robot_trajectory::RobotTrajectoryPtr& trajectory : res.trajectory_)
{
for (std::size_t pt_index = { 0 }; pt_index < trajectory->getWayPointCount(); ++pt_index)
{
EXPECT_TRUE(path_constraints->decide(trajectory->getWayPoint(pt_index)).satisfied);
}
}
<launch> | ||
<test pkg="moveit_planners_ompl" type="test_planning_context_manager" test-name="test_planning_context_manager" /> | ||
</launch> |
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.
There is no ROS environment loaded here. Do you need a rostest with a launch file after all?
Can the test run as a plain gtest as well?
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 need a node handle to call getPlanningRequest
, but the node handle is never used. As mentioned in the pr description:
Ideally, this test could be completely ROS independent if I had a way to create a "dummy" ros::NodeHandle without actually starting a roscore. The only method that needs this ROS handle is loadConstraintApproximations, which I'm not testing here.
I wish I could come up with a better solution. It is unfortunate that a ROS dependency got introduced in a non-ROS specific part of MoveIt. Technically, the code for the constraint approximations could be refactored to avoid this ros node handle dependency, but that would introduce breaking API changes for users, I think.
@rhaschke thank you for the feedback!
I think they become really useful if the new constrained-state-space gets merged, where an extra test is added to test the configurations options that the user can specify. |
Co-authored-by: Robert Haschke <rhaschke@users.noreply.github.com>
Note that I'll have to rebase this if #2247 gets merged first, because of the |
Description
(This pull request could use some extra work, but early feedback would be really valuable.)
This test goes through the main steps in solving a planning problem with the interface;
PlanningContextManager
.getPlanningContext
with a specific request to get aModelBasedPlanningContext
.solve
method on the planning context.The main intent is to check if the
ModelBasedPlanningContext
has the correct type ofModelBasedStateSpace
assigned for planning. (For a detailed explanation of this process, see here.)Calling the
solve
method is just the cherry on top of the cake.The
load_test_robot_class.h
is exactly the same as in #2247, so I assume that change will not be part of this pull request once rebased.TODO / issues
Loading a (dummy) IK solver for a planning group
The selection of the state space depends on the availability of an IK solver. I found an example of how to load a solver in a test class in test_constrained_sampler.cpp, which basically adds a complete implementation of an IK solver (
KinematicsBase
class) to the test directory.rostest dependency
Ideally, this test could be completely ROS independent if I had a way to create a "dummy"
ros::NodeHandle
without actually starting a roscore. The only method that needs this ROS handle is loadConstraintApproximations, which I'm not testing here.Why are these useful?
I'm currently using this test in the context of #2092, where they are extremely helpful.
Checklist