libstp
Robotics library for Botball
Loading...
Searching...
No Matches
libstp::sim::collision Namespace Reference

Classes

struct  CollisionInfo

Functions

std::vector< MapSegment > buildCollisionWalls (const WorldMap &map)
std::vector< MapSegment > buildCollisionWalls (const WorldMap &map, std::size_t layerIdx)
std::optional< CollisionInfo > findCollision (const Pose2D &pose, const Vec2 &moveVec, const RobotConfig &robot, const std::vector< MapSegment > &walls)
Pose2D resolveAgainstWall (const Pose2D &pose, const CollisionInfo &collision, const RobotConfig &robot)
std::vector< Pose2D > simulateSegment (const Pose2D &start, const Pose2D &target, const RobotConfig &robot, const std::vector< MapSegment > &walls)
bool checkRobotCollision (const Pose2D &pose, const RobotConfig &robot, const std::vector< MapSegment > &walls)
float raycastDistanceCm (float originX, float originY, float angleRad, float maxDistanceCm, const std::vector< MapSegment > &walls)

Function Documentation

◆ buildCollisionWalls() [1/2]

std::vector< MapSegment > libstp::sim::collision::buildCollisionWalls ( const WorldMap & map)

Expand thick walls into 4-edge rectangles, append table borders. Port of web-ide physics.ts buildCollisionWalls(). Uses the ground/active layer's walls.

◆ buildCollisionWalls() [2/2]

std::vector< MapSegment > libstp::sim::collision::buildCollisionWalls ( const WorldMap & map,
std::size_t layerIdx )

Layer-scoped variant: collide against the walls of layer layerIdx (plus the table border, which applies to every plane). Used by the sim so a robot on the raised ramp respects that layer's geometry.

◆ checkRobotCollision()

bool libstp::sim::collision::checkRobotCollision ( const Pose2D & pose,
const RobotConfig & robot,
const std::vector< MapSegment > & walls )

True if the robot's OBB at pose intersects any wall. Port of physics.ts checkRobotCollision().

◆ findCollision()

std::optional< CollisionInfo > libstp::sim::collision::findCollision ( const Pose2D & pose,
const Vec2 & moveVec,
const RobotConfig & robot,
const std::vector< MapSegment > & walls )

Deepest wall the robot's OBB currently penetrates, if any. Port of physics.ts findCollision(). moveVec is the motion that was attempted; walls facing away from it are ignored.

◆ raycastDistanceCm()

float libstp::sim::collision::raycastDistanceCm ( float originX,
float originY,
float angleRad,
float maxDistanceCm,
const std::vector< MapSegment > & walls )

Closest-hit raycast against a set of wall segments. originX, originY in cm, angleRad is the world-frame direction. Returns the distance (cm) to the first wall hit within maxDistanceCm, or maxDistanceCm if no wall is hit (clean miss to max range).

◆ resolveAgainstWall()

Pose2D libstp::sim::collision::resolveAgainstWall ( const Pose2D & pose,
const CollisionInfo & collision,
const RobotConfig & robot )

Push a penetrating pose out along the collision normal. Port of physics.ts resolvePoseAgainstWall().

◆ simulateSegment()

std::vector< Pose2D > libstp::sim::collision::simulateSegment ( const Pose2D & start,
const Pose2D & target,
const RobotConfig & robot,
const std::vector< MapSegment > & walls )

Integrate a motion from start → target with per-step wall collision and tangent sliding. Port of physics.ts simulateSegment(). Returns the trail of poses the robot actually visited (empty if no motion).