Failed collision object ADD replacement removes the existing object before validation
Maintainers usually reply within 1 day
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 76/100
Research direction
Start in moveit_core/planning_scene/src/planning_scene.cpp at PlanningScene::processCollisionObjectAdd() and trace how replacement ADD messages are converted and added to the world. Then find the PlanningScene collision object tests and add a case with mismatched primitive and pose counts. Done means the replacement is rejected and the original object's geometry and pose remain unchanged.
Written by the indexing model from the issue text.
Description
Description
In PlanningScene::processCollisionObjectAdd(), an existing collision object is removed before the replacement object's geometry is validated.
Affected file:
moveit_core/planning_scene/src/planning_scene.cpp
When an ADD operation targets an existing collision object, the following code removes the original object:
if (object.operation == moveit_msgs::msg::CollisionObject::ADD && world_->hasObject(object.id))
world_->removeObject(object.id);
However, the replacement geometry is only parsed and validated afterward:
const Eigen::Isometry3d& world_to_object_header_transform =
getFrameTransform(object.header.frame_id);
Eigen::Isometry3d header_to_pose_transform;
std::vectorshapes::ShapeConstPtr shapes;
EigenSTL::vector_Isometry3d shape_poses;
if (!shapesAndPosesFromCollisionObjectMessage(
object, header_to_pose_transform, shapes, shape_poses))
return false;
const Eigen::Isometry3d object_frame_transform =
world_to_object_header_transform * header_to_pose_transform;
world_->addToObject(object.id, object_frame_transform, shapes, shape_poses);
The geometry conversion function can return false when the input contains an invalid number of shape poses.
For example, if primitive_poses.size() exceeds primitives.size(), the conversion fails.
As a result, a malformed replacement ADD request can remove an existing valid collision object and then return false without restoring it.
This creates a partial state update and may cause an obstacle to disappear from the collision world even though the replacement operation failed.
In applications that rely on the PlanningScene for collision checking, this could lead to an incomplete representation of the environment.
Suggested Fix
Validate and construct the replacement geometry before removing the existing collision object.
The original object should remain unchanged if validation fails.
A regression test should verify that a rejected replacement ADD operation preserves the existing collision object and its geometry.
ROS Distro
Humble
OS and version
Ubuntu 22.04
Source or binary build?
Source
If binary, which release version?
No response
If source, which branch?
No response
Which RMW are you using?
None
Steps to Reproduce
Proposed reproduction steps (not yet executed):
- Create a PlanningScene instance with a valid robot model.
- Add a valid collision object with the ID test_object, containing one primitive shape.
- Verify that test_object exists in the collision world.
- Construct a new moveit_msgs::msg::CollisionObject message with:
- id = "test_object"
- operation = CollisionObject::ADD
- The same valid header.frame_id as the original object.
- One primitive shape.
- Two entries in primitive_poses, intentionally creating a mismatch between the number of shapes and poses.
- Submit the replacement message using PlanningScene::processCollisionObjectMsg().
- Check the return value of the operation.
- Query the collision world using getWorld()->hasObject("test_object").
The mismatched shape and pose counts should cause
shapesAndPosesFromCollisionObjectMessage() to return false after the existing object has already been removed.
Expected behavior
When a replacement ADD message contains invalid geometry data, the operation should fail without modifying the existing collision object.
The original object should remain in the collision world with its geometry, pose, and associated state unchanged.
A failed replacement operation should not remove an existing valid obstacle from the PlanningScene.
Actual behavior
Source inspection shows that processCollisionObjectAdd() removes the existing collision object before validating the replacement geometry.
If shapesAndPosesFromCollisionObjectMessage() detects an invalid shape/pose count, it returns false, causing processCollisionObjectAdd() to terminate without adding the replacement object.
Consequently, the original collision object can be removed even though the replacement ADD operation reports failure.
This behavior is supported by the source-level control flow but has not yet been verified by a runtime regression test.
Backtrace or Console output
No response
- Dominant language
- C++
- Stars
- 2.1k
- Forks
- 816
- Avg merge
- 1d 2h
- Merged PRs (30d)
- 4
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from moveit/moveit2
-
Collision object MOVE modifies object pose before validating shape pose countMay be free again A pull request for this issue was closed without being merged. Openbug
Difficulty 2/5 1-3 hours Newbie friendliness 79/100
moveit/moveit2#3941 · 2 comments ·
Maintainers usually reply within 1 day
-
Missing copy-on-write protection in World::moveShapesInObject and setSubframesOfObjectMay be free again A pull request for this issue was closed without being merged. Openbug
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
moveit/moveit2#3940 · 2 comments ·
Maintainers usually reply within 1 day
-
Missing bounds check for collision object subframe namesPossibly taken @huxiaoyi-ovo claimed this 6 days ago. Openbug
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
moveit/moveit2#3939 · 2 comments ·
Maintainers usually reply within 1 day
-
std::max mixes translational (m) and rotational (rad) errors in kdl_kinematics_plugin.cppMay be free again @Rudyy75 claimed this 136 days ago, and no pull request is open. Openbug
Difficulty 2/5 1-3 hours Newbie friendliness 63/100
moveit/moveit2#3747 · 2 comments ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
Maintainers usually reply within 1 day
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 62/100
mw00/project-maya#877 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
llvm/offload-test-suite#1703 ·
Maintainers usually reply within 1 day
-
backlog bug
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
EchoTools/nevr-runtime#2154 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
BGI-shenzhen/PopLDdecay#25 ·