3 from __future__
import print_function
13 from moveit_commander
import MoveGroupCommandInterpreter, MoveGroupInfoLevel, roscpp_initialize, roscpp_shutdown
19 input = getattr(__builtin__,
'raw_input')
20 except (ImportError, AttributeError):
41 cmds = readline.get_line_buffer().split()
45 if not self.options.has_key(prefix):
53 for s
in self.options.keys()
54 if s
and s.startswith(text)])
58 if s
and s.startswith(text)])
61 self.
matches = sorted(self.options.keys())
68 response = self.
matches[state] +
" " 74 if level == MoveGroupInfoLevel.FAIL:
75 print(bcolors.FAIL + msg + bcolors.ENDC)
76 elif level == MoveGroupInfoLevel.WARN:
77 print(bcolors.WARNING + msg + bcolors.ENDC)
78 elif level == MoveGroupInfoLevel.SUCCESS:
79 print(bcolors.OKGREEN + msg + bcolors.ENDC)
80 elif level == MoveGroupInfoLevel.DEBUG:
81 print(bcolors.OKBLUE + msg + bcolors.ENDC)
86 kw = interpreter.get_keywords()
91 c = MoveGroupCommandInterpreter()
92 if len(group_name) > 0:
93 c.execute(
"use " + group_name)
95 readline.set_completer(completer.complete)
98 print(bcolors.HEADER +
"Waiting for commands. Type 'help' to get a list of known commands." + bcolors.ENDC)
100 readline.parse_and_bind(
'tab: complete')
102 while not rospy.is_shutdown():
106 ag = c.get_active_group()
109 cmd =
input(bcolors.OKBLUE + name +
'> ' + bcolors.ENDC)
112 cmdorig = cmd.strip()
115 cmd = cmdorig.lower()
117 if cmd ==
"q" or cmd ==
"quit" or cmd ==
"exit":
120 print_message(MoveGroupInfoLevel.INFO,
"Master is '" + os.environ[
'ROS_MASTER_URI'] +
"'")
123 (level, msg) = c.execute(cmdorig)
129 c = MoveGroupCommandInterpreter()
130 if len(group_name) > 0:
131 c.execute(
"use " + group_name)
133 print(
"Running ROS service")
137 rospy.signal_shutdown(reason)
145 if __name__==
'__main__':
147 signal.signal(signal.SIGINT, sigint_handler)
151 rospy.init_node(
'move_group_interface_cmdline', anonymous=
True, disable_signals=
True)
153 parser = argparse.ArgumentParser(usage =
"""%(prog)s [options] [<group_name>]""",
154 description =
"Command Line Interface to MoveIt!")
155 parser.add_argument(
"-i",
"--interactive", action=
"store_true", dest=
"interactive", default=
True,
156 help=
"Run the command processing script in interactive mode (default)")
157 parser.add_argument(
"-s",
"--service", action=
"store_true", dest=
"service", default=
False,
158 help=
"Run the command processing script as a ROS service")
159 parser.add_argument(
"group_name", type=str, default=
"", nargs=
'?', help=
"Group name to initialize the CLI for.")
161 opt = parser.parse_args(rospy.myargv()[1:])
def __init__(self, options)
def run_interactive(group_name)
def complete(self, text, state)
def roscpp_initialize(args)
def set_options(self, options)
def print_message(level, msg)
def get_context_keywords(interpreter)
def run_service(group_name)
def sigint_handler(signal, frame)