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 1.2 kB

12345678910111213141516171819202122232425262728293031323334353637
  1. import time, random
  2. from dora_ros2_bridge import *
  3. from dora import Node
  4. node = Node()
  5. context = Ros2Context()
  6. node = context.new_node("turtle_teleop", "/ros2_demo", Ros2NodeOptions(rosout=True))
  7. topic_qos = Ros2QosPolicies(reliable=True, max_blocking_time=0.1)
  8. turtle_twist_topic = node.create_topic(
  9. "/turtle1/cmd_vel", "geometry_msgs::Twist", topic_qos
  10. )
  11. twist_writer = node.create_publisher(turtle_twist_topic)
  12. turtle_pose_topic = node.create_topic("/turtle1/pose", "turtlesim::Pose", topic_qos)
  13. pose_reader = node.create_subscription(turtle_pose_topic)
  14. for event in node:
  15. match event["type"]:
  16. case "INPUT":
  17. match event["id"]:
  18. case "direction":
  19. direction = {
  20. "linear": {
  21. "x": event["data"][0],
  22. },
  23. "angular": {
  24. "z": event["data"][5],
  25. },
  26. }
  27. twist_writer.publish(direction)
  28. case "tick":
  29. pose = pose_reader.next()
  30. if pose == None:
  31. break
  32. node.send_output(pose)

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