Skip to content

Commit a0da41a

Browse files
Fix clamping of joint constraints (#665)
Do not enforce position bounds (by clamping to valid positions), but let the stage fail if joints are outside the limits.
1 parent bad8e13 commit a0da41a

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

core/src/stages/move_relative.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@ static bool getJointStateFromOffset(const boost::any& direction, const Interface
9494
throw std::runtime_error("Cannot plan for multi-variable joint '" + j.first + "'");
9595
auto index = jm->getFirstVariableIndex();
9696
robot_state.setVariablePosition(index, robot_state.getVariablePosition(index) + sign * j.second);
97-
robot_state.enforceBounds(jm);
9897
}
9998
robot_state.update();
10099
return true;

core/test/test_move_relative.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include <moveit/task_constructor/stages/move_relative.h>
55
#include <moveit/task_constructor/stages/fixed_state.h>
66
#include <moveit/task_constructor/solvers/cartesian_path.h>
7+
#include <moveit/task_constructor/solvers/joint_interpolation.h>
78
#include <moveit/task_constructor/solvers/pipeline_planner.h>
89

910
#include <moveit/planning_scene/planning_scene.h>
@@ -32,6 +33,10 @@ solvers::CartesianPathPtr create<solvers::CartesianPath>() {
3233
return std::make_shared<solvers::CartesianPath>();
3334
}
3435
template <>
36+
solvers::JointInterpolationPlannerPtr create<solvers::JointInterpolationPlanner>() {
37+
return std::make_shared<solvers::JointInterpolationPlanner>();
38+
}
39+
template <>
3540
solvers::PipelinePlannerPtr create<solvers::PipelinePlanner>() {
3641
auto p = std::make_shared<solvers::PipelinePlanner>("pilz_industrial_motion_planner");
3742
p->setPlannerId("LIN");
@@ -68,6 +73,7 @@ struct PandaMoveRelative : public testing::Test
6873
}
6974
};
7075
using PandaMoveRelativeCartesian = PandaMoveRelative<solvers::CartesianPath>;
76+
using PandaMoveRelativeJoint = PandaMoveRelative<solvers::JointInterpolationPlanner>;
7177

7278
moveit_msgs::CollisionObject createObject(const std::string& id, const geometry_msgs::Pose& pose) {
7379
moveit_msgs::CollisionObject co;
@@ -163,6 +169,25 @@ TEST_F(PandaMoveRelativeCartesian, cartesianRotateAttachedIKFrame) {
163169
EXPECT_CONST_POSITION(move->solutions().front(), attached_object);
164170
}
165171

172+
// https://github.com/moveit/moveit_task_constructor/issues/664
173+
TEST_F(PandaMoveRelativeJoint, jointOutsideBound) {
174+
// move joint inside limit
175+
auto initial_jpos = scene->getCurrentState().getJointPositions("panda_joint7");
176+
move->setDirection([initial_jpos] {
177+
return std::map<std::string, double>{ { "panda_joint7", 2.0 - *initial_jpos } };
178+
}());
179+
EXPECT_TRUE(this->t.plan()) << "Plan should succeed, joint inside limit";
180+
181+
this->t.reset();
182+
183+
// move joint outside limit: 2.8973
184+
move->setDirection([initial_jpos] {
185+
return std::map<std::string, double>{ { "panda_joint7", 3.0 - *initial_jpos } };
186+
}());
187+
188+
EXPECT_FALSE(this->t.plan()) << "Plan should fail, joint outside limit";
189+
}
190+
166191
using PlannerTypes = ::testing::Types<solvers::CartesianPath, solvers::PipelinePlanner>;
167192
TYPED_TEST_SUITE(PandaMoveRelative, PlannerTypes);
168193
TYPED_TEST(PandaMoveRelative, cartesianCollisionMinMaxDistance) {

0 commit comments

Comments
 (0)