AssertionError: The 'time_from_start' field must be a sub message of type 'Duration'
Hi everyone,
i created a python node, that should controll a Universal Robot UR10 via a Joint Trajectory. Here's its code:
#!/usr/bin/env python3
import rclpy
from rclpy.node import Node
from rclpy.time import Duration
from trajectory_msgs.msg import JointTrajectory, JointTrajectoryPoint
class Ur10ManualJoints(Node):
def __init__(self):
super().__init__('Ur10ManualJoints')
#Publisher creation
self.publisher = self.create_publisher(JointTrajectory, 'joint_trajectory', 10)
joint_name = ['shoulder_pan_joint', 'shoulder_lift_joint','elbow_joint', 'wrist_1_joint', 'wrist_2_joint', 'wrist_3_joint']
joint_pos = []
for joint_name in joint_name:
pos = input(f'Gebe Position für {joint_name} ein:') # Translation: Enter position for {joint_name}
joint_pos.append(float(pos))
#Constructing the Message
joint_traj_msg = JointTrajectory()
joint_traj_msg.joint_names = joint_name
point = JointTrajectoryPoint()
point.positions = joint_pos
point.time_from_start = Duration(seconds=10)
joint_traj_msg.points.append(point)
#Publish th msg
self.get_logger().info(f"[HINWEIS] Nachricht: {joint_traj_msg} wurde veröffentlicht") #Translation: Message {joint_traj_msg} was published
self.publisher.publish(joint_traj_msg)
def main(args=None):
rclpy.init(args=args)
node = Ur10ManualJoints()
rclpy.spin(node)
rclpy.shutdown()
if __name__ == '__main__':
main()
And here's the Error i get when running the node:
ros2 run ur10_faps_driver Ur10ManualJoints
Gebe Position für shoulder_pan_joint ein:1
Gebe Position für shoulder_lift_joint ein:1
Gebe Position für elbow_joint ein:1
Gebe Position für wrist_1_joint ein:1
Gebe Position für wrist_2_joint ein:1
Gebe Position für wrist_3_joint ein:1
Traceback (most recent call last):
File "/home/ubuntu/Schreibtisch/ros2_ws/install/ur10_faps_driver/lib/ur10_faps_driver/Ur10ManualJoints", line 33, in <module>
sys.exit(load_entry_point('ur10-faps-driver==0.0.0', 'console_scripts', 'Ur10ManualJoints')())
File "/home/ubuntu/Schreibtisch/ros2_ws/install/ur10_faps_driver/lib/python3.10/site-packages/ur10_faps_driver/Ur10ManualJoints.py", line 39, in main
node = Ur10ManualJoints()
File "/home/ubuntu/Schreibtisch/ros2_ws/install/ur10_faps_driver/lib/python3.10/site-packages/ur10_faps_driver/Ur10ManualJoints.py", line 29, in __init__
point.time_from_start = Duration(seconds=10)
File "/opt/ros/humble/local/lib/python3.10/dist-packages/trajectory_msgs/msg/_joint_trajectory_point.py", line 271, in time_from_start
assert \
AssertionError: The 'time_from_start' field must be a sub message of type 'Duration'
1[ros2run]: Process exited with failure 1
Does anyone know wahts going on here, bc i didn`t find anything on the internet about such an error.