-
Notifications
You must be signed in to change notification settings - Fork 0
/
manipulator_server.py
93 lines (83 loc) · 3.07 KB
/
manipulator_server.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
import logging
import argparse
from manipulator_gym.interfaces.interface_service import ManipulatorInterfaceServer
from manipulator_gym.interfaces.base_interface import ManipulatorInterface
if __name__ == "__main__":
"""
Runs the ManipulatorServer on a robot machine with rospy installed.
When running on the actual ros robot, this requires the bringup of
- interbotix_xsarm_control)/launch/xsarm_control.launch
- usb camara published to /gripper_cam and /third_perp_cam
"""
parser = argparse.ArgumentParser(description="Manipulator Server")
parser.add_argument(
"--viperx", action="store_true", help="run the environment with the ViperX"
)
parser.add_argument(
"--widowx", action="store_true", help="run the environment with the WidowX"
)
parser.add_argument(
"--widowx_sim", action="store_true", help="run the environment with the WidowX"
)
parser.add_argument(
"--widowx_ros2",
action="store_true",
help="run the environment with the WidowX ros2",
)
parser.add_argument(
"--cam_ids",
type=int,
nargs="+",
default=[],
help="camera ids to use for the interface",
)
parser.add_argument(
"--non_blocking",
action="store_true",
help="run the environment with non_blocking control",
)
parser.add_argument(
"--resize_img",
type=int,
nargs=2,
default=None,
help="resize the image before sending to the client",
)
args = parser.parse_args()
# set logging to warning
logging.basicConfig(level=logging.WARNING)
_blocking = not args.non_blocking # default is blocking
if args.viperx:
from manipulator_gym.interfaces.viperx import ViperXInterface
print("Using ViperX interface")
interface = ViperXInterface(init_node=True, blocking_control=_blocking)
elif args.widowx:
from manipulator_gym.interfaces.widowx import WidowXInterface
print("Using WidowX interface")
blocking = not args.non_blocking
cam_ids = args.cam_ids if len(args.cam_ids) > 0 else None
interface = WidowXInterface(
init_node=True, blocking_control=_blocking, cam_ids=cam_ids
)
elif args.widowx_sim:
from manipulator_gym.interfaces.widowx_sim import WidowXSimInterface
print("Using WidowXSim interface")
interface = WidowXSimInterface()
elif args.widowx_ros2:
from manipulator_gym.interfaces.widowx_ros2 import WidowXRos2Interface
print("Using WidowXRos2 interface")
assert 0 < len(args.cam_ids) <= 2, "should provide 1 or 2 camera ids"
interface = WidowXRos2Interface(
cam_ids=args.cam_ids, blocking_control=_blocking
)
else:
print("Using base test interface")
interface = ManipulatorInterface()
# start the agentlace server
server = ManipulatorInterfaceServer(
manipulator_interface=interface,
resize_img=args.resize_img,
)
server.start()
server.stop()
print("Server stopped")