Q1: Run ros2 service list with turtlesim running. List all the services.
(your answer)
Q2: Run ros2 interface show turtlesim/srv/SetPen. What fields are in the
request? What fields (if any) are in the response?
Request fields:
Response fields:
Q3: After calling /spawn to create turtle2, run ros2 topic list.
List the new topics that appeared. Why does each turtle get its own separate
topics instead of sharing /cmd_vel and /pose?
New topics:
Why separate namespaces:
Q4: Topics and services are both ways for ROS2 nodes to communicate. Give one example of a situation where a service is the right choice and one where a topic is the right choice. Use concrete examples from turtlesim or from Project 4.
Service is better when:
Topic is better when:
Q5: When you called /turtle1/teleport_absolute, the turtle moved
instantly — it did not smoothly drive there. What does this tell you about
the difference between a service call and publishing a velocity command?
(your answer)
Q6: In Activity 8, drive_pattern.py used create_timer(). In this
activity, wall_avoider.py uses create_subscription(). What triggers
timer_callback vs. pose_callback? Why does that difference matter for
wall avoidance?
(your answer)
Q7: While wall_avoider.py is running, open a new terminal and run
ros2 topic hz /turtle1/cmd_vel. What publish rate do you see? Where does
that rate come from?
Rate observed:
Where it comes from:
Q8: Paste your completed pose_callback below — the working version that
keeps the turtle inside the walls.
def pose_callback(self, msg):
# paste your code hereQ9: What happens if you set WALL_MIN = 0.1 (very small buffer)?
What happens if you set WALL_MIN = 4.0 (very large buffer)?
Test both and describe the behavior.
WALL_MIN = 0.1:
WALL_MIN = 4.0:
Q10 (Extension): Paste your extended pose_callback that uses msg.theta
to turn away from the approaching wall. Describe how you used msg.theta in
your logic.
def pose_callback(self, msg):
# paste your extended code hereExplanation of how you used msg.theta:
Q11: Run ros2 node info /turtlesim and ros2 node info /wall_avoider.
Fill in the table.
| Node | Publishes | Subscribes to |
|---|---|---|
/turtlesim |
||
/wall_avoider |
Q12: The /turtle1/pose topic connects the two nodes. Which node is the
publisher and which is the subscriber? How does wall_avoider use what it
reads from /turtle1/pose to decide what to write to /turtle1/cmd_vel?
(your answer)
Q13: In Project 4, the Nav2 stack has many nodes communicating over many
topics. Based on what you saw with just two nodes (turtlesim + wall_avoider),
why is it useful to be able to inspect individual node subscriptions and
publications rather than just looking at ros2 topic list?
(your answer)