ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

You may use this

ros2 topic pub --once /turtle1/cmd_vel geometry_msgs/msg/Twist '{linear: {x: 2.0, y: 0.0, z: 0.0}, angular: {x: 0.0, y: 0.0, z: 1.8}}'

You may use this

ros2 topic pub --once /turtle1/cmd_vel geometry_msgs/msg/Twist '{linear: {x: 2.0, y: 0.0, z: 0.0}, angular: {x: 0.0, y: 0.0, z: 1.8}}'

Or in python

from time import sleep

import rclpy

from std_msgs.msg import String



def main(args=None):
  rclpy.init(args=args)

  node = rclpy.create_node('minimal_publisher')

  publisher = node.create_publisher(String, 'topic', 10)

  msg = String()
  senden = true
  i = 0
  while rclpy.ok():
    msg.data = 'Hello World: %d' % i
    i += 1
    #node.get_logger().info('Publishing: "%s"' % msg.data)
    If send:
        publisher.publish(msg)
        Send= false
    sleep(0.5)  # seconds

# Destroy the node explicitly
# (optional - otherwise it will be done automatically
# when the garbage collector destroys the node object)
node.destroy_node()
rclpy.shutdown()


if __name__ == '__main__':
  main()