What is the main goal of a global planner in ROS navigation?
The global planner finds a path from the robot's start position to the goal position on a map, avoiding obstacles and planning the best route.
Click to reveal answer
intermediate
How does the A* algorithm decide which path to take?
A* uses a cost function combining the distance from the start and an estimate (heuristic) of the distance to the goal to find the shortest path efficiently.
Click to reveal answer
intermediate
What is the key difference between Dijkstra's algorithm and A* in global planning?
Dijkstra's algorithm explores all possible paths equally without a heuristic, while A* uses a heuristic to guide the search, making it faster in many cases.
Click to reveal answer
beginner
In ROS, what type of data does the global planner use to compute paths?
The global planner uses a costmap, which is a grid map showing obstacles and free space, to calculate safe paths.
Click to reveal answer
beginner
Why is it important for the global planner to consider obstacles in the environment?
Considering obstacles ensures the robot does not plan paths that collide with objects, keeping navigation safe and reliable.
Click to reveal answer
Which algorithm uses a heuristic to speed up pathfinding in ROS global planners?
AA*
BDijkstra
CBreadth-first search
DDepth-first search
✗ Incorrect
A* uses a heuristic to estimate the cost to the goal, making it faster than Dijkstra which explores all paths equally.
What does the ROS global planner primarily use to represent the environment?
AOdometry data
BPoint cloud
CLaser scan
DCostmap
✗ Incorrect
The global planner uses a costmap grid to understand obstacles and free space for path planning.
Which of these is NOT a characteristic of Dijkstra's algorithm?
AUses heuristic to guide search
BFinds shortest path
CExplores all nodes equally
DGuarantees optimal path
✗ Incorrect
Dijkstra does not use a heuristic; it explores all nodes equally.
In ROS navigation, what is the role of the global planner?
AControl the robot's motors
BPlan a path from start to goal on the map
CDetect obstacles in real-time
DLocal obstacle avoidance
✗ Incorrect
The global planner calculates the overall path before the robot moves.
Why might A* be preferred over Dijkstra in many ROS applications?
AIt does not require a map
BIt ignores obstacles
CIt uses a heuristic to find paths faster
DIt always finds longer paths
✗ Incorrect
A* uses heuristics to speed up pathfinding while still finding the shortest path.
Explain how the A* algorithm works in the context of a ROS global planner.
Think about how A* guesses the best path by looking ahead.
You got /3 concepts.
Describe the difference between Dijkstra's algorithm and A* when used for global path planning in ROS.
Focus on how the search is guided or not.
You got /4 concepts.
Practice
(1/5)
1. What is the main difference between the A* algorithm and Dijkstra's algorithm in ROS global planners?
easy
A. Dijkstra uses a heuristic, while A* explores all paths evenly.
B. A* uses a heuristic to guide the search, while Dijkstra explores all paths evenly.
C. Both algorithms use heuristics but in different ways.
D. Neither algorithm considers obstacles in the map.
Solution
Step 1: Understand Dijkstra's algorithm behavior
Dijkstra explores all possible paths evenly without using heuristics, ensuring the shortest path but potentially slower.
Step 2: Understand A* algorithm behavior
A* uses a heuristic function to estimate the cost to the goal, guiding the search more efficiently and often faster.
Final Answer:
A* uses a heuristic to guide the search, while Dijkstra explores all paths evenly. -> Option B
Hint: Remember: A* uses heuristics, Dijkstra does not [OK]
Common Mistakes:
Confusing which algorithm uses heuristics
Thinking both ignore obstacles
Assuming both explore paths the same way
2. Which of the following is the correct way to initialize a Dijkstra planner in ROS using C++?
easy
A. auto planner = new DijkstraPlanner();
B. DijkstraPlanner planner = new DijkstraPlanner();
C. auto planner = DijkstraPlanner();
D. DijkstraPlanner planner();
Solution
Step 1: Understand object initialization in modern C++
Using 'auto' with direct initialization calls the constructor properly and manages type automatically.
Step 2: Analyze each option
auto planner = new DijkstraPlanner(); uses 'new' which returns a pointer, not an object. DijkstraPlanner planner = new DijkstraPlanner(); attempts to assign a pointer to an object, causing a type mismatch compile error. DijkstraPlanner planner(); is a function declaration, not an object. auto planner = DijkstraPlanner(); correctly initializes an object with automatic type deduction.
Final Answer:
auto planner = DijkstraPlanner(); -> Option C
Quick Check:
Use auto with constructor for clean initialization [OK]
Hint: Use 'auto planner = ClassName();' for simple object creation [OK]
Common Mistakes:
Using parentheses that declare a function, not an object
Using 'new' without managing pointers
Not using auto for type deduction
3. Given the following ROS global planner code snippet using A*:
If the planner finds a path with 5 points, what will be printed?
medium
A. 0
B. 4
C. 6
D. 5
Solution
Step 1: Understand the return value of makePlan()
The makePlan function returns a vector of points representing the path from start to goal, including both points.
Step 2: Analyze the output of path.size()
If the planner finds a path with 5 points, the vector size is 5, so printing path.size() outputs 5.
Final Answer:
5 -> Option D
Quick Check:
Path points count equals vector size [OK]
Hint: Path size equals number of points including start and goal [OK]
Common Mistakes:
Assuming path size excludes start or goal
Confusing index with size
Thinking path size counts edges, not points
4. You have this snippet in your ROS global planner node:
std::vector<Point> path = planner.makePlan(start, goal);
for (int i = 0; i <= path.size(); i++) {
std::cout << path[i].x << "," << path[i].y << std::endl;
}
What is the error in this code?
medium
A. Using <= in the loop causes out-of-bounds access.
B. The loop variable should be a float, not int.
C. The path vector is not initialized.
D. The makePlan function does not return a vector.
Solution
Step 1: Analyze the loop condition
The loop runs from i = 0 to i <= path.size(), which means it tries to access path[path.size()] on the last iteration.
Step 2: Understand vector indexing
Vectors are zero-indexed, so valid indices are 0 to path.size() - 1. Accessing path[path.size()] causes out-of-bounds error.
Final Answer:
Using <= in the loop causes out-of-bounds access. -> Option A
Quick Check:
Loop index must be less than size, not less or equal [OK]
Hint: Use i < path.size() in loops to avoid out-of-bounds [OK]
Common Mistakes:
Using <= instead of < in loops
Confusing vector size with last index
Assuming makePlan returns empty vector
5. In a ROS global planner using A*, you want to modify the heuristic to prefer paths farther from obstacles for safety. Which approach correctly applies this change?
hard
A. Add a penalty to the heuristic cost for points near obstacles.
B. Subtract a penalty from the heuristic cost for points near obstacles.
C. Add a penalty to the heuristic cost for points far from obstacles.
D. Ignore the heuristic and use Dijkstra instead.
Solution
Step 1: Understand heuristic modification goal
To prefer paths farther from obstacles, the heuristic should favor those points by lowering their cost or penalizing points near obstacles.
Step 2: Analyze penalty application
Adding a penalty to the heuristic cost for points near obstacles increases their cost, which discourages paths near obstacles, as desired for safety.
Step 3: Choose correct approach
Add a penalty to the heuristic cost for points near obstacles. correctly adds a penalty to points near obstacles, increasing their heuristic cost and discouraging proximity for safer paths.
Final Answer:
Add a penalty to the heuristic cost for points near obstacles. -> Option A
Quick Check:
Modify heuristic cost to prefer points near obstacles [OK]
Hint: Adjust heuristic cost to favor desired path traits [OK]
Common Mistakes:
Confusing penalty direction for heuristic
Ignoring heuristic and switching algorithms unnecessarily
Not understanding heuristic impact on path choice
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.