23 from sr_robot_commander.sr_hand_commander
import SrHandCommander
24 from sr_utilities.hand_finder
import HandFinder
29 rospy.init_node(
"print_joints_position", anonymous=
True)
31 parser = argparse.ArgumentParser(description=
'A script to print hand and arm joint positions. ',
32 add_help=
True, usage=
'%(prog)s [-h] --angle_type ANGLE_TYPE',
33 formatter_class=argparse.RawTextHelpFormatter)
35 parser.add_argument(dest=
'--angle_type', help=
"ANGLE_TYPE should be either degrees or radians")
36 args = parser.parse_args()
38 angle_type = args.angle_type
41 hand_finder = HandFinder()
42 hand_parameters = hand_finder.get_hand_parameters()
43 prefix = hand_parameters.mapping.values()[0]
44 hand_serial = hand_parameters.mapping.keys()[0]
47 if angle_type ==
"degrees":
50 hand_commander = SrHandCommander(hand_parameters=hand_parameters, hand_serial=hand_serial)
52 print(
"Joints positions")
54 all_joints_state = hand_commander.get_joints_position()
58 k: (v * scale)
for k, v
in all_joints_state.items()
59 if k.startswith(prefix +
"_")
and not k.startswith(prefix +
"_W")}
61 k: (v * scale)
for k, v
in all_joints_state.items()
62 if k.startswith(prefix[0] +
"a_")
or k.startswith(prefix +
"_W")}
65 print(
"Hand joints position \n " + str(hand_joints_state) +
"\n")
67 print(
"Arm joints position \n " + str(arm_joints_state) +
"\n")