0

I am working on a simulation project involving a quadrotor in a Mars-like environment using PyBullet in Python. I have successfully loaded a custom terrain from an STL file, but I am facing an issue with collision detection between the quadrotor and the terrain.

The problem is that the quadrotor does not seem to collide with the terrain correctly. Instead, it lands on an invisible plane that seems to be at the same height as the highest point of the terrain. The terrain itself has unevenness, but the quadrotor does not recognize these variations. .

Here is a picture showing the problem:

enter image description here

This is the code i used to upload the terrain:

def load_mars_surface(p, filename): #Load mars terrain using STL or OBJ approach
    mars_surface_shape = p.createCollisionShape(shapeType=p.GEOM_MESH, fileName=filename)
    mars_surface_visual = p.createVisualShape(shapeType=p.GEOM_MESH, fileName=filename)
    mars_surface_position = [0, 0, 0]
    mars_surface_orientation = p.getQuaternionFromEuler([0, 0, 0])

    mars_surface_body = p.createMultiBody(baseMass=0, baseCollisionShapeIndex=mars_surface_shape,
                                          baseVisualShapeIndex=mars_surface_visual,
                                          basePosition=mars_surface_position,
                                          baseOrientation=mars_surface_orientation)

    return mars_surface_body



def init_mars_env():
    connection_id = p.connect(p.GUI)  # Connect to the physics engine
    p.setGravity(0, 0, -3.721)  # Set Mars gravity (-3.721 m/s^2)

    p.setAdditionalSearchPath(pybullet_data.getDataPath())  # Set path for additional resources
    filename = "curiosity.stl"
    load_mars_surface(p, filename)

    return connection_id

I have already tried to convert the terrain from STL to other formats like OBJ and URDF.

Could anyone please provide some guidance on how to solve this problem? Is there a specific way to load custom terrain and ensure proper collision detection in PyBullet?

James Z
  • 12,209
  • 10
  • 24
  • 44

0 Answers0