Problem when importing mesh as ground

Official Python bindings with a focus on reinforcement learning and robotics.
Post Reply
yconst
Posts: 3
Joined: Tue Dec 12, 2017 11:31 pm
Contact:

Problem when importing mesh as ground

Post by yconst » Tue Dec 12, 2017 11:40 pm

I'm trying to import a mesh to use as ground. I'm using the following code:

Code: Select all

        visualShift = [0, 0, 0]
        shift = [0, 0, -0.1]
        meshScale=[0.1, 0.1, 0.1]
        path = os.path.abspath(os.path.dirname(__file__))
        self.groundColId = p.createCollisionShape(shapeType=p.GEOM_MESH, 
                                                  fileName=os.path.join(path, "ground.obj"), 
                                                  collisionFramePosition=shift,
                                                  meshScale=meshScale)
        self.groundVisID = p.createVisualShape(shapeType=p.GEOM_MESH, 
                                            fileName=os.path.join(path, "ground.obj"), 
                                            rgbaColor=[1,1,1,1],
                                            specularColor=[0.4,.4,0],
                                            visualFramePosition=visualShift,
                                            meshScale=meshScale)
        self.groundId = p.createMultiBody(baseMass=0,
                                              baseInertialFramePosition=[0,0,0],
                                              baseCollisionShapeIndex=self.groundColId, 
                                              baseVisualShapeIndex=self.groundVisID, 
                                              basePosition=[0,0,0], 
                                              useMaximalCoordinates=True)
The imported object looks ok (has bumps as it should) but it seems that the collision shape is flat.
Screen Shot 2017-12-13 at 01.34.17.png
Screen Shot 2017-12-13 at 01.34.17.png (161.57 KiB) Viewed 253 times
I am not importing anything else apart from this object and the robot seen in the image above.

Is there any mistake I am doing in importing the mesh?

Thank you

User avatar
Erwin Coumans
Site Admin
Posts: 4103
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA
Contact:

Re: Problem when importing mesh as ground

Post by Erwin Coumans » Wed Dec 13, 2017 2:18 am

Use the flags=GEOM_FORCE_CONCAVE_TRIMESH in the createCollisionShape command.

yconst
Posts: 3
Joined: Tue Dec 12, 2017 11:31 pm
Contact:

Re: Problem when importing mesh as ground

Post by yconst » Wed Dec 13, 2017 9:49 am

That did the trick, thanks!

Post Reply