-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBox_In_Plane.py
47 lines (32 loc) · 1.44 KB
/
Box_In_Plane.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# We will now add a Box into our Pybullet Simulation
# Importing the needed Python libraries for plane/box simulation
import pybullet as p
import pybullet_data
Connecting_to_pybullet = p.connect(p.GUI)
Gravity = p.setGravity(0, 0, -9.8)
p.setAdditionalSearchPath(pybullet_data.getDataPath())
coordinates = [0, 0, 0]
oreintation = [0, 0, 0]
intial_oreintation = p.getQuaternionFromEuler(oreintation)
Plane = p.loadURDF("plane.urdf", coordinates, intial_oreintation)
# If the stuff above did not make sense, practice Plane_Exercise first,
# until you can set it up on your own
# Now we will build our Box
halfExtents = [0.5, 0.5, 0.5] # Dimensions of our box
# Coordinates & Orientation of our box
box_coordinates = [0, 0, 0]
box_oreintation = [0, 0, 0]
# to make life simple use Quaternion's for pybullet
intial_box_orientation = p.getQuaternionFromEuler(box_oreintation)
# Create collision body
Collisionbody = p.createCollisionShape(shapeType=p.GEOM_BOX, halfExtents=halfExtents)
# Create visionbody
visualBody = p.createVisualShape(shapeType=p.GEOM_BOX, halfExtents=halfExtents, rgbaColor=[1, 0, 0, 1])
# Create multibody
Multibody = p.createMultiBody(baseMass=1, baseCollisionShapeIndex=Collisionbody,
baseVisualShapeIndex=visualBody,
basePosition=box_coordinates,
baseOrientation=intial_box_orientation)
while True:
p.stepSimulation()
p.setTimeStep(1 / 240)