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
46 from collections
import deque
55 req = SvenzvaJointGoal()
56 if len(qmap[state_name]) < 6:
57 rospy.logerr(
"Could not find specified state. Configuration file ill-formed or missing. Aborting.")
59 req.positions = qmap[state_name]
61 rospy.loginfo(
"Sending state command...")
62 fkine.send_goal_and_wait(req)
66 global joint_states, states_list
68 states_list.append(data)
72 rospy.init_node(
'svenzva_pick_place_demo', anonymous=
False)
73 global qmap, fkine, joint_states, states_list
75 states_list = deque(maxlen=10)
77 record = rospy.get_param(
'record_points',
False)
78 joint_states = JointState()
80 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")
90 filename =
"full_pick_and_place" 92 rospack = rospkg.RosPack()
93 path = rospack.get_path(
'svenzva_demo')
98 while(
not rospy.is_shutdown()):
99 raw_input(
"Press Enter to save the current joint state to file. Enter q/Q for exit.")
100 saved_js = joint_states
101 name = raw_input(
"What to name this point: ")
102 if name ==
'q' or name ==
'Q':
104 f = open(path+
"/config/" + filename +
".yaml",
"a")
106 ar.append(saved_js.position[0])
107 ar.append(saved_js.position[1])
108 ar.append(saved_js.position[2])
109 ar.append(saved_js.position[3])
110 ar.append(saved_js.position[4])
111 ar.append(saved_js.position[5])
112 f.write(name +
": " + str(ar) +
"\n")
116 f = open(path+
"/config/" + filename +
".yaml")
117 qmap = yaml.safe_load(f)
124 while not rospy.is_shutdown():
127 Grab an existing item from location 1 152 Take an item from human and drop it off at location 2 174 Take an item from human and take to location 1 191 Pick up item from location 2 and hand to human 219 goal.target_action = goal.CLOSE 220 goal.target_current = 400 221 gripper_client.send_goal(goal) 224 js_playback(fname, "lift1") 225 js_playback(fname, "lift2") 226 js_playback(fname, "lift1") 227 js_playback(fname, "grasp") 231 goal.target_action = goal.OPEN 232 gripper_client.send_goal(goal) 235 js_playback(fname, "approach") 236 js_playback(fname, "home") 240 while not rospy.is_shutdown(): 242 goal.target_action = goal.CLOSE 243 goal.target_current = 100 244 gripper_client.send_goal(goal) 252 goal.target_action = goal.OPEN
257 goal.target_action = goal.CLOSE
258 goal.target_current = target_current
262 while not rospy.is_shutdown():
269 while not rospy.is_shutdown():
277 Returns whether or not the gripper wrist feels a non-negligible external force 280 global joint_states, states_list
284 while not rospy.is_shutdown():
286 for state
in list(states_list):
287 avg = avg + state.effort[5]
288 avg = avg / len(states_list)
290 if abs(avg - joint_states.effort[5]) > delta:
294 if __name__ ==
'__main__':
297 except rospy.ROSInterruptException:
def feel_and_open_gripper()
def close_gripper(target_current)
def js_playback(filename, state_name)
def feel_and_close_gripper(target_current)