|
libstp
Robotics library for Botball
|
#include <WorldMap.hpp>
Public Member Functions | |
| WorldMap ()=default | |
| float | tableWidthCm () const noexcept |
| float | tableHeightCm () const noexcept |
| const std::vector< MapSegment > & | segments () const noexcept |
| std::size_t | layerCount () const noexcept |
| const std::vector< MapLayer > & | layers () const noexcept |
| const std::vector< MapTransition > & | transitions () const noexcept |
| int | layerIndex (const std::string &id) const noexcept |
| Index of the layer with the given id, or -1 when absent. | |
| const std::vector< MapSegment > & | layerSegments (std::size_t idx) const noexcept |
| bool | isOnLine (float xCm, float yCm, std::size_t layerIdx) const |
| bool | isOnWall (float xCm, float yCm, std::size_t layerIdx) const |
| std::vector< MapSegment > | lines () const |
| Subset of segments() with Kind::Line. | |
| std::vector< MapSegment > | walls () const |
| bool | isOnBlackLine (float xCm, float yCm) const |
| bool | isOnLine (float xCm, float yCm) const |
| bool | isOnWall (float xCm, float yCm) const |
| float | distanceToNearestLine (float xCm, float yCm) const |
| float | distanceToNearestWall (float xCm, float yCm) const |
| Point2D | sensorFieldPosition (float robotXCm, float robotYCm, float robotHeadingRad, const SensorOffset &sensor) const |
| bool | sensorIsOnLine (float robotXCm, float robotYCm, float robotHeadingRad, const SensorOffset &sensor) const |
| Convenience: sensorFieldPosition + isOnLine. | |
| bool | sensorIsOnWall (float robotXCm, float robotYCm, float robotHeadingRad, const SensorOffset &sensor) const |
| Convenience: sensorFieldPosition + isOnWall. | |
| void | loadFtmap (const std::filesystem::path &path) |
| void | parseFtmap (const std::string &content) |
| void | setTable (float widthCm, float heightCm) noexcept |
| void | addSegment (const MapSegment &seg) |
| void | clear () noexcept |
Canonical Botball table map: bounds + line/wall segments + the geometric queries the particle filter and existing TableMap users need.
Coordinate convention: origin at bottom-left of the table, +X right, +Y up, all values in cm. The ftmap on-disk format stores Y top-down; every parser in this class flips it on ingest so the in-memory representation stays bottom-up.
This module supersedes both the in-sim WorldMap (libstp-sim still owns its copy until Phase 1 commit B migrates it) and the Python TableMap (deleted in a later commit). Sensor projection lives here so the Python side can call into it without paying FFI per particle.
Definition at line 73 of file WorldMap.hpp.
|
default |
|
inline |
Definition at line 190 of file WorldMap.hpp.
|
inlinenoexcept |
Definition at line 191 of file WorldMap.hpp.
| float libstp::map::WorldMap::distanceToNearestLine | ( | float | xCm, |
| float | yCm ) const |
Shortest distance from (xCm, yCm) to any line segment centerline, in cm. Returns +infinity when the map has no lines. Used by the particle filter as a soft observation likelihood.
| float libstp::map::WorldMap::distanceToNearestWall | ( | float | xCm, |
| float | yCm ) const |
Shortest distance from (xCm, yCm) to any wall segment OR border edge. Returns +infinity when the map has neither. Border edges are included so a robot just inside the table still gets a finite "distance to wall" reading.
| bool libstp::map::WorldMap::isOnBlackLine | ( | float | xCm, |
| float | yCm ) const |
Legacy alias — kept so callers porting from libstp::sim::WorldMap or the Python TableMap don't have to grep twice. Same logic as isOnLine.
| bool libstp::map::WorldMap::isOnLine | ( | float | xCm, |
| float | yCm ) const |
True when (xCm, yCm) is within max(0.75 cm, widthCm/2) of any line segment. The 0.75 cm floor is the heuristic carried over from the web-ide TableMapService — thin authored lines still register as "on the line" for IR detection purposes.
| bool libstp::map::WorldMap::isOnLine | ( | float | xCm, |
| float | yCm, | ||
| std::size_t | layerIdx ) const |
Layer-scoped variants of the point queries. Same semantics as the no-arg versions but against layer idx's segments (table border walls still apply to every layer).
| bool libstp::map::WorldMap::isOnWall | ( | float | xCm, |
| float | yCm ) const |
True when the point is within widthCm/2 of any wall segment OR within 0.5 cm of any of the four border edges. The border fallback is what makes "robot at the edge of the table" register as on-wall without needing the .ftmap to spell out border walls.
| bool libstp::map::WorldMap::isOnWall | ( | float | xCm, |
| float | yCm, | ||
| std::size_t | layerIdx ) const |
|
inlinenoexcept |
Definition at line 90 of file WorldMap.hpp.
|
noexcept |
Index of the layer with the given id, or -1 when absent.
|
inlinenoexcept |
Definition at line 91 of file WorldMap.hpp.
|
noexcept |
Segments of layer idx. Falls back to the ground segments when the map has no explicit layers or idx is out of range.
| std::vector< MapSegment > libstp::map::WorldMap::lines | ( | ) | const |
Subset of segments() with Kind::Line.
| void libstp::map::WorldMap::loadFtmap | ( | const std::filesystem::path & | path | ) |
Load an .ftmap file (flowchart-table-map v1, JSON-on-disk; we parse it via yaml-cpp because YAML is a JSON superset). Throws FtmapParseError for any schema violation.
| void libstp::map::WorldMap::parseFtmap | ( | const std::string & | content | ) |
Parse an in-memory ftmap payload (flowchart-table-map v1 or v2). Used by tests and by Python callers — including TableMap.from_ftmap, whose binding serializes the project's ftmap dict to JSON and hands it here so there is one parser.
|
inlinenoexcept |
Definition at line 81 of file WorldMap.hpp.
| Point2D libstp::map::WorldMap::sensorFieldPosition | ( | float | robotXCm, |
| float | robotYCm, | ||
| float | robotHeadingRad, | ||
| const SensorOffset & | sensor ) const |
Project a sensor mounted at sensor (robot-local frame) into the field frame given the robot pose. forward_cm is along the heading, strafe_cm is 90° CCW. Equivalent to the body→world rotation used by raccoon.robot.table_map.sensor_field_position (kept bit-for-bit identical so the Python TableMap can be retired without behavior drift).
| bool libstp::map::WorldMap::sensorIsOnLine | ( | float | robotXCm, |
| float | robotYCm, | ||
| float | robotHeadingRad, | ||
| const SensorOffset & | sensor ) const |
Convenience: sensorFieldPosition + isOnLine.
| bool libstp::map::WorldMap::sensorIsOnWall | ( | float | robotXCm, |
| float | robotYCm, | ||
| float | robotHeadingRad, | ||
| const SensorOffset & | sensor ) const |
Convenience: sensorFieldPosition + isOnWall.
|
inlinenoexcept |
Definition at line 185 of file WorldMap.hpp.
|
inlinenoexcept |
Definition at line 80 of file WorldMap.hpp.
|
inlinenoexcept |
Definition at line 79 of file WorldMap.hpp.
|
inlinenoexcept |
Definition at line 92 of file WorldMap.hpp.
| std::vector< MapSegment > libstp::map::WorldMap::walls | ( | ) | const |
Subset of segments() with Kind::Wall plus the four table border edges synthesized from the table bounds. The border edges have width=0 — isOnWall treats them as zero-thickness collision lines via the same min-threshold rule used for thin black lines.