Robotics StackExchange | Archived questions

joint trajectory published but not executed

Hi, I validated my robot description by sending a joint trajectory message via terminal to my Jointtrajectorycontroller and it seems to work fine.

I want to write a script that builds a trajectory and publishes it for my robot to execute.

I seem to have achieved my goal as the trajectory is published ( i can see it has been by running rostopic echo)

The problem is that the trajectory is not executed by my robot (contrary to when i publish it via terminal).

I don't see any messages from the roscore when i publish it even if I intentionally input invalid data.

Here is the code i produced.

import rospy
from trajectory_msgs.msg import JointTrajectory, JointTrajectoryPoint
from std_msgs.msg import Header

import numpy as np
from numpy import genfromtxt

if __name__ == "__main__":

    pub_shaft_scanner = rospy.Publisher('/shaft_scanner_trajectory_controller/command', JointTrajectory, queue_size=10)

    rospy.init_node('shaft_scanner_pub')
    points = genfromtxt('./shaft/trajectory1.txt', delimiter=',')
    joint_trajectory_msg = JointTrajectory()
    joint_trajectory_msg.header = Header()
    joint_trajectory_msg.header.stamp = rospy.Time.now()

    joint_trajectory_msg.joint_names = ["lift_x", "lift_y", "lift_z"]
    joint_trajectory_point = JointTrajectoryPoint()

    joint_trajectory_point.positions = [1,11,5]

    joint_trajectory_point.velocities= [1,1,1]
    joint_trajectory_point.accelerations = [0, 0, 0]
    joint_trajectory_point.effort = [0, 0, 0]
    joint_trajectory_point.time_from_start.secs = 1

    joint_trajectory_msg.points = [joint_trajectory_point]

    pub_shaft_scanner.publish(joint_trajectory_msg)

The trajectory message that i used to test in the terminal (and works) is the following

rostopic pub /shaft_scanner_trajectory_controller/command trajectory_msgs/JointTrajectory "header:
seq: 0
stamp:
    secs: 0
    nsecs: 0
frame_id: ''
joint_names: [lift_x, lift_y, lift_z]
points:
- positions: [1, 1, 1]
  velocities: [0,0,0]
  accelerations: [0,0,0]
  effort: [0,0,0]
  time_from_start: {secs: 0, nsecs: 1}" 

Note that if I intentionally input invalid data i get an error message or a warning printed in the roscore log.

If you have a hint to help me it would be greatly appreciated.

Asked by wonwon0 on 2020-10-06 12:45:03 UTC

Comments

Answers