trajectory_publisher.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 
3 """
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
8 
9 Both methods are exemplified here.
10 """
11 
12 import rospy
13 import actionlib
14 from trajectory_msgs.msg import JointTrajectory, JointTrajectoryPoint
15 from control_msgs.msg import FollowJointTrajectoryAction, FollowJointTrajectoryGoal
16 
18  action_client = True
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)
43 
44  traj.points.append(jtp)
45  traj.header.stamp = rospy.Time.now()
46 
47  if not action_client:
48  pub.publish(traj)
49  else:
50  goal = FollowJointTrajectoryGoal()
51  goal.trajectory = traj
52  goal.goal_time_tolerance = rospy.Duration(4.0)
53 
54  client.wait_for_server()
55  print 'Found server'
56  client.send_goal(goal)
57 
58 if __name__ == '__main__':
59  try:
60  publish_goal()
61  except rospy.ROSInterruptException:
62  pass
63 


svenzva_simulation
Author(s): Max Svetlik
autogenerated on Wed Oct 28 2020 03:31:30