23 from sr_robot_commander.sr_hand_commander
import SrHandCommander
24 from sr_utilities.hand_finder
import HandFinder
25 from numpy
import arange
30 rospy.init_node(
"print_hand_joints_position", anonymous=
True)
32 parser = argparse.ArgumentParser(description=
'A script to print hand joint positions. ',
33 add_help=
True, usage=
'%(prog)s [-h] --angle_type ANGLE_TYPE',
34 formatter_class=argparse.RawTextHelpFormatter)
36 parser.add_argument(
"--angle_type", default=
"radians", help=
"ANGLE_TYPE should be either degrees or radians")
37 args = parser.parse_args()
39 angle_type = args.angle_type
42 hand_finder = HandFinder()
43 hand_parameters = hand_finder.get_hand_parameters()
45 prefix = hand_parameters.mapping.values()
46 hand_serial = hand_parameters.mapping.keys()
49 if angle_type ==
"degrees":
52 for i
in arange(0, len(prefix)):
53 hand_commander = SrHandCommander(hand_parameters=hand_parameters, hand_serial=hand_serial[i])
55 print(
"Joints positions")
57 all_joints_state = hand_commander.get_joints_position()
60 k: (v * scale)
for k, v
in all_joints_state.items()
if k.startswith(prefix[i] +
"_")}
62 print(
"Hand joints position \n " + str(hand_joints_state) +
"\n")