An occupancy grid map is a 2D grid representation where each cell shows if the space is free, occupied, or unknown. It helps robots understand their surroundings for navigation.
Click to reveal answer
beginner
What values can cells in an occupancy grid map hold?
Cells can hold values like 0 (free space), 100 (occupied), or -1 (unknown). These values tell the robot if it can move through that cell or not.
Click to reveal answer
beginner
How does an occupancy grid map help a robot navigate?
It shows where obstacles are and where the robot can safely move. The robot plans paths by avoiding cells marked as occupied.
Click to reveal answer
intermediate
What is the role of resolution in an occupancy grid map?
Resolution defines the size of each grid cell in meters. Smaller cells mean more detail but require more memory and processing power.
Click to reveal answer
intermediate
How does ROS represent occupancy grid maps in messages?
ROS uses the nav_msgs/OccupancyGrid message type, which includes metadata like map size, resolution, and a data array with cell values.
Click to reveal answer
In an occupancy grid map, what does a cell value of 100 usually mean?
AThe cell is a charging station
BThe cell is free space
CThe cell is unknown
DThe cell is occupied by an obstacle
✗ Incorrect
A value of 100 means the cell is occupied, indicating an obstacle or blocked space.
What does the resolution of an occupancy grid map control?
AThe color of the map
BThe robot's speed
CThe size of each grid cell in meters
DThe number of robots in the map
✗ Incorrect
Resolution sets how big each cell is, affecting map detail and memory use.
Which ROS message type is used to represent occupancy grid maps?
Astd_msgs/String
Bnav_msgs/OccupancyGrid
Cgeometry_msgs/Pose
Dsensor_msgs/Image
✗ Incorrect
nav_msgs/OccupancyGrid is the standard message for occupancy grid maps.
What does a cell value of -1 indicate in an occupancy grid map?
AUnknown or unexplored area
BFree space
COccupied space
DCharging station
✗ Incorrect
A value of -1 means the robot does not know if the cell is free or occupied.
Why is an occupancy grid map useful for robot navigation?
AIt shows where obstacles are to avoid collisions
BIt controls the robot's battery
CIt changes the robot's color
DIt increases the robot's speed
✗ Incorrect
The map helps the robot plan safe paths by marking obstacles.
Explain what an occupancy grid map is and how it helps a robot move safely.
Think about how a map shows where you can walk and where you cannot.
You got /5 concepts.
Describe the meaning of cell values in an occupancy grid map and why resolution matters.
Consider how big or small squares on a map affect what you see.
You got /5 concepts.
Practice
(1/5)
1.
What does an occupancy grid map represent in ROS?
easy
A. A grid showing which areas are free, occupied, or unknown
B. A list of robot commands to move in space
C. A 3D model of the robot's shape
D. A sensor data stream from the robot's camera
Solution
Step 1: Understand the purpose of occupancy grid maps
Occupancy grid maps divide space into small cells to mark if they are free, occupied, or unknown.
Step 2: Match the description to the options
A grid showing which areas are free, occupied, or unknown correctly describes this as a grid showing cell states. Other options describe unrelated concepts.
Final Answer:
A grid showing which areas are free, occupied, or unknown -> Option A
Quick Check:
Occupancy grid = space divided into free/occupied/unknown cells [OK]
Hint: Occupancy grid = map of free or blocked spaces [OK]
Common Mistakes:
Confusing occupancy grid with robot commands
Thinking it is a 3D robot model
Mixing it up with raw sensor data
2.
Which data type correctly represents the occupancy grid map data in ROS?
nav_msgs::OccupancyGrid map;
// What type is map.data?
easy
A. bool[][]
B. std::string
C. std::vector<int8_t>
D. float[]
Solution
Step 1: Recall the ROS message type for occupancy grid data
The map.data field is a list of signed 8-bit integers representing cell states.
Step 2: Match the data type to the options
std::vector<int8_t> matches the expected type. Other options do not fit the ROS message definition.
Final Answer:
std::vector<int8_t> -> Option C
Quick Check:
map.data type = std::vector<int8_t> [OK]
Hint: Occupancy data uses vector of int8_t in ROS [OK]
Common Mistakes:
Assuming map.data is a string or float array
Thinking it is a 2D bool array
Confusing with sensor_msgs data types
3.
Given this snippet in ROS Python:
grid = [0, 100, -1, 0]
free_cells = sum(1 for cell in grid if cell == 0)
occupied_cells = sum(1 for cell in grid if cell == 100)
unknown_cells = sum(1 for cell in grid if cell == -1)
print(f"Free: {free_cells}, Occupied: {occupied_cells}, Unknown: {unknown_cells}")
What will be printed?
medium
A. Free: 1, Occupied: 1, Unknown: 2
B. Free: 1, Occupied: 2, Unknown: 1
C. Free: 2, Occupied: 0, Unknown: 2
D. Free: 2, Occupied: 1, Unknown: 1
Solution
Step 1: Count free cells (value 0) in the list
grid has two zeros at positions 0 and 3, so free_cells = 2.
In ROS, occupancy grid data must be updated through the OccupancyGrid message interface, not by directly modifying a local list copy.
Final Answer:
map_data should be updated via the OccupancyGrid message, not a plain list -> Option A
Quick Check:
Update occupancy grid via ROS message, not local list [OK]
Hint: Update occupancy grid through ROS message, not local list [OK]
Common Mistakes:
Assuming direct list change updates ROS map
Thinking index 2 is invalid
Believing 100 is invalid occupancy value
5.
You want to create a 5x5 occupancy grid map in ROS where the center cell is occupied (value 100), edges are unknown (-1), and others are free (0). Which Python code correctly creates the data list for this map?
# Options:
# A
# data = [100 if i == 12 else -1 if i % 5 == 0 or i % 5 == 4 else 0 for i in range(25)]
# B
# data = [0]*25
# data[12] = 100
# for i in range(25):
# if i % 5 == 0 or i % 5 == 4 or i < 5 or i > 19:
# data[i] = -1
# C
# data = [-1]*25
# data[12] = 100
# for i in range(25):
# if i % 5 != 0 and i % 5 != 4 and 5 <= i <= 19:
# data[i] = 0
# D
# data = [0 if i != 7 else 100 for i in range(25)]
# for i in range(25):
# if i % 5 == 0 or i % 5 == 4 or i < 5 or i > 19:
# data[i] = -1
hard
A. Creates data with center 100, edges -1, others 0 in one list comprehension
B. Starts with all 0s, sets center 100, then sets edges to -1 in a loop
C. Starts with all -1s, sets center 100, then sets inner cells to 0 in a loop
D. Starts with zeros except center 100, then sets edges -1 in a loop
Solution
Step 1: Understand the map layout requirements
Center cell (index 12) = 100, edges = -1, others = 0 in a 5x5 grid (indexes 0-24).
Step 2: Analyze each option's logic
Starts with all 0s, sets center to 100, then sets edges to -1 in a loop, matching requirements exactly.
Final Answer:
Starts with all 0s, sets center 100, then sets edges to -1 in a loop -> Option B
Quick Check:
Initialize edges as -1, center 100, inner cells 0 [OK]
Hint: Initialize edges first, then set center and free cells [OK]
Common Mistakes:
Confusing edge indexes with inner cells
Overwriting center cell after setting edges
Using incorrect conditions for edges
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.