ROS2 Rosbag2 Recording Automation Script

Medium Tools 74% pass rate
#rosbag2#automation#odom#recording#tools#robot-data

Practice the ROS2 Rosbag2 Recording Automation Script coding problem in Tools. Browser-based execution with automated grading — no local ROS install required. 74% of engineers pass this challenge.

Problem Statement

Implement a topic statistics monitor node that subscribes to /statistics_target (std_msgs/Float64) and computes running statistics, publishing a summary to /topic_stats (std_msgs/String) as a JSON string every 2 seconds.

Requirements

Your node must:

  • Subscribe to /statistics_target (std_msgs/Float64)
  • Track per-message: value, receive timestamp (using time.time())
  • Every 2 seconds (create_timer(2.0, ...)), compute and publish a JSON string containing:
    {
      "count": <int>,
      "mean": <float>,
      "min": <float>,
      "max": <float>,
      "std_dev": <float>,
      "rate_hz": <float>
    }
    
    • count: total messages received since last report
    • mean: average value
    • min / max: range of values
    • std_dev: population standard deviation
    • rate_hz: average publish rate (messages / elapsed seconds)
  • Publish the JSON as std_msgs/String on /topic_stats
  • Reset counters after each report
  • If count == 0, publish {"count": 0, "rate_hz": 0.0}
  • Log "Topic Statistics Monitor Ready" on startup

🤖 Why This Matters in Real Robots

Data quality validation is non-negotiable in production. Before deploying a SLAM update, engineers verify that sensor bags have correct publish rates, expected value ranges, and no dropped messages. This monitor pattern — subscribe, collect, report — is exactly what ROS2's ros2 topic hz and ros2 topic echo --filter do under the hood.

Frequently asked questions

What is the ROS2 Rosbag2 Recording Automation Script practice problem?

It is a hands-on Tools challenge on SimuCode where you implement and run ROS2 code in the browser with runtime-verified tests.

How do I practice ROS2 Rosbag2 Recording Automation Script online?

Open this page, sign in, and solve the problem in the built-in IDE. Your solution is graded against real ROS2 execution checks.

What skills does ROS2 Rosbag2 Recording Automation Script test?

This Medium problem focuses on rosbag2, automation, odom skills used in robotics interviews and production systems.