AS: code update
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user