Skip to content

Commit 60ccd74

Browse files
authored
MoveRelative: fix segfault on empty trajectory (#595)
Check that at least one robot state exists in the robot trajectory before accessing it. Signed-off-by: Paul Gesel <[email protected]>
1 parent 2e9a223 commit 60ccd74

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

core/src/stages/move_relative.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,8 @@ bool MoveRelative::compute(const InterfaceState& state, planning_scene::Planning
296296
if (!success)
297297
comment = result.message;
298298

299-
if (robot_trajectory) { // the following requires a robot_trajectory returned from planning
299+
if (robot_trajectory && robot_trajectory->getWayPointCount() > 0) { // the following requires a robot_trajectory
300+
// returned from planning
300301
moveit::core::RobotStatePtr& reached_state = robot_trajectory->getLastWayPointPtr();
301302
reached_state->updateLinkTransforms();
302303
const Eigen::Isometry3d& reached_pose = reached_state->getGlobalLinkTransform(link) * offset;
@@ -331,7 +332,7 @@ bool MoveRelative::compute(const InterfaceState& state, planning_scene::Planning
331332
}
332333

333334
// store result
334-
if (robot_trajectory) {
335+
if (robot_trajectory && robot_trajectory->getWayPointCount() > 0) {
335336
scene->setCurrentState(robot_trajectory->getLastWayPoint());
336337
if (dir == Interface::BACKWARD)
337338
robot_trajectory->reverse();

0 commit comments

Comments
 (0)