Challenge - 5 Problems
Depth Camera Integration Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ component_behavior
intermediateWhat is the output of this ROS node subscribing to a depth camera topic?
Consider a ROS node subscribing to the topic
/camera/depth/image_raw which publishes sensor_msgs/Image messages. The node prints the depth value at pixel (320, 240). What will the node output if the depth image encoding is 16UC1 and the pixel value at (320, 240) is 1000?ROS
import rclpy from rclpy.node import Node from sensor_msgs.msg import Image import numpy as np class DepthListener(Node): def __init__(self): super().__init__('depth_listener') self.subscription = self.create_subscription( Image, '/camera/depth/image_raw', self.listener_callback, 10) def listener_callback(self, msg): # Convert raw data to numpy array depth_array = np.frombuffer(msg.data, dtype=np.uint16).reshape(msg.height, msg.width) depth_value = depth_array[240, 320] self.get_logger().info(f'Depth at (320,240): {depth_value}') rclpy.init() node = DepthListener() rclpy.spin(node) node.destroy_node() rclpy.shutdown()
Attempts:
2 left
💡 Hint
Remember that 16UC1 encoding means unsigned 16-bit integers per pixel.
✗ Incorrect
The depth image encoding 16UC1 means each pixel is an unsigned 16-bit integer. The numpy dtype np.uint16 matches this. The pixel value 1000 is read directly as 1000, so the output logs 'Depth at (320,240): 1000'.
📝 Syntax
intermediateWhich option correctly initializes a ROS2 publisher for depth images?
You want to create a ROS2 publisher node that publishes depth images on the topic
/camera/depth/image_raw with message type sensor_msgs/msg/Image. Which code snippet correctly creates this publisher?ROS
import rclpy from rclpy.node import Node from sensor_msgs.msg import Image class DepthPublisher(Node): def __init__(self): super().__init__('depth_publisher') # Publisher initialization here rclpy.init() node = DepthPublisher() rclpy.spin(node) node.destroy_node() rclpy.shutdown()
Attempts:
2 left
💡 Hint
The create_publisher method takes message type first, then topic name, then queue size.
✗ Incorrect
In ROS2 Python, create_publisher is called as create_publisher(msg_type, topic_name, qos). Option B follows this order correctly.
🔧 Debug
advancedWhy does this ROS node fail to convert depth image data correctly?
This ROS node subscribes to a depth image topic with encoding '32FC1' but prints incorrect depth values. What is the likely cause?
ROS
def listener_callback(self, msg): depth_array = np.frombuffer(msg.data, dtype=np.uint16).reshape(msg.height, msg.width) depth_value = depth_array[240, 320] self.get_logger().info(f'Depth: {depth_value}')
Attempts:
2 left
💡 Hint
Check the encoding type and matching numpy dtype.
✗ Incorrect
The encoding '32FC1' means 32-bit float per pixel. Using np.uint16 reads the bytes incorrectly, resulting in wrong values.
❓ state_output
advancedWhat is the value of the variable 'distance' after processing this depth image message?
Given a depth image message with encoding '16UC1' and pixel value 2000 at (100, 150), what is the value of
distance after this code runs?ROS
depth_array = np.frombuffer(msg.data, dtype=np.uint16).reshape(msg.height, msg.width) distance = depth_array[150, 100] / 1000.0 # convert mm to meters
Attempts:
2 left
💡 Hint
Remember the pixel coordinates order in numpy arrays is [row, column].
✗ Incorrect
The pixel at (100,150) means column=100, row=150, so depth_array[150, 100] accesses the correct pixel. Value 2000 mm converted to meters is 2.0.
🧠 Conceptual
expertWhich ROS2 QoS profile is best suited for reliable depth camera data streaming in a noisy wireless environment?
You are integrating a depth camera in a ROS2 system over a wireless network prone to packet loss. Which QoS profile should you choose to ensure the most reliable data delivery?
Attempts:
2 left
💡 Hint
Reliable means guaranteed delivery; durability controls message persistence.
✗ Incorrect
Reliable reliability ensures message delivery despite packet loss. Volatile durability means messages are not saved for late joiners, suitable for streaming data like depth images.
