Quiz#

This quiz covers the key concepts from Lecture 12: Namespaces, Remapping, and Behavior Trees. Topics include namespace isolation, node/topic/parameter remapping, behavior tree composites (Sequence, Selector), decorators, conditions, actions, and the tick mechanism.

Note

Instructions:

  • Answer all questions to the best of your ability.

  • Multiple choice questions have exactly one correct answer.

  • True/False questions require you to determine if the statement is correct.

  • Essay questions require short written responses (2-4 sentences).

  • Click the dropdown after each question to reveal the answer.


Multiple Choice#

Question 1

A ROS 2 node publishes on the topic image_raw (relative name). You launch it with --ros-args -r __ns:=/front. What is the fully-qualified topic name?

  1. /image_raw

  2. /front/image_raw

  3. /front/camera_node/image_raw

  4. image_raw

Answer

B/front/image_raw.

A namespace prefixes all relative names. Since image_raw does not start with /, the namespace /front is prepended. Absolute names (starting with /) are not affected.

Question 2

In a behavior tree, what does a Sequence node do when one of its children returns FAILURE?

  1. It continues ticking the remaining children.

  2. It immediately returns FAILURE without ticking remaining children.

  3. It retries the failed child.

  4. It returns RUNNING.

Answer

B – It immediately returns FAILURE.

A Sequence node (logical AND) fails as soon as any child fails. It does not tick the remaining children.

Question 3

In py_trees, what is the difference between a Selector and a Sequence?

  1. A Selector ticks children in reverse order.

  2. A Selector succeeds on the first child SUCCESS; a Sequence succeeds only if all children succeed.

  3. A Selector always returns RUNNING.

  4. There is no difference; they are aliases.

Answer

B – A Selector (Fallback) succeeds on the first SUCCESS (logical OR). A Sequence succeeds only if all children succeed (logical AND).

Question 4

What does a py_trees.decorators.Timeout decorator do?

  1. It makes the child node tick faster.

  2. It returns FAILURE if the child is still RUNNING after a set duration.

  3. It retries the child on FAILURE.

  4. It converts SUCCESS to RUNNING.

Answer

B – Returns FAILURE if the child is still RUNNING after the configured duration. This is used to detect when a navigation or driving action is taking too long.

Question 5

What does memory=False mean on a py_trees Sequence?

  1. The Sequence forgets which child was running and re-evaluates all children from the beginning on every tick.

  2. The Sequence caches the last result and never re-ticks children.

  3. The Sequence uses less RAM.

  4. The Sequence does not store any internal state.

Answer

A – With memory=False, the Sequence is reactive: it starts from the first child on every tick. This means condition nodes are re-checked each tick, allowing the tree to react immediately to changes (e.g., goal reached, battery low).

Question 6

You run the same executable twice in the same namespace without remapping the node name. What happens?

  1. Both nodes run normally.

  2. The second node fails to start because the name is already taken.

  3. Both nodes share the same publishers and subscribers.

  4. ROS 2 automatically assigns unique names.

Answer

B – The second node fails because every node in a ROS 2 system must have a unique name. Use --ros-args -r __node:=new_name or the name argument in a launch file to resolve this.


True/False#

Question 7

A namespace affects absolute topic names (those starting with /).

Answer

False – Namespaces only affect relative names. Absolute names bypass the namespace entirely.

Question 8

A condition node in a behavior tree should never return RUNNING.

Answer

True – Condition nodes must give an instantaneous yes/no answer: SUCCESS or FAILURE. Only action nodes return RUNNING.

Question 9

A py_trees Selector with memory=True always starts from the first child on every tick.

Answer

False – With memory=True, the Selector remembers which child was last ticked. If a child returned FAILURE, the Selector resumes from the next child on the following tick, rather than starting over.


Essay Questions#

Question 10

Explain the difference between a namespace and remapping in ROS 2. When would you use one over the other?

Answer

A namespace is a bulk operation that prepends a prefix to all relative names (topics, services, parameters) associated with a node. It is used to isolate multiple instances of the same node (e.g., three cameras). Remapping is a surgical operation that changes one specific name (e.g., redirecting image_raw to /sensors/front/image). Use namespaces first for isolation, then remapping to fine-tune individual names that the namespace alone does not handle correctly.

Question 11

In the bt_demo behavior tree, the root Sequence uses memory=False while the Selector (DriveOrRecover) uses memory=True. Explain why each choice is appropriate.

Answer

The root Sequence uses memory=False so that the GoalNotReached? condition is re-evaluated on every tick. This makes the tree reactive: the moment the robot reaches the goal, the condition returns FAILURE and the Sequence stops immediately. The Selector uses memory=True so that once DriveForward times out (FAILURE), the Selector stays on the Spin recovery child rather than retrying DriveForward immediately on the next tick. Spin runs until it reaches the target yaw (SUCCESS), then the Selector resets and gives DriveForward a fresh attempt.