You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

random_turtle.py 892 B

1234567891011121314151617181920212223242526272829303132
  1. from dora_ros2_bridge import *
  2. import time, random
  3. context = Ros2Context()
  4. node = context.new_node("turtle_teleop", "/ros2_demo", Ros2NodeOptions(rosout=True))
  5. topic_qos = Ros2QosPolicies(reliable=True, max_blocking_time=0.1)
  6. turtle_twist_topic = node.create_topic(
  7. "/turtle1/cmd_vel", "geometry_msgs::Twist", topic_qos
  8. )
  9. twist_writer = node.create_publisher(turtle_twist_topic)
  10. turtle_pose_topic = node.create_topic("/turtle1/pose", "turtlesim::Pose", topic_qos)
  11. pose_reader = node.create_subscription(turtle_pose_topic)
  12. for i in range(500):
  13. direction = {
  14. "linear": {
  15. "x": random.random() + 1,
  16. },
  17. "angular": {
  18. "z": (random.random() - 0.5) * 5,
  19. },
  20. }
  21. twist_writer.publish(direction)
  22. while True:
  23. pose = pose_reader.next()
  24. if pose == None:
  25. break
  26. print(pose)
  27. time.sleep(0.5)

DORA (Dataflow-Oriented Robotic Architecture) is middleware designed to streamline and simplify the creation of AI-based robotic applications. It offers low latency, composable, and distributed datafl