forked from personalrobotics/herbpy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconsole.py
executable file
·50 lines (42 loc) · 1.87 KB
/
console.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
#!/usr/bin/env python
"""
Provides a simple console that sets up basic functionality for
using herbpy and openravepy.
"""
import os
if os.environ.get('ROS_DISTRO', 'hydro')[0] <= 'f':
import roslib
roslib.load_manifest('herbpy')
import argparse, herbpy, logging, numpy, openravepy, sys
if __name__ == "__main__":
parser = argparse.ArgumentParser(description='utility script for loading HerbPy')
parser.add_argument('-s', '--sim', action='store_true',
help='simulation mode')
parser.add_argument('-v', '--viewer', nargs='?', const=True,
help='attach a viewer of the specified type')
parser.add_argument('--robot-xml', type=str,
help='robot XML file; defaults to herb_description')
parser.add_argument('--env-xml', type=str,
help='environment XML file; defaults to an empty environment')
parser.add_argument('-b', '--segway-sim', action='store_true',
help='simulate base')
parser.add_argument('-p', '--perception-sim', action='store_true',
help='simulate perception')
parser.add_argument('--debug', action='store_true',
help='enable debug logging')
args = parser.parse_args()
openravepy.RaveInitialize(True)
openravepy.misc.InitOpenRAVELogging()
if args.debug:
openravepy.RaveSetDebugLevel(openravepy.DebugLevel.Debug)
herbpy_args = {'sim':args.sim,
'attach_viewer':args.viewer,
'robot_xml':args.robot_xml,
'env_path':args.env_xml,
'segway_sim':args.segway_sim,
'perception_sim': args.perception_sim}
if args.sim and not args.segway_sim:
herbpy_args['segway_sim'] = args.sim
env, robot = herbpy.initialize(**herbpy_args)
import IPython
IPython.embed()