Best Way To Simulate --once In Galactic?

On all my prior robots, I have a status script which I like to run that prints out:

  • load (uptime)
  • memory usage (free -h)
  • Processor Temperature
  • Clock Frequency
  • Throttled Status (temperature or power)
  • Battery Level

Everything but the battery info is available from the operating system.

On the Create3 / TurtleBot4 robots which run ROS2 Galactic, I can access the battery info with:

ros2 topic echo /battery_state

but in Galactic there is no “–once” option so the CLI command continues until control-c signaled, preventing simply adding the topic echo to my status script (which I can do in ROS2 Humble).

Do I have to write (and have running)

  • a “My_Battery” node
    • that subscribes to /battery_state and
    • has a service “/state_once”

that I could call from the CLI?

Is there any other way to snatch a single topic on demand (in Galactic)?

for what its worth, the changes added to Humble to implement the --once option seem simple enough. you could consider backporting to Galactic and building from source in an overlay workspace

1 Like

Wow - very confined changes. Seems like a good learning exercise (when the lack of --once gets to be too annoying).