AS: code update

This commit is contained in:
Alexander Schaefer
2025-05-07 23:12:12 +02:00
parent e8d48c0a4d
commit b67b2a5174
7 changed files with 151 additions and 76 deletions

View File

@@ -12,28 +12,31 @@ class ScaledJointTrajectoryPublisher(Node):
10
)
def send_trajectory(self, joint_positions, duration=2.0):
"""Publish a joint trajectory command to move the UR10e."""
msg = JointTrajectory()
msg.joint_names = [
"shoulder_pan_joint", "shoulder_lift_joint", "elbow_joint",
"wrist_1_joint", "wrist_2_joint", "wrist_3_joint"
]
try:
msg = JointTrajectory()
msg.joint_names = [
"shoulder_pan_joint", "shoulder_lift_joint", "elbow_joint",
"wrist_1_joint", "wrist_2_joint", "wrist_3_joint"
]
point = JointTrajectoryPoint()
point.positions = joint_positions # Target joint positions
point.time_from_start.sec = int(duration) # Duration in seconds
point = JointTrajectoryPoint()
point.positions = [2.0]*6 # Target joint positions
point.velocities = [2.0] * 6
point.accelerations = [2.0] * 6
#point.time_from_start.sec = int(2)
#point.time_from_start.nanosec = int(0)
msg.points.append(point)
msg.points.append(point)
self.publisher.publish(msg)
self.publisher.publish(msg)
except Exception as e:
print(f"Error publishing joint trajectory: {e}")
def main():
rclpy.init()
node = ScaledJointTrajectoryPublisher()
# Move to a target position
node.send_trajectory([0.0]*6)
rclpy.spin(node)
node.destroy_node()