31 from sr_robot_commander.sr_robot_commander
import SrRobotCommander
35 rospy.init_node(
"print_joints_position", anonymous=
True)
37 parser = argparse.ArgumentParser(description=
'A script to print hand and arm joint positions. ',
38 add_help=
True, usage=
'%(prog)s [-h] --angle_type ANGLE_TYPE',
39 formatter_class=argparse.RawTextHelpFormatter)
40 parser.add_argument(
'--angle_type', dest=
'angle_type',
42 help=
"ANGLE_TYPE should be either degrees or radians")
43 args = parser.parse_args()
45 angle_type = args.angle_type
46 if angle_type
not in [
'radians',
'degrees']:
51 if angle_type ==
"degrees":
56 robot_commander = SrRobotCommander(name=
"right_arm_and_hand")
59 all_joints_state = robot_commander.get_joints_position()
62 k: (v * scale)
for k, v
in all_joints_state.items()
63 if k.startswith(
"rh_")
and not k.startswith(
"rh_W")}
65 k: (v * scale)
for k, v
in all_joints_state.items()
66 if k.startswith(
"ra_")
or k.startswith(
"rh_W")}
68 rospy.loginfo(
"Joints positions:")
69 rospy.loginfo(
"Hand joints position \n " + str(hand_joints_state) +
"\n")
70 rospy.loginfo(
"Arm joints position \n " + str(arm_joints_state) +
"\n")