Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default to TwistStamped #90

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion key_teleop/key_teleop/key_teleop.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
13 changes: 9 additions & 4 deletions mouse_teleop/mouse_teleop/mouse_teleop.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -241,8 +241,13 @@ 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()
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):
self._send_motion()
Expand Down
Loading