ROS2 LIDAR: Find Nearest Obstacle

Easy Sensor Processing 0% pass rate

Practice the ROS2 LIDAR: Find Nearest Obstacle coding problem in Sensor Processing. Browser-based execution with automated grading — no local ROS install required. 0% of engineers pass this challenge.

Problem Statement

Implement a ROS2 node that reads sensor_msgs/LaserScan data, finds the nearest valid obstacle, and publishes its position as a std_msgs/Float32 distance on /nearest_obstacle_distance.

Requirements

Your node must:

  • Subscribe to /scan (sensor_msgs/LaserScan)
  • In the callback, filter out invalid readings: values that are inf, nan, <= msg.range_min, or >= msg.range_max
  • Find the minimum valid range from the filtered array
  • Publish the minimum range as std_msgs/Float32 on /nearest_obstacle_distance
  • Log the distance and its angle with self.get_logger().info()
  • If no valid readings exist, log a warning and skip publishing
  • Log "LIDAR Processor Ready" on startup

Input / Output

Input: sensor_msgs/LaserScan on /scan Output: std_msgs/Float32 on /nearest_obstacle_distance

🤖 Why This Matters in Real Robots

This is the foundation of reactive obstacle avoidance. iRobot's Roomba, Boston Dynamics Spot, and every autonomous forklift uses this same pattern — scan the LIDAR, find the closest thing, decide whether to stop. The Nav2 obstacle layer builds a full costmap using this data, but the core primitive is always "what is the nearest obstacle and how far is it?"

Input/Output Format

Input: /scan (sensor_msgs/LaserScan) | Output: /nearest_obstacle (std_msgs/Float32)

⚠️ Common Pitfalls

  • Handling empty scans
  • Assuming ranges are always finite

📚 Helpful Resources

Frequently asked questions

What is the ROS2 LIDAR: Find Nearest Obstacle practice problem?

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

How do I practice ROS2 LIDAR: Find Nearest Obstacle 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 LIDAR: Find Nearest Obstacle test?

This Easy problem focuses on Sensor Processing skills used in robotics interviews and production systems.