-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[attitudeObserver] Add gyro-bias management #17
base: main
Are you sure you want to change the base?
Changes from all commits
22fde99
e8ff421
3de4565
caa44df
ba39b14
a40996e
853013b
66d754e
7674685
4f9ba84
b7ee02f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -11,9 +11,9 @@ namespace mc_state_observation | |||||
struct AttitudeObserver : public mc_observers::Observer | ||||||
{ | ||||||
EIGEN_MAKE_ALIGNED_OPERATOR_NEW | ||||||
using indexes = stateObservation::kine::indexes<stateObservation::kine::rotationVector>; | ||||||
using indexes = stateObservation::IMUDynamicalSystem::indexes; | ||||||
|
||||||
public: | ||||||
public: | ||||||
AttitudeObserver(const std::string & type, double dt); | ||||||
|
||||||
void configure(const mc_control::MCController & ctl, const mc_rtc::Configuration &) override; | ||||||
|
@@ -32,7 +32,10 @@ struct AttitudeObserver : public mc_observers::Observer | |||||
double gyroCovariance = 1e-10; | ||||||
double orientationAccCov = 0.003; | ||||||
double linearAccCov = 1e-13; | ||||||
double biasDriftCov = 1e-10; | ||||||
double biasInitCov = 1e-7; | ||||||
double stateCov = 3e-14; | ||||||
double oriCov = 1e-12; | ||||||
double stateInitCov = 1e-8; | ||||||
Comment on lines
32
to
39
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not directly related to this PR, but I found a bug in |
||||||
Eigen::Matrix3d offset = Eigen::Matrix3d::Identity(); ///< Offset to apply to the estimation result | ||||||
void addToLogger(mc_rtc::Logger & logger, const std::string & category); | ||||||
|
@@ -62,6 +65,11 @@ struct AttitudeObserver : public mc_observers::Observer | |||||
mc_rtc::gui::StateBuilder &, | ||||||
const std::vector<std::string> & /* category */) override; | ||||||
|
||||||
void switchWithGyroBias(bool); | ||||||
|
||||||
void setGyroBiasToMeanValue(); /// set the value of the bias to the mean identified value | ||||||
void startGyroBiasIdentification(); /// start the identification of the bias from the curren gyro readings | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
protected: | ||||||
/// @{ | ||||||
std::string robot_ = ""; ///< Name of robot to which the IMU sensor belongs | ||||||
|
@@ -72,12 +80,14 @@ struct AttitudeObserver : public mc_observers::Observer | |||||
KalmanFilterConfig config_; ///< Current configuration for the KF (GUI, etc...) | ||||||
bool log_kf_ = false; ///< Whether to log the parameters of the kalman filter | ||||||
bool initFromControl_ = true; ///< Whether to initialize from the control state | ||||||
/// @} | ||||||
bool withGyroBias_ = false; ///< Whether the estimator will be considering gyro bias | ||||||
|
||||||
/// Sizes of the states for the state, the measurement, and the input vector | ||||||
static constexpr unsigned STATE_SIZE = 18; | ||||||
static constexpr unsigned MEASUREMENT_SIZE = 6; | ||||||
static constexpr unsigned INPUT_SIZE = 6; | ||||||
static constexpr stateObservation::Index STATE_SIZE_BASE = 18; | ||||||
static constexpr stateObservation::Index MEASUREMENT_SIZE = 6; | ||||||
static constexpr stateObservation::Index INPUT_SIZE = 6; | ||||||
|
||||||
stateObservation::Index stateSize_ = STATE_SIZE_BASE; | ||||||
|
||||||
double lastStateInitCovariance_; | ||||||
|
||||||
|
@@ -93,12 +103,23 @@ struct AttitudeObserver : public mc_observers::Observer | |||||
stateObservation::Vector uk_; | ||||||
stateObservation::Vector xk_; | ||||||
|
||||||
stateObservation::Matrix3 Kpt_, Kdt_; | ||||||
stateObservation::Matrix3 Kpo_, Kdo_; | ||||||
stateObservation::Matrix3 Kpt_, Kdt_, Kat_; | ||||||
stateObservation::Matrix3 Kpo_, Kdo_, Kao_; | ||||||
|
||||||
Eigen::Matrix3d m_orientation = Eigen::Matrix3d::Identity(); ///< Result | ||||||
}; | ||||||
Eigen::Vector3d m_gyrobias = Eigen::Vector3d::Zero(); | ||||||
Eigen::Vector3d m_gyroMeasurementTotal = | ||||||
Eigen::Vector3d::Zero(); /// the sum of values of gyro measurements (used to compute the mean value) | ||||||
unsigned m_numberOfValues = 0; | ||||||
|
||||||
bool m_resetGUI = false; | ||||||
std::vector<std::string> m_category; | ||||||
|
||||||
bool m_gyroBiasFromMeasurement_running = false; /// sets if the identification of the gyro bias is stoped | ||||||
|
||||||
Eigen::Vector3d m_accIn = Eigen::Vector3d::Zero(); | ||||||
Eigen::Vector3d m_rateIn = Eigen::Vector3d::Zero(); | ||||||
}; | ||||||
|
||||||
} // namespace mc_state_observation | ||||||
|
||||||
|
@@ -116,6 +137,7 @@ struct ConfigurationLoader<mc_state_observation::AttitudeObserver::KalmanFilterC | |||||
config("gyr_cov", c.gyroCovariance); | ||||||
config("ori_acc_cov", c.orientationAccCov); | ||||||
config("lin_acc_cov", c.linearAccCov); | ||||||
config("bias_drift_cov", c.biasDriftCov); | ||||||
config("state_cov", c.stateCov); | ||||||
config("state_init_cov", c.stateInitCov); | ||||||
return c; | ||||||
|
@@ -128,6 +150,7 @@ struct ConfigurationLoader<mc_state_observation::AttitudeObserver::KalmanFilterC | |||||
config.add("acc_cov", c.acceleroCovariance); | ||||||
config.add("gyr_cov", c.gyroCovariance); | ||||||
config.add("ori_acc_cov", c.orientationAccCov); | ||||||
config.add("bias_drift_cov", c.biasDriftCov); | ||||||
config.add("lin_acc_cov", c.linearAccCov); | ||||||
config.add("state_cov", c.stateCov); | ||||||
config.add("state_init_cov", c.stateInitCov); | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should make this a version requirement in cmake
find_package
.While trying this PR locally, I didn't update the
state-observation
package. Viciously, this builds, but the estimation is nonsense (with the stabilizer just standing, the robot estimate leans backwards and the robot falls forward). I assume this is because of an index mismatch.Enforcing the minimal version of
state-observation
would prevent such subtle errors.