-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathsawyer_test.py
55 lines (42 loc) · 1.73 KB
/
sawyer_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
import time
import os
import sys
if os.environ.get('ROS_DISTRO'):
import rospy
import pybullet as p
from cairo_simulator.core.utils import ASSETS_PATH
from cairo_simulator.core.log import Logger
from cairo_simulator.core.simulator import Simulator, SimObject
from cairo_simulator.devices.manipulators import Sawyer
def main():
if os.environ.get('ROS_DISTRO'):
rospy.init_node("CAIRO_Sawyer_Simulator")
use_ros = True
else:
use_ros = False
use_real_time = True
logger = Logger()
sim = Simulator(logger=logger, use_ros=use_ros, use_real_time=use_real_time) # Initialize the Simulator
p.configureDebugVisualizer(p.COV_ENABLE_RENDERING,0)
p.setPhysicsEngineParameter(enableFileCaching=0)
ground_plane = SimObject("Ground", "plane.urdf", [0,0,0])
# Add a table and a Sawyer robot
table = SimObject("Table", ASSETS_PATH + 'table.sdf', (0.9, 0, 0), (0, 0, 1.5708)) # Table rotated 90deg along z-axis
print(p.getNumJoints(table.get_simulator_id()))
sawyer_robot = Sawyer("sawyer0", [0, 0, 0.8], fixed_base=1)
p.configureDebugVisualizer(p.COV_ENABLE_RENDERING,1)
sim_obj = SimObject('cube0', 'cube_small.urdf', (0.75, 0, .55))
sim_obj = SimObject('cube1', 'cube_small.urdf', (0.74, 0.05, .55))
sim_obj = SimObject('cube2', 'cube_small.urdf', (0.67, -0.1, .55))
sim_obj = SimObject('cube3', 'cube_small.urdf', (0.69, 0.1, .55))
joint_config = sawyer_robot.solve_inverse_kinematics([0.9,0,1.5], [0,0,0,1])
#sawyer_robot.move_to_joint_pos(joint_config)
# Loop until someone shuts us down
try:
while True:
sim.step()
except KeyboardInterrupt:
p.disconnect()
sys.exit(0)
if __name__ == "__main__":
main()