def main():
"""SDK Gripper Example: Joystick Control
Use a game controller to control the grippers.
Attach a game controller to your dev machine and run this
example along with the ROS joy_node to control gripper
using the joysticks and buttons. Be sure to provide
the *joystick* type you are using as an argument to setup
appropriate key mappings.
Uses the intera_interface.Gripper class and the helper classes
in intera_external_devices.Joystick.
"""
epilog = """
See help inside the example with the "Start" button for controller
key bindings.
"""
rp = intera_interface.RobotParams()
valid_limbs = rp.get_limb_names()
if not valid_limbs:
rp.log_message(("Cannot detect any limb parameters on this robot. "
"Exiting."), "ERROR")
return
arg_fmt = argparse.RawDescriptionHelpFormatter
parser = argparse.ArgumentParser(formatter_class=arg_fmt,
description=main.__doc__,
epilog=epilog)
required = parser.add_argument_group('required arguments')
required.add_argument(
'-j', '--joystick', required=True, choices=['xbox', 'logitech', 'ps3'],
help='specify the type of joystick to use'
)
parser.add_argument(
"-l", "--limb", dest="limb", default=valid_limbs[0],
choices=valid_limbs,
help="Limb on which to run the gripper joystick example"
)
args = parser.parse_args(rospy.myargv()[1:])
joystick = None
if args.joystick == 'xbox':
joystick = intera_external_devices.joystick.XboxController()
elif args.joystick == 'logitech':
joystick = intera_external_devices.joystick.LogitechController()
elif args.joystick == 'ps3':
joystick = intera_external_devices.joystick.PS3Controller()
else:
# Should never reach this case with proper argparse usage
parser.error("Unsupported joystick type '%s'" % (args.joystick))
print("Initializing node... ")
rospy.init_node("sdk_gripper_joystick")
map_joystick(joystick, args.limb)
评论列表
文章目录