-
Notifications
You must be signed in to change notification settings - Fork 131
/
testmotion.py
executable file
·55 lines (43 loc) · 1.39 KB
/
testmotion.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/usr/bin/python
#
# Send joint values to UR5 using messages
#
from std_msgs.msg import Header
from trajectory_msgs.msg import JointTrajectory
from trajectory_msgs.msg import JointTrajectoryPoint
import rospy
waypoints = [[0.0, -1.44, 1.4, 0.6, 0, -0.33], [0,0,0,0,0,0]]
def main():
rospy.init_node('send_joints')
pub = rospy.Publisher('/arm_controller/command',
JointTrajectory,
queue_size=10)
# Create the topic message
traj = JointTrajectory()
traj.header = Header()
# Joint names for UR5
traj.joint_names = ['shoulder_pan_joint', 'shoulder_lift_joint',
'elbow_joint', 'wrist_1_joint', 'wrist_2_joint',
'wrist_3_joint']
rate = rospy.Rate(1)
cnt = 0
pts = JointTrajectoryPoint()
traj.header.stamp = rospy.Time.now()
while not rospy.is_shutdown():
cnt += 1
if cnt%2 == 1:
pts.positions = waypoints[0]
else:
pts.positions = waypoints[1]
pts.time_from_start = rospy.Duration(1.0)
# Set the points to the trajectory
traj.points = []
traj.points.append(pts)
# Publish the message
pub.publish(traj)
rate.sleep()
if __name__ == '__main__':
try:
main()
except rospy.ROSInterruptException:
print ("Program interrupted before completion")