Practice the ROS2 ROS2 Node: Safe Motor Shutdown On Error coding problem in Safety. Browser-based execution with automated grading — no local ROS install required. 0% of engineers pass this challenge.
Implement a safety watchdog node that monitors a /heartbeat topic and sends zero-velocity commands if the heartbeat stops.
Your node must:
/heartbeat (std_msgs/String) — the topic being monitored/cmd_vel_input (geometry_msgs/Twist) — incoming velocity commands to pass through/cmd_vel (geometry_msgs/Twist) — the safe outputcreate_timer(0.2, ...)) that runs check_heartbeat()check_heartbeat():time.time() - self.last_heartbeat_timeself.healthy = False, log a warning, publish zero Twistself.healthy = True/cmd_vel_input callback: only forward the command if self.healthy == True, otherwise publish zero Twist/heartbeat callback: update self.last_heartbeat_time = time.time()Input: std_msgs/String on /heartbeat | geometry_msgs/Twist on /cmd_vel_input
Output: geometry_msgs/Twist on /cmd_vel (pass-through when healthy, zero when not)
This is the architecture used in every safety-critical robotics deployment. The Nav2 controller server monitors a control frequency watchdog. The MoveIt2 servo package has a joint-angle watchdog. If any upstream node stops responding, the robot stops — it never keeps moving blindly based on stale commands.
self.get_clock().now() can freeze if the executor isn't spinning. Use Python's time.time() for the watchdog timeout — it always runs.last_heartbeat_time starts as None, the first check_heartbeat() call crashes. Initialise it to time.time() in __init__.It is a hands-on Safety challenge on SimuCode where you implement and run ROS2 code in the browser with runtime-verified tests.
Open this page, sign in, and solve the problem in the built-in IDE. Your solution is graded against real ROS2 execution checks.
This Medium problem focuses on Safety skills used in robotics interviews and production systems.