AndrejOrsula / ign_moveit2_examples

C++ and Python examples of using MoveIt 2 inside Ignition Gazebo simulation environment
BSD 3-Clause "New" or "Revised" License
97 stars 20 forks source link

Adding collision meshes to RViz and gazebo ignition #16

Closed marc-wittwer closed 2 years ago

marc-wittwer commented 2 years ago

I managed to add collision meshes via an .stl-file to the moveit component. The mesh displays in the RViz window correctly but is missing in the gazebo scene.

image image

            filepath = path.join(
                path.dirname(path.realpath(__file__)), "cylinder.stl"
            )
            mesh_id = 'cylinder'
            position = Point(x=0.5, y=0.0, z=0.2)
            quat = Quaternion(x=1.0, y=0.0, z=0.0, w=0.0)

            self.get_logger().warn("Adding collision mesh cylinder")

            self._moveit2.add_collision_mesh(
                filepath=filepath, id=mesh_id, position=position, quat_xyzw=quat)

However, how would I add the cylinder collision mesh to the gazebo scene?

How should I implement a moving obstacle (collision mesh) programmatically, so that it is both visible in RViz and gazebo? (e.g. a moving person walking by the robot)

AndrejOrsula commented 2 years ago

Hello @marc-wittwer,

That is an expected behaviour. MoveIt 2 has nothing to do with objects inside the simulation. Function add_collision_mesh() adds mesh only to the planning scene of MoveIt such that it avoids these objects/meshes during motion planning.

To add objects to the Gazebo simulation, there are several ways. You can use some of the Gazebo plugins to add objects (e.g. Resource Spawner), edit SDF world files (e.g. worlds/throw_object.sdf) or do it programatically. Try consulting ~Ignition~ Gazebo tutorials for that. Note that these objects will NOT be automatically a part of the MoveIt planning scene.