3 from __future__
import print_function
11 import pyreadline
as readline
17 from moveit_commander
import (
18 MoveGroupCommandInterpreter,
29 input = getattr(__builtin__,
"raw_input")
30 except (ImportError, AttributeError):
52 cmds = readline.get_line_buffer().split()
64 [s
for s
in self.
options.keys()
if s
and s.startswith(text)]
68 [s
for s
in self.
options[prefix]
if s
and s.startswith(text)]
79 response = self.
matches[state] +
" "
86 if level == MoveGroupInfoLevel.FAIL:
87 print(bcolors.FAIL + msg + bcolors.ENDC)
88 elif level == MoveGroupInfoLevel.WARN:
89 print(bcolors.WARNING + msg + bcolors.ENDC)
90 elif level == MoveGroupInfoLevel.SUCCESS:
91 print(bcolors.OKGREEN + msg + bcolors.ENDC)
92 elif level == MoveGroupInfoLevel.DEBUG:
93 print(bcolors.OKBLUE + msg + bcolors.ENDC)
99 kw = interpreter.get_keywords()
106 if len(group_name) > 0:
107 c.execute(
"use " + group_name)
109 readline.set_completer(completer.complete)
114 +
"Waiting for commands. Type 'help' to get a list of known commands."
118 readline.parse_and_bind(
"tab: complete")
120 while not rospy.is_shutdown():
124 ag = c.get_active_group()
127 cmd =
input(bcolors.OKBLUE + name +
"> " + bcolors.ENDC)
130 cmdorig = cmd.strip()
133 cmd = cmdorig.lower()
135 if cmd ==
"q" or cmd ==
"quit" or cmd ==
"exit":
139 MoveGroupInfoLevel.INFO,
140 "Master is '" + os.environ[
"ROS_MASTER_URI"] +
"'",
144 (level, msg) = c.execute(cmdorig)
152 if len(group_name) > 0:
153 c.execute(
"use " + group_name)
155 print(
"Running ROS service")
160 rospy.signal_shutdown(reason)
170 if __name__ ==
"__main__":
172 signal.signal(signal.SIGINT, sigint_handler)
177 "move_group_interface_cmdline", anonymous=
True, disable_signals=
True
180 parser = argparse.ArgumentParser(
181 usage=
"""%(prog)s [options] [<group_name>]""",
182 description=
"Command Line Interface to MoveIt",
190 help=
"Run the command processing script in interactive mode (default)",
198 help=
"Run the command processing script as a ROS service",
205 help=
"Group name to initialize the CLI for.",
208 opt = parser.parse_args(rospy.myargv()[1:])