From b9abc2884d776279136b0cf405372db1a42d6901 Mon Sep 17 00:00:00 2001 From: Bence Magyar Date: Thu, 5 Sep 2024 12:41:14 +0100 Subject: [PATCH 1/3] Update key_teleop.py --- key_teleop/key_teleop/key_teleop.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/key_teleop/key_teleop/key_teleop.py b/key_teleop/key_teleop/key_teleop.py index 3451938..f569b47 100755 --- a/key_teleop/key_teleop/key_teleop.py +++ b/key_teleop/key_teleop/key_teleop.py @@ -127,7 +127,7 @@ def __init__(self, interface): self._interface = interface - self._publish_stamped_twist = self.declare_parameter('twist_stamped_enabled', False).value + self._publish_stamped_twist = self.declare_parameter('twist_stamped_enabled', True).value if self._publish_stamped_twist: self._pub_cmd = self.create_publisher(TwistStamped, 'key_vel', From cc7154b6a58116ad9bd15ba69d3c4030c5e3bbaf Mon Sep 17 00:00:00 2001 From: Bence Magyar Date: Thu, 5 Sep 2024 12:45:25 +0100 Subject: [PATCH 2/3] Update mouse_teleop.py --- mouse_teleop/mouse_teleop/mouse_teleop.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/mouse_teleop/mouse_teleop/mouse_teleop.py b/mouse_teleop/mouse_teleop/mouse_teleop.py index 0fdd88e..0b09bd6 100755 --- a/mouse_teleop/mouse_teleop/mouse_teleop.py +++ b/mouse_teleop/mouse_teleop/mouse_teleop.py @@ -41,7 +41,7 @@ import signal import tkinter -from geometry_msgs.msg import Twist, Vector3 +from geometry_msgs.msg import TwistStamped, Vector3 import numpy import rclpy from rclpy.node import Node @@ -241,8 +241,15 @@ def _send_motion(self): lin = Vector3(x=v_x, y=v_y, z=0.0) ang = Vector3(x=0.0, y=0.0, z=w) - twist = Twist(linear=lin, angular=ang) - self._pub_cmd.publish(twist) + twist_stamped = TwistStamped() + header = Header() + header.stamp = rclpy.clock.Clock().now().to_msg() + header.frame_id = 'mouse_teleop' + twist_stamped.header = header + twist_stamped.twist.linear = lin + twist_stamped.twist.angular = ang + + self._pub_cmd.publish(twist_stamped) def _publish_twist(self): self._send_motion() From e644b282f63de9441bea9f8203ac80fad82d2f2e Mon Sep 17 00:00:00 2001 From: Bence Magyar Date: Wed, 11 Sep 2024 19:17:26 +0100 Subject: [PATCH 3/3] fix import --- mouse_teleop/mouse_teleop/mouse_teleop.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/mouse_teleop/mouse_teleop/mouse_teleop.py b/mouse_teleop/mouse_teleop/mouse_teleop.py index 0b09bd6..7d10d09 100755 --- a/mouse_teleop/mouse_teleop/mouse_teleop.py +++ b/mouse_teleop/mouse_teleop/mouse_teleop.py @@ -58,7 +58,7 @@ def __init__(self): self._holonomic = self.declare_parameter('holonomic', False).value # Create twist publisher: - self._pub_cmd = self.create_publisher(Twist, 'mouse_vel', 10) + self._pub_cmd = self.create_publisher(TwistStamped, 'mouse_vel', 10) # Initialize twist components to zero: self._v_x = 0.0 @@ -242,13 +242,11 @@ def _send_motion(self): ang = Vector3(x=0.0, y=0.0, z=w) twist_stamped = TwistStamped() - header = Header() - header.stamp = rclpy.clock.Clock().now().to_msg() - header.frame_id = 'mouse_teleop' - twist_stamped.header = header + twist_stamped.header.stamp = rclpy.clock.Clock().now().to_msg() + twist_stamped.header.frame_id = 'mouse_teleop' twist_stamped.twist.linear = lin twist_stamped.twist.angular = ang - + self._pub_cmd.publish(twist_stamped) def _publish_twist(self):