Which statement best explains why vision is crucial for a robot's perception?
Think about how seeing helps humans understand their environment.
Vision provides rich information about the environment, such as shapes, colors, and movements, which helps robots perceive and interact effectively.
In ROS, when a vision sensor detects an obstacle, what is the typical behavior of the robot's perception system?
Consider how robots use sensor data to navigate safely.
Vision sensors feed data to the perception system, which updates the robot's understanding of the environment to avoid obstacles.
Which ROS Python code snippet correctly subscribes to a camera topic named '/camera/image_raw' to receive vision data?
import rospy from sensor_msgs.msg import Image def image_callback(data): rospy.loginfo('Image received') rospy.init_node('image_listener') # Subscription line here rospy.spin()
Remember that subscribing requires topic name, message type, and callback function.
Option D correctly subscribes to the '/camera/image_raw' topic with the Image message type and a callback function.
Given a ROS node that converts incoming camera images to grayscale using OpenCV, what is the expected output type after processing?
def image_callback(data): cv_image = bridge.imgmsg_to_cv2(data, 'bgr8') gray_image = cv2.cvtColor(cv_image, cv2.COLOR_BGR2GRAY) # What is the type of gray_image?
Think about how OpenCV represents images internally.
OpenCV uses NumPy arrays to represent images; converting to grayscale results in a 2D array of pixel intensities.
Consider this ROS Python node snippet intended to display camera images using OpenCV. Why does it fail to show the image window?
import rospy from sensor_msgs.msg import Image import cv2 from cv_bridge import CvBridge def callback(data): bridge = CvBridge() cv_image = bridge.imgmsg_to_cv2(data, 'bgr8') cv2.imshow('Camera', cv_image) # Missing line here def main(): rospy.init_node('image_viewer') rospy.Subscriber('/camera/image_raw', Image, callback) rospy.spin() if __name__ == '__main__': main()
OpenCV windows need a specific function call to refresh and display images.
Without cv2.waitKey(), OpenCV windows do not process GUI events, so the image window never appears or updates.
