AndrejOrsula / pymoveit2

Basic Python interface for MoveIt 2 built on top of ROS 2 actions and services
BSD 3-Clause "New" or "Revised" License
137 stars 54 forks source link

RViz framerate drops when collision_meshes are added #13

Closed marc-wittwer closed 2 years ago

marc-wittwer commented 2 years ago

I tried to add a 3D occupancy map of the robots surroundings using the add_collision_mesh functionality.

I discretized the robots workspace into 5cm cubes which I can toggle.

However the performance is really low in RViz with a framerate of 0/1/2 fps.

With multiple cubes that represent the ground floor: 2fps image

A single mesh to represent the ground floor: 31 fps image

Performance test with multiple cubes: 0 fps image

Is this expected behaviour? Are collision meshes not meant to be uesd for collision detection?

Is this performance due to using a VM?

for x in range(0, world_dimensions_x):
                for y in range(0, world_dimensions_y):
                    z = 4
                    self.add_collision_mesh_cube(x, y, z)
....
....
    def add_collision_mesh_cube(self, x: int, y: int, z: int):
        filepath = path.join(
            path.dirname(path.realpath(__file__)), "5cm_blender_cube.stl"
        )
        quat = Quaternion(x=1.0, y=0.0, z=0.0, w=0.0)

        center_coordinates_x = 17
        center_coordinates_y = 17
        center_coordinates_z = 4

        step_size = 0.05
        offset_z = -0.025

        x_rviz = x * step_size - (center_coordinates_x * step_size)
        y_rviz = y * step_size - (center_coordinates_y * step_size)
        z_rviz = z * step_size - (center_coordinates_z * step_size) + offset_z

        position = Point(x=x_rviz, y=y_rviz, z=z_rviz)
        id = str(x) + "_" + str(y) + "_" + str(z) + "_cube"
        self._moveit2.add_collision_mesh(
            filepath=filepath, id=id, position=position, quat_xyzw=quat
        )

My 5cm cube: 5cm_blender_cube.zip

AndrejOrsula commented 2 years ago

It is difficult to tell quantitatively, but the performance is expected to drop when such a large number of objects is added. No idea how large impact your VM has.

I think you might be looking for this:


Also, this issue is not related to this repository. Module pymoveit2 provides only interface to MoveIt 2 functionalities. Whatever MoveIt 2 / RViz 2 / ... does is out of the scope for this repository. Other place would be more suitable for this discussion.

marc-wittwer commented 2 years ago

Thanks for your reply.