Simultaneous localisation and mapping with an extended Kalman filter: a robot works out where it is and where the landmarks around it are, at the same time, from odometry and range-and-bearing sightings of the landmarks.
More...
|
| | EKFSlam (const Pose &start, const Parameters ¶meters) |
| | EKFSlam (const EKFSlam &)=delete |
| EKFSlam & | operator= (const EKFSlam &)=delete |
| void | predict (real_t distance, real_t turn) |
| | Move the robot with the odometry of one step: it drove distance [m] and turned by turn [rad].
|
| uint_t | update (const std::vector< Observation > &sightings) |
| | Correct with sightings taken at the same time. Returns how many were used: added as new landmarks, or accepted by the gate.
|
| AssociationResult | update_unknown (const std::vector< Sighting > &sightings) |
| | Correct with sightings taken at the same time whose landmarks are not known: work out which landmark each is of, or whether it is a new one, see the class. Do not mix with update() on the same filter unless the ids cannot collide: new landmarks take the next id after the largest in the map.
|
| AssociationResult | update_unknown (const std::vector< Sighting > &sightings, const Association &association) |
| real_t | mahalanobis (uint_t id, const Sighting &sighting) const |
| | The squared Mahalanobis distance of a sighting from landmark id: how many variances of the innovation apart what was seen and what the estimate expects are.
|
| Pose | pose () const |
| DynMat< real_t > | pose_covariance () const |
| | The 3 x 3 covariance of (x, y, yaw).
|
| uint_t | n_landmarks () const noexcept |
| bool | has_landmark (uint_t id) const |
| const std::vector< uint_t > & | landmark_ids () const noexcept |
| | The ids of the landmarks, in the order they were mapped.
|
| std::array< real_t, 2 > | landmark (uint_t id) const |
| | Where landmark id is [m].
|
| DynMat< real_t > | landmark_covariance (uint_t id) const |
| | The 2 x 2 covariance of landmark id.
|
| const DynMat< real_t > & | covariance () const |
| | The covariance of the whole state.
|
| uint_t | n_rejected () const noexcept |
| | How many re-sightings the gate turned away.
|
| const Parameters & | parameters () const noexcept |
Simultaneous localisation and mapping with an extended Kalman filter: a robot works out where it is and where the landmarks around it are, at the same time, from odometry and range-and-bearing sightings of the landmarks.
Odometry alone drifts: every step adds a little error, and nothing takes it out. A landmark the robot sees is a fixed point it can measure itself against, but only if it knows where the landmark is, which it can only work out from where it thinks it is itself. EKF-SLAM keeps both in one state, (x, y, yaw, m1x, m1y, m2x, m2y, ...), with one covariance over all of it. That covariance holds how the errors of the robot and of every landmark are tied together, and that is what makes it work: when the robot sees again a landmark it mapped long ago, the correction reaches its own pose and every landmark correlated with it. This is loop closure.
- predict() moves the robot with the odometry, see SlamMotionModel;
- update() takes sightings of landmarks, each a range and a bearing from the robot. A landmark seen for the first time is added to the state, where the sighting puts it, with a covariance that ties it to the robot's; a landmark seen before corrects the whole state, through the gate of ExtendedKalmanFilter.
With update() every landmark has an id, as a fiducial marker does, so the filter knows which landmark each sighting is of. Without ids it has to work that out itself, data association, and update_unknown() does: it scores every sighting against every landmark by the squared Mahalanobis distance of the innovation, \(d^2 = \nu^T S^{-1} \nu\), which measures the difference between what was seen and what was expected against how uncertain both are. Then
- it pairs sightings and landmarks greedily, the smallest \(d^2\) first, if it is within Association::match_gate, each landmark with at most one sighting of a scan: two posts seen at once are two posts;
- a sighting left over that is beyond Association::new_gate from every landmark is a new landmark, and gets the next free id;
- one in between could be either, and is not used: a doubtful sighting is cheaper to drop than to believe.
A pairing is final: a wrong one moves the robot and the map to agree with it, and the filter cannot take it back. That is why the gate measures against the uncertainty and not in metres: the same 20 cm is a good match far from the start and a bad one next to it.
The map's frame is the robot's start: its first pose is known exactly, so the uncertainty grows from there.
The state, and so the work of each step, grows with the number of landmarks: predict and update cost \(O(n^3)\) here for n values in the state. That is fine for tens of landmarks; large maps need sparser methods.