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

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

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