Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to define a simple Xacro macro named 'wheel'.
ROS
<macro name="wheel"> <link name="[1]"> <visual> <geometry> <cylinder length="0.1" radius="0.05"/> </geometry> </visual> </link> </macro>
Attempts:
3 left
💡 Hint
Common Mistakes
Using a different name than the macro name for the link.
Forgetting to add the name attribute.
✗ Incorrect
The macro defines a link named 'wheel' which matches the macro's purpose.
2fill in blank
mediumComplete the code to call the 'wheel' macro with the name 'front_wheel'.
ROS
<xacro:wheel name="[1]"/>
Attempts:
3 left
💡 Hint
Common Mistakes
Using the macro name instead of the instance name.
Omitting the name attribute.
✗ Incorrect
The macro is called with the name 'front_wheel' to create a wheel link with that name.
3fill in blank
hardFix the error in the macro parameter declaration to accept a 'radius' parameter.
ROS
<macro name="wheel" [1]> <link name="${name}"> <visual> <geometry> <cylinder length="0.1" radius="${radius}"/> </geometry> </visual> </link> </macro>
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'param' instead of 'params'.
Separating parameters with commas.
✗ Incorrect
The correct attribute to declare parameters is 'params' with space-separated names without commas.
4fill in blank
hardFill both blanks to define a macro 'arm' with parameters 'length' and 'radius' and use them in the cylinder geometry.
ROS
<macro name="arm" [1]> <link name="arm_link"> <visual> <geometry> <cylinder length="$[2]" radius="${radius}"/> </geometry> </visual> </link> </macro>
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'param' instead of 'params'.
Using the wrong parameter name inside ${}.
✗ Incorrect
The macro parameters are declared with 'params="length radius"' and the length parameter is used as '${length}'.
5fill in blank
hardFill all three blanks to create a macro 'robot_part' with parameters 'name', 'length', and 'radius', and use them correctly in the link name and cylinder geometry.
ROS
<macro name="robot_part" [1]> <link name="$[2]"> <visual> <geometry> <cylinder length="$[3]" radius="${radius}"/> </geometry> </visual> </link> </macro>
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting to declare all parameters.
Using incorrect parameter names inside ${}.
✗ Incorrect
The macro declares parameters 'name', 'length', and 'radius' with 'params'. The link name uses '${name}' and the cylinder length uses '${length}'.
