39 from std_msgs.msg
import Bool
42 from trajectory_msgs.msg
import JointTrajectoryPoint
43 from control_msgs.msg
import JointTrajectoryAction, JointTrajectoryGoal, FollowJointTrajectoryAction, FollowJointTrajectoryGoal
44 from sensor_msgs.msg
import JointState
45 from std_msgs.msg
import Int32
48 Plays back poses from an interaction file and controls the gripper as an Action 59 req = SvenzvaJointGoal()
60 if len(qmap[state_name]) < 6:
61 rospy.logerr(
"Could not find specified state. Configuration file ill-formed or missing. Aborting.")
63 req.positions = qmap[state_name]
65 rospy.loginfo(
"Sending state command...")
66 fkine.send_goal_and_wait(req)
73 rospy.init_node(
'svenzva_pick_place_demo', anonymous=
False)
74 global qmap, fkine, joint_states
77 joint_states = JointState()
79 joint_states_sub = rospy.Subscriber(
'/joint_states', JointState, js_cb, queue_size=1)
82 fkine.wait_for_server()
83 rospy.loginfo(
"Found Trajectory action server")
85 gripper_client.wait_for_server()
86 rospy.loginfo(
"Found Revel gripper action server")
92 rospack = rospkg.RosPack()
93 path = rospack.get_path(
'svenzva_demo')
99 while(
not rospy.is_shutdown()):
100 raw_input(
"Press Enter to save the current joint state to file...")
101 name = raw_input(
"What to name this point: ")
102 f = open(path+
"/config/" + filename +
".yaml",
"a")
104 ar.append(joint_states.position[0])
105 ar.append(joint_states.position[1])
106 ar.append(joint_states.position[2])
107 ar.append(joint_states.position[3])
108 ar.append(joint_states.position[4])
109 ar.append(joint_states.position[5])
110 f.write(name +
": " + str(ar) +
"\n")
113 f = open(path+
"/config/" + filename +
".yaml")
114 qmap = yaml.safe_load(f)
122 goal.target_action = goal.OPEN
123 gripper_client.send_goal(goal)
132 goal.target_action = goal.CLOSE
133 goal.target_current = 50
134 gripper_client.send_goal(goal)
147 goal.target_action = goal.OPEN
148 gripper_client.send_goal(goal)
163 goal.target_action = gripper.OPEN 164 gripper_client.send_goal(goal) 167 #go forward to approach point 168 js_playback(fname, "a1") 171 goal.target_action = gripper.CLOSE 172 goal.target_current = 50 173 gripper_client.send_goal(goal) 177 js_playback(fname, "p2") 179 goal.target_action = gripper.OPEN 180 gripper_client.send_goal(goal) 184 js_playback(fname, "home") 185 rospy.loginfo("Arm homed. Demo complete") 189 if __name__ ==
'__main__':
192 except rospy.ROSInterruptException:
def js_playback(filename, state_name)