@@ -364,17 +364,15 @@ ompl::base::ConstraintPtr createOMPLConstraints(const moveit::core::RobotModelCo
364
364
const std::string& group,
365
365
const moveit_msgs::msg::Constraints& constraints)
366
366
{
367
- // TODO(bostoncleek): does this reach the end w/o a return ?
368
-
369
- const std::size_t num_dofs = robot_model->getJointModelGroup (group)->getVariableCount ();
370
- const std::size_t num_pos_con = constraints.position_constraints .size ();
371
- const std::size_t num_ori_con = constraints.orientation_constraints .size ();
372
-
373
367
// This factory method contains template code to support position and/or orientation constraints.
374
368
// If the specified constraints are invalid, a nullptr is returned.
375
369
std::vector<ompl::base::ConstraintPtr> ompl_constraints;
376
- if (num_pos_con > 1 )
370
+ const std::size_t num_dofs = robot_model->getJointModelGroup (group)->getVariableCount ();
371
+
372
+ // Parse Position Constraints
373
+ if (!constraints.position_constraints .empty ())
377
374
{
375
+ <<<<<<< HEAD
378
376
RCLCPP_WARN (LOGGER, " Only a single position constraint is supported. Using the first one." );
379
377
}
380
378
if (num_ori_con > 1 )
@@ -385,27 +383,63 @@ ompl::base::ConstraintPtr createOMPLConstraints(const moveit::core::RobotModelCo
385
383
{
386
384
BaseConstraintPtr pos_con;
387
385
if (constraints.name == " use_equality_constraints" )
386
+ =======
387
+ if (constraints.position_constraints .size () > 1 )
388
+ >>>>>>> b0401e91a (Handle unsupported position constraints in OMPL (#2417 ))
389
+ {
390
+ RCLCPP_WARN (getLogger (), " Only a single position constraint is supported. Using the first one." );
391
+ }
392
+
393
+ const auto & primitives = constraints.position_constraints .at (0 ).constraint_region .primitives ;
394
+ if (primitives.size () > 1 )
395
+ {
396
+ RCLCPP_WARN (getLogger (), " Only a single position primitive is supported. Using the first one." );
397
+ }
398
+ if (primitives.empty () || primitives.at (0 ).type != shape_msgs::msg::SolidPrimitive::BOX)
388
399
{
389
- pos_con = std::make_shared<EqualityPositionConstraint>(robot_model, group, num_dofs);
400
+ RCLCPP_ERROR (getLogger (), " Unable to plan with the requested position constraint. "
401
+ " Only BOX primitive shapes are supported as constraint region." );
390
402
}
391
403
else
392
404
{
393
- pos_con = std::make_shared<BoxConstraint>(robot_model, group, num_dofs);
405
+ BaseConstraintPtr pos_con;
406
+ if (constraints.name == " use_equality_constraints" )
407
+ {
408
+ pos_con = std::make_shared<EqualityPositionConstraint>(robot_model, group, num_dofs);
409
+ }
410
+ else
411
+ {
412
+ pos_con = std::make_shared<BoxConstraint>(robot_model, group, num_dofs);
413
+ }
414
+ pos_con->init (constraints);
415
+ ompl_constraints.emplace_back (pos_con);
394
416
}
395
- pos_con->init (constraints);
396
- ompl_constraints.emplace_back (pos_con);
397
417
}
398
- if (num_ori_con > 0 )
418
+
419
+ // Parse Orientation Constraints
420
+ if (!constraints.orientation_constraints .empty ())
399
421
{
422
+ if (constraints.orientation_constraints .size () > 1 )
423
+ {
424
+ RCLCPP_WARN (getLogger (), " Only a single orientation constraint is supported. Using the first one." );
425
+ }
426
+
400
427
auto ori_con = std::make_shared<OrientationConstraint>(robot_model, group, num_dofs);
401
428
ori_con->init (constraints);
402
429
ompl_constraints.emplace_back (ori_con);
403
430
}
404
- if (num_pos_con < 1 && num_ori_con < 1 )
431
+
432
+ // Check if we have any constraints to plan with
433
+ if (ompl_constraints.empty ())
405
434
{
435
+ <<<<<<< HEAD
406
436
RCLCPP_ERROR (LOGGER, " No path constraints found in planning request." );
437
+ =======
438
+ RCLCPP_ERROR (getLogger (), " Failed to parse any supported path constraints from planning request." );
439
+ >>>>>>> b0401e91a (Handle unsupported position constraints in OMPL (#2417 ))
407
440
return nullptr ;
408
441
}
442
+
409
443
return std::make_shared<ompl::base::ConstraintIntersection>(num_dofs, ompl_constraints);
410
444
}
411
445
} // namespace ompl_interface
0 commit comments