robot.table_map¶
Table map model for Botball field geometry.
Stores line and wall segments from the .ftmap vector format and provides spatial queries (point-on-line, point-on-wall, distance-to-nearest-line).
The coordinate system matches the Botball field: origin at bottom-left, X right, Y up, all values in centimeters.
Example usage:
from raccoon.robot.table_map import TableMap
# Load from ftmap dict (as stored in raccoon.project.yml)
table_map = TableMap.from_ftmap(config["robot"]["physical"]["table_map"])
# Load from .ftmap file
table_map = TableMap.load("config/table_map.ftmap")
# Query
table_map.is_on_line(50.0, 30.0) # True/False
table_map.is_on_wall(0.0, 50.0) # True/False
table_map.distance_to_nearest_line(50.0, 30.0) # cm
Classes¶
A single line or wall segment on the field, in centimeters. |
|
Botball field table map with line and wall segments. |
Module Contents¶
- class robot.table_map.MapSegment¶
A single line or wall segment on the field, in centimeters.
- class robot.table_map.TableMap(width_cm: float, height_cm: float, segments: Sequence[MapSegment] = ())¶
Botball field table map with line and wall segments.
All coordinates are in centimeters with origin at bottom-left of the field.
- width_cm¶
- height_cm¶
- property lines: List[MapSegment]¶
- property walls: List[MapSegment]¶
- property all_segments: List[MapSegment]¶
- classmethod from_ftmap(data: Dict[str, Any]) TableMap¶
Create a TableMap from an ftmap dict (as stored in project config).
- Parameters:
data – Dict with keys
format,version,table,lines.- Returns:
A populated TableMap instance.
- Raises:
ValueError – If the format or version is unsupported.
- classmethod load(path: str | pathlib.Path) TableMap¶
Load a TableMap from a
.ftmapJSON file.- Parameters:
path – Path to the .ftmap file.
- Returns:
A populated TableMap instance.
- distance_to_nearest_line(x_cm: float, y_cm: float) float¶
Shortest distance from a point to any line segment centerline.
- Parameters:
x_cm – X position on field (cm from left).
y_cm – Y position on field (cm from bottom).
- Returns:
Distance in cm, or
float('inf')if there are no lines.
- distance_to_nearest_wall(x_cm: float, y_cm: float) float¶
Shortest distance from a point to any wall segment centerline.
- Parameters:
x_cm – X position on field (cm from left).
y_cm – Y position on field (cm from bottom).
- Returns:
Distance in cm, or
float('inf')if there are no walls.
- is_on_line(x_cm: float, y_cm: float) bool¶
Check if a point is within any line segment’s width.
A point is “on” a line if its perpendicular distance to the segment centerline is less than half the line’s width.
- Parameters:
x_cm – X position on field (cm from left).
y_cm – Y position on field (cm from bottom).
- Returns:
True if the point overlaps a line.
- is_on_wall(x_cm: float, y_cm: float) bool¶
Check if a point is within any wall segment’s width.
- Parameters:
x_cm – X position on field (cm from left).
y_cm – Y position on field (cm from bottom).
- Returns:
True if the point overlaps a wall.
- sensor_field_position(robot_x_cm: float, robot_y_cm: float, robot_heading_rad: float, sensor: raccoon.robot.geometry.SensorPosition) tuple[float, float]¶
Compute the field position of a sensor given robot pose.
The robot pose is in field coordinates (origin bottom-left, heading 0 = +X, CCW positive). The sensor position is in robot-relative coordinates (forward/strafe from geometric center).
- Parameters:
robot_x_cm – Robot center X on field (cm).
robot_y_cm – Robot center Y on field (cm).
robot_heading_rad – Robot heading (radians, 0 = +X, CCW positive).
sensor – SensorPosition with forward_cm and strafe_cm offsets.
- Returns:
Tuple of (field_x_cm, field_y_cm) for the sensor.
- sensor_is_on_line(robot_x_cm: float, robot_y_cm: float, robot_heading_rad: float, sensor: raccoon.robot.geometry.SensorPosition) bool¶
Check if a sensor would be over a black line given current robot pose.
- Parameters:
robot_x_cm – Robot center X on field (cm).
robot_y_cm – Robot center Y on field (cm).
robot_heading_rad – Robot heading (radians).
sensor – SensorPosition offset from robot center.
- Returns:
True if the sensor’s field position overlaps a line.
- sensor_is_on_wall(robot_x_cm: float, robot_y_cm: float, robot_heading_rad: float, sensor: raccoon.robot.geometry.SensorPosition) bool¶
Check if a sensor would be over a wall given current robot pose.
- Parameters:
robot_x_cm – Robot center X on field (cm).
robot_y_cm – Robot center Y on field (cm).
robot_heading_rad – Robot heading (radians).
sensor – SensorPosition offset from robot center.
- Returns:
True if the sensor’s field position overlaps a wall.