|
Enki
1.9
|
A generic infrared sensor. More...
#include <IRSensor.h>
Public Member Functions | |
| IRSensor (Robot *owner, Vector pos, double height, double orientation, double range, double m, double x0, double c, double noiseSd=0.) | |
| Constructor. More... | |
| void | init (double dt, World *w) |
| Reset distance values. | |
| void | objectStep (double dt, World *w, PhysicalObject *po) |
| Check for all potential intersections using smartRadius of sensor and calculate and find closest distance for each ray. | |
| void | wallsStep (double dt, World *w) |
| Separated from objectStep because it is much simpler. | |
| void | finalize (double dt, World *w) |
| Applies the SensorResponseFunction to each ray and combines all rays using weights defined in the rayCombinationKernel. | |
| double | getValue (void) const |
| Return the final sensor value. | |
| double | getDist (void) const |
| Return the distance through the inverse response of the final sensor value. | |
| double | getRayValue (unsigned i) const |
| Return the value of a ray. | |
| double | getRayDist (unsigned i) const |
| Return the distance of a ray. | |
| Point | getAbsolutePosition (void) const |
| Return the absolute position of the IR sensor, updated at each time step on init() | |
| double | getAbsoluteOrientation (void) const |
| Return the absolute orientation of the IR sensor, updated at each time step on init() | |
| unsigned | getRayCount (void) const |
| Return the number of rays. | |
| double | getAperture (void) const |
| Return the aperture of the sensor. | |
| double | getRange (void) const |
| Return the range of the sensor. | |
| double | getSmartRadius (void) const |
| Return the radius for the smallest circle enclosing all rays. | |
| Point | getAbsSmartPos (void) const |
| Return current position of the center of the smartRadius, i.e. center of the smallest circle enclosing all rays in relative (robot) coordinates. | |
Public Member Functions inherited from Enki::LocalInteraction | |
| LocalInteraction () | |
| Constructor. | |
| LocalInteraction (double range, Robot *owner) | |
| Constructor. | |
| virtual | ~LocalInteraction () |
| Destructor. | |
| double | getRange () const |
| Return the range of the interaction. | |
Protected Member Functions | |
| void | updateRay (size_t i, double dist) |
| If dist is smaller than current ray distance, update distance and response value. | |
| double | responseFunction (double x) const |
| Return the response for a given distance. | |
| double | inverseResponseFunction (double v) const |
| Return the inverse response for a given distance. | |
| double | distanceToPolygon (double rayAngle, const Polygone &p) const |
| Returns distance to PhysicalObject po for angle rayAngle. More... | |
Protected Attributes | |
| Vector | absPos |
| Absolute position in the world, updated on init() | |
| double | absOrientation |
| Absolute orientation in the world, updated on init() | |
| const Vector | pos |
| Relative position on the robot. | |
| const double | height |
| Height above ground, the sensor will not see any object of smaller height. | |
| const double | orientation |
| Relative orientation on the robot. | |
| const double | range |
| Actual detection range. | |
| const double | aperture |
| Aperture angle. | |
| const double | alpha |
| 1/cos(aperture) | |
| const unsigned | rayCount |
| Number of rays used, each ray has an aperture of aperture/rayCount to the next one. Rays are assembled from right to left (i.e. counterclockwise) | |
| const double | m |
| Maximum possible response value, might be inside the robot if x0<0, first parameter of response function. | |
| const double | x0 |
| Position of the maximum of response (might be negative, inside the robot), second parametere of response function. | |
| const double | c |
| Third parameter of response function. | |
| const double | noiseSd |
| Standard deviation of Gaussian noise in the response space. | |
| double | smartRadius |
| Radius for the smallest circle enclosing all rays. | |
| Point | smartPos |
| Current position of the center of the smartRadius, i.e. center of the smallest circle enclosing all rays in relative (robot) coordinates. | |
| Vector | absSmartPos |
| Current position of the center of the smartRadius in absolute (world) coordinates, updated on init() | |
| std::vector< double > | rayDists |
| Temporary ray values containing the lowest distance found up to now. | |
| std::vector< double > | rayValues |
| Temporary ray values containing the response value of the closest object found up to now. | |
| std::vector< double > | rayAngles |
| The angle for each ray relative to the sensor orientation in relative (robot) coordinates. | |
| std::vector< double > | absRayAngles |
| The angle for each ray relative to the sensor orientation in absolute (world) coordinates. | |
| double | finalValue |
| Final sensor value. | |
| double | finalDist |
| Final computed distance. | |
Protected Attributes inherited from Enki::LocalInteraction | |
| double | r |
| Radius of the local interaction. | |
| Robot * | owner |
| The physical object that owns the interaction. | |
A generic infrared sensor.
This sensor is based on a inverse square response function and three casted rays.
During objectStep() and wallsStep() it casts the three rays, separated by an angle of 15 degrees. Distances are in cm. For negative distance values, i.e. a sensor inside an object, wall, etc., the value of the sensor response function at distance 0 will be used. If a ray fails to touch the object, the distance returned will be HUGE_VAL; the sensor response function will return a 0 sensor response for this case.
Upon finalize(), it computes finalValue and finalDist. It does so first using the following equation for each ray:
m * (c - x0*x0)
value = F(x) = ----------------
x*x - 2*x0*x + c
where x is the distance to the obstacle.
It then combines the three rays with this equation:
finalValue = F(d_center) + F(d_left) + F(d_right) - 2*F(d_center*alpha)
where d_R is the distance of ray R, and alpha is 1/cos(15 degrees).
Finally, it computes the final distance using:
finalDist = F-1(finalValue)
where: m F-1(v) = x0 + sqrt( (x0*x0-c) * ( 1 - — ) ) v
TODO SensorResponseFunctors translate the distances stored in the rayValues[] into actual sensor activations. An appropriate noise model (if realistic modelling is desired) should be included in the sensor response function.
| Enki::IRSensor::IRSensor | ( | Robot * | owner, |
| Vector | pos, | ||
| double | height, | ||
| double | orientation, | ||
| double | range, | ||
| double | m, | ||
| double | x0, | ||
| double | c, | ||
| double | noiseSd = 0. |
||
| ) |
Constructor.
| owner | robot which embeds this sensor |
| pos | relative position (x,y) on the robot |
| height | height above ground, the sensor will not see any object of smaller height |
| orientation | relative orientation on the robot |
| range | detection range, objects over this range will not be seen |
| m | maximum possible response value, might be inside the robot if x0<0, first parameter of response function |
| x0 | position of the maximum of response (might be negative, inside the robot), second parametere of response function |
| c | third parameter of response function |
| noiseSd | standard deviation of Gaussian noise in the response space |
References absRayAngles, Enki::Vector::angle(), aperture, finalDist, finalValue, Enki::Vector::norm(), Enki::Vector::norm2(), Enki::LocalInteraction::owner, Enki::LocalInteraction::r, range, rayAngles, rayCount, rayDists, rayValues, smartPos, and smartRadius.
|
protected |
Returns distance to PhysicalObject po for angle rayAngle.
Note: The polygon MUST be convex and have vertices oriented counterclockwise (ccw). This code does not check for and verify these conditions. Returns distance to shortest intersection point or HUGE_VAL if there is no intersection
References Enki::Segment::a, absPos, Enki::Segment::b, Enki::Vector::cross(), range, Enki::Vector::x, and Enki::Vector::y.
Referenced by getAbsSmartPos(), and objectStep().
1.8.11