|
|
| RangeSensor (const Transform2D &tf, float obstacleDegree=0) |
| |
|
| RangeSensor (float obstacleDegree=0) |
| |
|
bool | begin () |
| | Start the sensor (e.g., initialize hardware)
|
| |
|
void | update (float angleDeg, float distanceM) |
| | Update the sensor with angle (deg) and distance (m)
|
| |
|
void | update (Angle angle, Distance distance) |
| | Update the sensor with angle and distance objects.
|
| |
|
void | end () |
| | Stop the sensor.
|
| |
|
void | setObstacleDirectionDegree (float deg) |
| | Defines the angle to the obstacle in degrees: 0 means forward.
|
| |
|
void | setObstacleDirection (Angle angle) |
| | Set the obstacle direction using an Angle object.
|
| |
| float | getObstacleDirectionDegree () const |
| |
| bool | setObstacleDistance (Distance dist) |
| |
| bool | setObstacleDistance (float distanceM) |
| |
|
void | setObstacleAlertAngle (Angle deg) |
| | Set the alert angle threshold for obstacle detection.
|
| |
|
void | setObstacleAlertDistance (Distance dist) |
| | Set the alert distance threshold for obstacle detection.
|
| |
| float | getObstacleDistance () const |
| |
|
void | setObstacle (float degree, float distance) |
| | Convenience method to set both the obstacle bearing and distance at once.
|
| |
|
void | setTransform (const Transform2D &tf) |
| | Set the sensor-to-world transform.
|
| |
| bool | getObstacleCoordinate (Coordinate< T > &result) |
| |
|
| operator bool () const |
| | Check if the sensor reading is valid (distance > 0)
|
| |
|
bool | hasObstacle () const |
| | Return true if there is an obstacle detected (distance > 0)
|
| |
|
float | getSpeedFactor (Distance breakingDistance) const |
| | Compute a speed factor (0.0 to 1.0) based on the distance to the obstacle.
|
| |
| void | subscribe (MessageHandler &handler, MessageOrigin origin=MessageOrigin::Undefined, MessageContent content=MessageContent::Undefined) |
| | Subscribe a message handler to this source, with optional filtering.
|
| |
|
void | unsubscribeAll () |
| | Remove all registered message handlers.
|
| |
| void | sendMessage (Message< float > &msg) |
| | Publish a message to all registered handlers.
|
| |
| void | sendMessage (const Message< Coordinate< float > > &msg) |
| | Publish a message to all registered handlers.
|
| |
| void | sendMessage (const Message< GPSCoordinate > &msg) |
| | Publish a message to all registered handlers.
|
| |
|
void | sendMessage (const Message< MotionState3D > &msg) |
| | Overload for MotionState3D messages.
|
| |
template<typename T = DistanceM>
class tinyrobotics::RangeSensor< T >
Generic range sensor abstraction for LIDAR, ultrasonic, or similar sensors.
This template class models a simple range sensor, such as a LIDAR or ultrasonic sensor, for robotics applications. It tracks the measured distance to an obstacle, the angle (bearing) of the obstacle relative to the sensor, and the transform from the sensor's local frame to the world frame. The class provides methods to set and retrieve the measured distance and bearing, update the sensor-to-world transform, and compute the world-frame coordinates of detected obstacles.
Features
- Supports any distance unit via template parameter (default: meters)
- Publishes distance, angle, and obstacle position as messages (for integration with messaging framework)
- Computes obstacle coordinates in the world frame using a 2D transform
- Validity checks for sensor readings (distance > 0)
- Can be used for navigation, mapping, and obstacle avoidance
Usage Example
sensor.begin();
sensor.setObstacleDistance(1.5f);
if (sensor) {
if (sensor.getObstacleCoordinate(obs)) {
}
}
A generic 3D coordinate class for robotics, navigation, and spatial calculations.
Definition: Coordinate.h:57
Generic range sensor abstraction for LIDAR, ultrasonic, or similar sensors.
Definition: RangeSensor.h:69
Template Parameters
- Template Parameters
-
Methods
- setObstacleDirectionDegree(deg): Set obstacle bearing in degrees
- setObstacleDistance(distance): Set measured distance
- setObstacle(degree, distance): Set both bearing and distance
- setTransform(tf): Set sensor-to-world transform
- getObstacleCoordinate(result): Compute world-frame obstacle coordinate
- hasObstacle(): True if a valid obstacle is detected
Applications
- LIDAR, ultrasonic, or IR range sensing
- Robot navigation and mapping
- Obstacle detection and avoidance
- Author
- Phil Schatzmann