Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to declare a recovery behavior node in ROS.
ROS
ros::NodeHandle nh;
std::shared_ptr<[1]> recovery_behavior = std::make_shared<ClearCostmapRecovery>(nh);Attempts:
3 left
💡 Hint
Common Mistakes
Using a generic RecoveryBehavior instead of a specific recovery class.
Confusing MoveBaseRecovery with ClearCostmapRecovery.
✗ Incorrect
The ClearCostmapRecovery class is a common recovery behavior in ROS navigation stack.
2fill in blank
mediumComplete the code to call the recovery behavior's runBehavior method.
ROS
if (!recovery_behavior->[1]()) { ROS_ERROR("Recovery behavior failed"); }
Attempts:
3 left
💡 Hint
Common Mistakes
Using execute() which is not defined in recovery behaviors.
Using start() or perform() which are not standard methods.
✗ Incorrect
The runBehavior() method triggers the recovery action in ROS navigation.
3fill in blank
hardFix the error in the recovery behavior initialization code.
ROS
std::shared_ptr<ClearCostmapRecovery> recovery_behavior = std::make_shared<ClearCostmapRecovery>([1]);Attempts:
3 left
💡 Hint
Common Mistakes
Passing a temporary NodeHandle instead of the existing one.
Passing nullptr or an undefined variable.
✗ Incorrect
The ClearCostmapRecovery constructor requires a valid NodeHandle object, usually named nh.
4fill in blank
hardFill both blanks to create a recovery behavior and run it safely.
ROS
auto recovery = std::make_shared<[1]>(nh); if (!recovery->[2]()) { ROS_WARN("Recovery failed"); }
Attempts:
3 left
💡 Hint
Common Mistakes
Using execute() instead of runBehavior().
Using MoveBaseRecovery class incorrectly.
✗ Incorrect
ClearCostmapRecovery is a recovery class and runBehavior() runs it.
5fill in blank
hardFill all three blanks to define, initialize, and run a recovery behavior with error handling.
ROS
std::shared_ptr<[1]> recovery_behavior = std::make_shared<[2]>(nh); if (!recovery_behavior->[3]()) { ROS_ERROR("Recovery behavior execution failed"); }
Attempts:
3 left
💡 Hint
Common Mistakes
Using the same class name for pointer and instance incorrectly.
Using execute() instead of runBehavior().
✗ Incorrect
RecoveryBehavior is the interface type, ClearCostmapRecovery is the concrete class, and runBehavior() executes it.
