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 948 B

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