4 This file gives a demonstration of sending a waypoint trajectory programatically. 5 The trajectory action server can be invoked in two separate ways- 6 1) Through an actionlib client 7 2) Through publishing to a topic 9 Both methods are exemplified here. 14 from trajectory_msgs.msg
import JointTrajectory, JointTrajectoryPoint
15 from control_msgs.msg
import FollowJointTrajectoryAction, FollowJointTrajectoryGoal
19 client = actionlib.SimpleActionClient(
'/revel_trajectory_controller/follow_joint_trajectory', FollowJointTrajectoryAction)
20 pub = rospy.Publisher(
'/revel_trajectory_controller/command', JointTrajectory, queue_size=10)
21 rospy.init_node(
'trajectory_tester', anonymous=
True)
22 traj = JointTrajectory()
23 traj.joint_names.append(
"joint_1")
24 traj.joint_names.append(
"joint_2")
25 traj.joint_names.append(
"joint_3")
26 traj.joint_names.append(
"joint_4")
27 traj.joint_names.append(
"joint_5")
28 traj.joint_names.append(
"joint_6")
29 jtp = JointTrajectoryPoint()
30 jtp.positions.append(0.0)
31 jtp.positions.append(0.0)
32 jtp.positions.append(0.0)
33 jtp.positions.append(0.0)
34 jtp.positions.append(0.0)
35 jtp.positions.append(0.0)
36 jtp.velocities.append(1.0)
37 jtp.velocities.append(1.0)
38 jtp.velocities.append(1.0)
39 jtp.velocities.append(1.0)
40 jtp.velocities.append(1.0)
41 jtp.velocities.append(1.0)
42 jtp.time_from_start = rospy.Duration(0.0)
44 traj.points.append(jtp)
45 traj.header.stamp = rospy.Time.now()
50 goal = FollowJointTrajectoryGoal()
51 goal.trajectory = traj
52 goal.goal_time_tolerance = rospy.Duration(4.0)
54 client.wait_for_server()
56 client.send_goal(goal)
58 if __name__ ==
'__main__':
61 except rospy.ROSInterruptException: