-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmovement_test.py
118 lines (97 loc) · 3.92 KB
/
movement_test.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
import pybullet as p
import random
import time
import pybullet_data
physicsClient = p.connect(p.GUI)
p.setAdditionalSearchPath(pybullet_data.getDataPath())
planeId = p.loadURDF("plane.urdf", [0, 0, -.98])
# load robot
# load robot
bot_start_position = [0, 0, 0]
bot_start_orientation = p.getQuaternionFromEuler([0, 0, 0])
# TODO define robot position and orientation
bot = p.loadURDF("/u/teddy/Robotics_Research/catkin_ws/Perturbative_Training/rudis_magic_sawyer.urdf",
bot_start_position, bot_start_orientation)
sphereRadius = 0.05
colSphereId = p.createCollisionShape(p.GEOM_SPHERE, radius=sphereRadius)
colBoxId = p.createCollisionShape(p.GEOM_BOX,
halfExtents=[sphereRadius, sphereRadius, sphereRadius])
colTableId = p.createCollisionShape(p.GEOM_BOX,
halfExtents=[0.8, 0.2, 0.38])
mass = 1
visualShapeId = -1
link_Masses = [1]
linkCollisionShapeIndices = [colBoxId]
linkVisualShapeIndices = [-1]
linkPositions = [[0, 0, 0.11]]
linkOrientations = [[0, 0, 0, 1]]
linkInertialFramePositions = [[0, 0, 0]]
linkInertialFrameOrientations = [[0, 0, 0, 1]]
indices = [0]
jointTypes = [p.JOINT_REVOLUTE]
axis = [[0, 0, 1]]
sphereBasePosition = [
0, 2, 1
]
sphere2BasePosition = [
-2, 2, 1
]
boxBasePosition = [
2, 2, 1
]
tableBasePosition = [
0.5, 0, 1
]
baseOrientation = [0, 0, 0, 1]
sphereUid = p.createMultiBody(mass, colSphereId, visualShapeId, sphereBasePosition,
baseOrientation)
sphereUid = p.createMultiBody(mass, colSphereId, visualShapeId, sphere2BasePosition,
baseOrientation)
sphereUid = p.createMultiBody(mass,
colBoxId,
visualShapeId,
boxBasePosition,
baseOrientation,
linkMasses=link_Masses,
linkCollisionShapeIndices=linkCollisionShapeIndices,
linkVisualShapeIndices=linkVisualShapeIndices,
linkPositions=linkPositions,
linkOrientations=linkOrientations,
linkInertialFramePositions=linkInertialFramePositions,
linkInertialFrameOrientations=linkInertialFrameOrientations,
linkParentIndices=indices,
linkJointTypes=jointTypes,
linkJointAxis=axis)
# table
sphereUid = p.createMultiBody(500,
colTableId,
visualShapeId,
tableBasePosition,
baseOrientation,
linkMasses=link_Masses,
linkCollisionShapeIndices=linkCollisionShapeIndices,
linkVisualShapeIndices=linkVisualShapeIndices,
linkPositions=linkPositions,
linkOrientations=linkOrientations,
linkInertialFramePositions=linkInertialFramePositions,
linkInertialFrameOrientations=linkInertialFrameOrientations,
linkParentIndices=indices,
linkJointTypes=jointTypes,
linkJointAxis=axis)
p.changeDynamics(sphereUid,
-1,
spinningFriction=0.001,
rollingFriction=0.001,
linearDamping=0.0)
for joint in range(p.getNumJoints(sphereUid)):
p.setJointMotorControl2(
sphereUid, joint, p.VELOCITY_CONTROL, targetVelocity=1, force=10)
p.setGravity(0, 0, -10)
p.setRealTimeSimulation(1)
p.getNumJoints(sphereUid)
for i in range(p.getNumJoints(sphereUid)):
p.getJointInfo(sphereUid, i)
while (1):
keys = p.getKeyboardEvents()
print(keys)
time.sleep(0.01)