In ROS, nodes communicate by publishing and subscribing to topics. Why does this method enable decoupled communication?
Think about how nodes find each other when using topics.
In ROS, topics act as named channels. Publishers send messages to a topic without knowing who receives them. Subscribers listen to topics without knowing who sends messages. This separation means nodes are decoupled.
In ROS, if a subscriber node starts after the publisher has already published messages on a topic, what will the subscriber receive?
Consider how ROS topics handle message delivery timing.
ROS topics deliver messages only to subscribers that are active at the time of publishing. Past messages are not stored or replayed by default.
In ROS, if a publisher node crashes or disconnects, what happens to the subscribers listening to its topic?
Think about how ROS topics manage publisher availability.
Subscribers remain active and wait for messages. If no publisher is available, they simply receive no messages until a publisher appears again.
Choose the correct ROS Python code snippet to create a publisher for the topic 'chatter' with message type std_msgs/String.
import rospy from std_msgs.msg import String rospy.init_node('talker') # Which line correctly creates the publisher?
Check the order and types of arguments for rospy.Publisher.
The rospy.Publisher constructor requires the topic name as a string, the message type class (not a string or instance), and queue_size as a keyword argument.
Given the following ROS Python subscriber code, why does the callback function never execute?
import rospy from std_msgs.msg import String def callback(msg): rospy.loginfo(f'Received: {msg.data}') rospy.init_node('listener') rospy.Subscriber('chatter', String, callback) # Missing rospy.spin() here
Think about what keeps a ROS node alive to receive messages.
Without rospy.spin(), the node finishes execution immediately after subscribing, so the callback never gets a chance to run.
