-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEKFSlammer.h
102 lines (73 loc) · 3.39 KB
/
EKFSlammer.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
//
// Created by Swapnil on 3/17/2018.
//
#ifndef EKFSLAM_EKFSLAMMER_H
#define EKFSLAM_EKFSLAMMER_H
#include "Eigen/Dense"
#include "Utils.h"
#include "Robot.h"
class EKFSlammer {
private:
Eigen::VectorXd x; // State (location of the robot and all elements in map)
Eigen::MatrixXd cov; // Covariance matrix for state vector
//Stores the components of gravity in the x and y directions of the accelerometers
//This accounts for the accelerometer not being completely level
Eigen::Vector2d g;
int n; //Number of stored landmark features
//Mahalanobis distance threshold for classifying observed features as new
double newFeatureThreshold;
//Time step for the state update
const double TIME_STEP;
public:
//EKFSlammer
EKFSlammer(const Robot &r);
Eigen::MatrixXd getState() const;
Eigen::MatrixXd getCov() const;
//getRotationMat
//Returns 2x2 rotation matrix describing the transformation from the world reference frame to the
//robot reference frame
Eigen::Matrix2d getRotationMat() const;
//getRotationMat
//Returns 2x2 inverse rotation matrix the transformation from the robot's reference frame to the
//world reference frame
Eigen::Matrix2d getRotationMatInverse() const;
//getMotionModelUncertainty
//Returns the uncertainty in the motion model update
Eigen::Matrix3d getMotionModelUncertainty(const control &cIn) const;
//motionModelUpdate
//Calculates the predicted position of the robot based on the command passed
//TODO: Add data type for passing command.
void motionModelUpdate(const double &deltaT, const control &controlIn);
//setZeroPosition
//Transforms the world reference frame to be zeroed at the new zero position (passed relative to the robot)
void setZeroPosition(const Eigen::Vector2d &arucoMarker);
//getTimeStep
//Returns the elpased time between time steps
double getTimeStep() const;
//encoderUpdate, arucoUpdate, and kinectUpdate are all methods for the SLAM correction step
//These three methods collect data from the respective sensors, calculate the expected observation
//calculate the Kalman gain, and update the predicted state
//encoderUpdate
//Encoders return an estimated state for the robot
//void encoderUpdate(Eigen::Matrix3d encEstPos);
void kinectUpdate(const Eigen::VectorXd &z);
void accelerometerUpdate(const Eigen::Vector2d &previousS,
const Eigen::Vector2d &gamma,
const Eigen::Vector2d encoder);
void gyroUpdate(const double &previousTheta, const double &beta);
void arucoUpdate(const Eigen::Vector2d &arucoMarker);
void ekfCorrectionStep(const Eigen::VectorXd &kinectObstacles,
const Eigen::Vector2d &previousS,
const Eigen::Vector2d &gamma,
const Eigen::Vector2d &encoder,
const double &previousTheta,
const double &beta,
const Eigen::Vector2d &arucoMarker);
void ekfUpdate(const control &controlIn,
const Eigen::VectorXd &kinectObstacles,
const Eigen::Vector2d &gamma,
const Eigen::Vector2d &encoder,
const double &beta,
const Eigen::Vector2d &arucoMarker);
};
#endif //EKFSLAM_EKFSLAMMER_H