Skip to content

Commit d529029

Browse files
authored
Add use_padding flag + deprecate checkCollisionUnpadded() functions (#3088)
* Add use_padding flag + deprecate Unpadded... functions * Fix CI * Remove deprecated functions from python API * Update #pragmas * Address review * Add CHANGELOG comment * Remove warning * Update MIGRATION guide * Update early exit logic in checkCollision * Update comment
1 parent 91b47a6 commit d529029

File tree

7 files changed

+170
-109
lines changed

7 files changed

+170
-109
lines changed

MIGRATION.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
API changes in MoveIt releases
44

55
## ROS Rolling
6+
- [11/2024] Added flags to control padding to CollisionRequest. This change deprecates PlanningScene::checkCollisionUnpadded(..) functions. Please use PlanningScene::checkCollision(..) with a req.pad_environment_collisions = false;
7+
68
- [12/2023] `trajectory_processing::Path` and `trajectory_processing::Trajectory` APIs have been updated to prevent misuse.
79
The constructors have been replaced by builder methods so that errors can be communicated. Paths and trajectories now need to be created with `Path::Create()` and `Trajectory::Create()`. These methods now return an `std::optional` that needs to be checked for a valid value. `Trajectory` no longer has the `isValid()` method. If it's invalid, `Trajectory::Create()` will return `std::nullopt`. Finally, `Path` now takes the list of input waypoints as `std::vector`, instead of `std::list`.
810
- [12/2023] LMA kinematics plugin is removed to remove the maintenance work because better alternatives exist like KDL or TracIK

moveit_core/collision_detection/include/moveit/collision_detection/collision_common.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,12 @@ struct CollisionRequest
150150
* are included. */
151151
std::string group_name = "";
152152

153+
/** \brief If true, use padded collision environment */
154+
bool pad_environment_collisions = true;
155+
156+
/** \brief If true, do self collision check with padded robot links */
157+
bool pad_self_collisions = false;
158+
153159
/** \brief If true, compute proximity distance */
154160
bool distance = false;
155161

moveit_core/planning_scene/include/moveit/planning_scene/planning_scene.h

Lines changed: 27 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -347,19 +347,12 @@ class MOVEIT_PLANNING_SCENE_EXPORT PlanningScene : public std::enable_shared_fro
347347
void checkCollision(const collision_detection::CollisionRequest& req, collision_detection::CollisionResult& res);
348348

349349
/** \brief Check whether the current state is in collision. The current state is expected to be updated. */
350-
void checkCollision(const collision_detection::CollisionRequest& req, collision_detection::CollisionResult& res) const
351-
{
352-
checkCollision(req, res, getCurrentState());
353-
}
350+
void checkCollision(const collision_detection::CollisionRequest& req, collision_detection::CollisionResult& res) const;
354351

355352
/** \brief Check whether a specified state (\e robot_state) is in collision. This variant of the function takes
356353
a non-const \e robot_state and calls updateCollisionBodyTransforms() on it. */
357354
void checkCollision(const collision_detection::CollisionRequest& req, collision_detection::CollisionResult& res,
358-
moveit::core::RobotState& robot_state) const
359-
{
360-
robot_state.updateCollisionBodyTransforms();
361-
checkCollision(req, res, static_cast<const moveit::core::RobotState&>(robot_state));
362-
}
355+
moveit::core::RobotState& robot_state) const;
363356

364357
/** \brief Check whether a specified state (\e robot_state) is in collision. The collision transforms of \e
365358
* robot_state are
@@ -372,11 +365,7 @@ class MOVEIT_PLANNING_SCENE_EXPORT PlanningScene : public std::enable_shared_fro
372365
a non-const \e robot_state and updates its link transforms if needed. */
373366
void checkCollision(const collision_detection::CollisionRequest& req, collision_detection::CollisionResult& res,
374367
moveit::core::RobotState& robot_state,
375-
const collision_detection::AllowedCollisionMatrix& acm) const
376-
{
377-
robot_state.updateCollisionBodyTransforms();
378-
checkCollision(req, res, static_cast<const moveit::core::RobotState&>(robot_state), acm);
379-
}
368+
const collision_detection::AllowedCollisionMatrix& acm) const;
380369

