8 from trajectory_msgs.msg
import JointTrajectory,JointTrajectoryPoint
9 from control_msgs.msg
import FollowJointTrajectoryAction, FollowJointTrajectoryGoal
12 def __init__(self, time=1.0, step=0.01, freq=1.0, joint_num=1, topic='/joint_trajectory', action='/joint_trajectroy_action'):
18 self.
pub = rospy.Publisher(topic, JointTrajectory, queue_size=10)
19 self.
client = actionlib.SimpleActionClient(
20 action, FollowJointTrajectoryAction)
25 self.
phase = np.random.uniform(np.pi)
26 while tick <= self.
time:
31 points.append(JointTrajectoryPoint(positions=positions,
32 velocities=velocities,
33 accelerations=accelerations,
34 time_from_start=rospy.Time.from_sec(tick)))
36 msg = JointTrajectory(joint_names=self.
joint_names, points=points)
37 msg.header.stamp = rospy.Time.now()
41 goal = FollowJointTrajectoryGoal()
43 self.client.send_goal(goal)
45 if __name__ ==
"__main__":
46 rospy.init_node(
'joint_trajectory_generator')
48 parser = argparse.ArgumentParser()
49 parser.add_argument(
'--time-step', type=float, help=
'Time step between each trajectory point')
50 parser.add_argument(
'--topic', type=str, default=
"/joint_trajectory", help=
'Topic name to be published')
51 parser.add_argument(
'--action', type=str, default=
"/joint_trajectory_action", help=
'Action name to be called')
52 parser.add_argument(
'--joint-num', type=int, default=1, help=
'Number of joints')
53 sys.argv = rospy.myargv()
54 args = parser.parse_args()
61 while not rospy.is_shutdown():
def __init__(self, time=1.0, step=0.01, freq=1.0, joint_num=1, topic='/joint_trajectory', action='/joint_trajectroy_action')