Skip to content

Commit 7f10292

Browse files
authored
JointInterpolationPlanner: pass optional max_effort property along to GripperCommand (#458)
MoveIt passes the effort field of the last trajectory point as the max_effort for a GripperCommand. Thus we pass the max_effort property to the effort field of the trajectory's last waypoint.
1 parent b346e7e commit 7f10292

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

core/src/solvers/joint_interpolation.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ using namespace trajectory_processing;
5151
JointInterpolationPlanner::JointInterpolationPlanner() {
5252
auto& p = properties();
5353
p.declare<double>("max_step", 0.1, "max joint step");
54+
// allow passing max_effort to GripperCommand actions via
55+
p.declare<double>("max_effort", "max_effort for GripperCommand actions");
5456
}
5557

5658
void JointInterpolationPlanner::init(const core::RobotModelConstPtr& /*robot_model*/) {}
@@ -95,6 +97,20 @@ bool JointInterpolationPlanner::plan(const planning_scene::PlanningSceneConstPtr
9597
timing->computeTimeStamps(*result, props.get<double>("max_velocity_scaling_factor"),
9698
props.get<double>("max_acceleration_scaling_factor"));
9799

100+
// set max_effort on first and last waypoint (first, because we might reverse the trajectory)
101+
const auto& max_effort = properties().get("max_effort");
102+
if (!max_effort.empty()) {
103+
double effort = boost::any_cast<double>(max_effort);
104+
for (const auto* jm : jmg->getActiveJointModels()) {
105+
if (jm->getVariableCount() != 1)
106+
continue;
107+
result->getFirstWayPointPtr()->dropAccelerations();
108+
result->getFirstWayPointPtr()->setJointEfforts(jm, &effort);
109+
result->getLastWayPointPtr()->dropAccelerations();
110+
result->getLastWayPointPtr()->setJointEfforts(jm, &effort);
111+
}
112+
}
113+
98114
return true;
99115
}
100116

0 commit comments

Comments
 (0)