381370
/** \brief Check whether a specified state (\e robot_state) is in collision, with respect to a given
382371
allowed collision matrix (\e acm). */
@@ -387,99 +376,69 @@ class MOVEIT_PLANNING_SCENE_EXPORT PlanningScene : public std::enable_shared_fro
387376
/** \brief Check whether the current state is in collision,
388377
but use a collision_detection::CollisionRobot instance that has no padding.
389378
Since the function is non-const, the current state transforms are also updated if needed. */
390-
void checkCollisionUnpadded(const collision_detection::CollisionRequest& req,
391-
collision_detection::CollisionResult& res);
379+
[[deprecated("Use new CollisionRequest flags to enable/ disable padding instead.")]] void
380+
checkCollisionUnpadded(const collision_detection::CollisionRequest& req, collision_detection::CollisionResult& res);
392381

393382
/** \brief Check whether the current state is in collision,
394383
but use a collision_detection::CollisionRobot instance that has no padding. */
395-
void checkCollisionUnpadded(const collision_detection::CollisionRequest& req,
396-
collision_detection::CollisionResult& res) const
397-
{
398-
checkCollisionUnpadded(req, res, getCurrentState(), getAllowedCollisionMatrix());
399-
}
384+
[[deprecated("Use new CollisionRequest flags to enable/ disable padding instead.")]] void
385+
checkCollisionUnpadded(const collision_detection::CollisionRequest& req,
386+
collision_detection::CollisionResult& res) const;
400387

401388
/** \brief Check whether a specified state (\e robot_state) is in collision,
402389
but use a collision_detection::CollisionRobot instance that has no padding. */
403-
void checkCollisionUnpadded(const collision_detection::CollisionRequest& req,
404-
collision_detection::CollisionResult& res,
405-
const moveit::core::RobotState& robot_state) const
406-
{
407-
checkCollisionUnpadded(req, res, robot_state, getAllowedCollisionMatrix());
408-
}
390+
[[deprecated("Use new CollisionRequest flags to enable/ disable padding instead.")]] void
391+
checkCollisionUnpadded(const collision_detection::CollisionRequest& req, collision_detection::CollisionResult& res,
392+
const moveit::core::RobotState& robot_state) const;
409393

410394
/** \brief Check whether a specified state (\e robot_state) is in collision,
411395
but use a collision_detection::CollisionRobot instance that has no padding.
412396
Update the link transforms of \e robot_state if needed. */
413-
void checkCollisionUnpadded(const collision_detection::CollisionRequest& req,
414-
collision_detection::CollisionResult& res, moveit::core::RobotState& robot_state) const
415-
{
416-
robot_state.updateCollisionBodyTransforms();
417-
checkCollisionUnpadded(req, res, static_cast<const moveit::core::RobotState&>(robot_state),
418-
getAllowedCollisionMatrix());
419-
}
397+
[[deprecated("Use new CollisionRequest flags to enable/ disable padding instead.")]] void
398+
checkCollisionUnpadded(const collision_detection::CollisionRequest& req, collision_detection::CollisionResult& res,
399+
moveit::core::RobotState& robot_state) const;
420400

421401
/** \brief Check whether a specified state (\e robot_state) is in collision, with respect to a given
422402
allowed collision matrix (\e acm), but use a collision_detection::CollisionRobot instance that has no padding.
423403
This variant of the function takes a non-const \e robot_state and calls updates the link transforms if needed. */
424-
void checkCollisionUnpadded(const collision_detection::CollisionRequest& req,
425-
collision_detection::CollisionResult& res, moveit::core::RobotState& robot_state,
426-
const collision_detection::AllowedCollisionMatrix& acm) const
427-
{
428-
robot_state.updateCollisionBodyTransforms();
429-
checkCollisionUnpadded(req, res, static_cast<const moveit::core::RobotState&>(robot_state), acm);
430-
}
404+
[[deprecated("Use new CollisionRequest flags to enable/ disable padding instead.")]] void
405+
checkCollisionUnpadded(const collision_detection::CollisionRequest& req, collision_detection::CollisionResult& res,
406+
moveit::core::RobotState& robot_state,
407+
const collision_detection::AllowedCollisionMatrix& acm) const;
431408

