Challenge - 5 Problems
Conditional Launch Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ component_behavior
intermediateWhat happens when the condition is false in this ROS launch snippet?
Given this ROS launch snippet using
Assuming
if condition:<launch> <node pkg="demo_pkg" type="demo_node" name="demo" if="launch_demo" /> </launch>
Assuming
launch_demo is set to false, what will be the behavior?ROS
<launch> <node pkg="demo_pkg" type="demo_node" name="demo" if="launch_demo" /> </launch>
Attempts:
2 left
💡 Hint
Think about what the 'if' attribute controls in ROS launch files.
✗ Incorrect
In ROS launch files, the 'if' attribute controls whether a node is launched. If the condition is false, the node is skipped and not launched.
📝 Syntax
intermediateWhich option correctly uses a condition to launch a node only if a parameter is true?
You want to launch a node only if the parameter
use_sensor is true. Which launch snippet is correct?Attempts:
2 left
💡 Hint
Remember how to reference arguments inside conditions in ROS launch files.
✗ Incorrect
The 'if' attribute expects a boolean expression. Using '$(arg use_sensor)' correctly references the argument value for the condition.
❓ state_output
advancedWhat is the output when launching with this conditional group?
Consider this launch snippet:
Which nodes will be running after launch?
<launch>
<group if="false">
<node pkg="pkg1" type="node1" name="node1" />
</group>
<node pkg="pkg2" type="node2" name="node2" />
</launch>Which nodes will be running after launch?
ROS
<launch> <group if="false"> <node pkg="pkg1" type="node1" name="node1" /> </group> <node pkg="pkg2" type="node2" name="node2" /> </launch>
Attempts:
2 left
💡 Hint
Groups with 'if' conditions control all contained nodes.
✗ Incorrect
The group with 'if="false"' disables all nodes inside it. Nodes outside the group launch normally.
🔧 Debug
advancedWhy does this launch file fail to conditionally launch the node?
This launch snippet is intended to launch
But the node launches even when
camera_node only if enable_camera is true:<launch> <arg name="enable_camera" default="false" /> <node pkg="camera_pkg" type="camera_node" name="camera" if="enable_camera" /> </launch>
But the node launches even when
enable_camera is false. Why?ROS
<launch> <arg name="enable_camera" default="false" /> <node pkg="camera_pkg" type="camera_node" name="camera" if="enable_camera" /> </launch>
Attempts:
2 left
💡 Hint
Consider how ROS launch treats argument values in conditions.
✗ Incorrect
Arguments are strings, so 'if="enable_camera"' always evaluates true because non-empty strings are truthy. You must use 'if="$(arg enable_camera)"' to evaluate the argument value.
🧠 Conceptual
expertHow does ROS 2 launch handle conditional launching differently than ROS 1?
Which statement best describes the difference in conditional launching between ROS 1 and ROS 2 launch systems?
Attempts:
2 left
💡 Hint
Think about the launch file formats and APIs in ROS 1 vs ROS 2.
✗ Incorrect
ROS 2 launch uses Python-based launch files with condition classes like 'IfCondition' to control node launching, unlike ROS 1's XML 'if' attribute.