432409
/** \brief Check whether a specified state (\e robot_state) is in collision, with respect to a given
433410
allowed collision matrix (\e acm), but use a collision_detection::CollisionRobot instance that has no padding. */
434-
void checkCollisionUnpadded(const collision_detection::CollisionRequest& req,
435-
collision_detection::CollisionResult& res, const moveit::core::RobotState& robot_state,
436-
const collision_detection::AllowedCollisionMatrix& acm) const;
411+
[[deprecated("Use new CollisionRequest flags to enable/ disable padding instead.")]] void
412+
checkCollisionUnpadded(const collision_detection::CollisionRequest& req, collision_detection::CollisionResult& res,
413+
const moveit::core::RobotState& robot_state,
414+
const collision_detection::AllowedCollisionMatrix& acm) const;
437415

438416
/** \brief Check whether the current state is in self collision */
439417
void checkSelfCollision(const collision_detection::CollisionRequest& req, collision_detection::CollisionResult& res);
440418

441419
/** \brief Check whether the current state is in self collision */
442420
void checkSelfCollision(const collision_detection::CollisionRequest& req,
443-
collision_detection::CollisionResult& res) const
444-
{
445-
checkSelfCollision(req, res, getCurrentState());
446-
}
421+
collision_detection::CollisionResult& res) const;
447422

448423
/** \brief Check whether a specified state (\e robot_state) is in self collision */
449424
void checkSelfCollision(const collision_detection::CollisionRequest& req, collision_detection::CollisionResult& res,
450-
moveit::core::RobotState& robot_state) const
451-
{
452-
robot_state.updateCollisionBodyTransforms();
453-
checkSelfCollision(req, res, static_cast<const moveit::core::RobotState&>(robot_state), getAllowedCollisionMatrix());
454-
}
425+
moveit::core::RobotState& robot_state) const;
455426

456427
/** \brief Check whether a specified state (\e robot_state) is in self collision */
457428
void checkSelfCollision(const collision_detection::CollisionRequest& req, collision_detection::CollisionResult& res,
458-
const moveit::core::RobotState& robot_state) const
459-
{
460-
// do self-collision checking with the unpadded version of the robot
461-
getCollisionEnvUnpadded()->checkSelfCollision(req, res, robot_state, getAllowedCollisionMatrix());
462-
}
429+
const moveit::core::RobotState& robot_state) const;
463430

464431
/** \brief Check whether a specified state (\e robot_state) is in self collision, with respect to a given
465432
allowed collision matrix (\e acm). The link transforms of \e robot_state are updated if needed. */
466433
void checkSelfCollision(const collision_detection::CollisionRequest& req, collision_detection::CollisionResult& res,
467434
moveit::core::RobotState& robot_state,
468-
const collision_detection::AllowedCollisionMatrix& acm) const
469-
{
470-
robot_state.updateCollisionBodyTransforms();
471-
checkSelfCollision(req, res, static_cast<const moveit::core::RobotState&>(robot_state), acm);
472-
}
435+
const collision_detection::AllowedCollisionMatrix& acm) const;
473436

474437
/** \brief Check whether a specified state (\e robot_state) is in self collision, with respect to a given
475438
allowed collision matrix (\e acm) */
476439
void checkSelfCollision(const collision_detection::CollisionRequest& req, collision_detection::CollisionResult& res,
477440
const moveit::core::RobotState& robot_state,
478-
const collision_detection::AllowedCollisionMatrix& acm) const
479-
{
480-
// do self-collision checking with the unpadded version of the robot
481-
getCollisionEnvUnpadded()->checkSelfCollision(req, res, robot_state, acm);
482-
}
441+
const collision_detection::AllowedCollisionMatrix& acm) const;
483442

484443
/** \brief Get the names of the links that are involved in collisions for the current state */
485444
void getCollidingLinks(std::vector<std::string>& links);

0 commit comments

Comments
 (0)