|
| 1 | +/** |
| 2 | + * @file CenterOfMassKalmanFilter.h |
| 3 | + * @authors Prashanth Ramadoss |
| 4 | + * @copyright 2021 Istituto Italiano di Tecnologia (IIT). This software may be modified and |
| 5 | + * distributed under the terms of the GNU Lesser General Public License v2.1 or any later version. |
| 6 | + */ |
| 7 | + |
| 8 | +#ifndef BIPEDAL_LOCOMOTION_ESTIMATORS_CENTER_OF_MASS_KALMAN_FILTER_H |
| 9 | +#define BIPEDAL_LOCOMOTION_ESTIMATORS_CENTER_OF_MASS_KALMAN_FILTER_H |
| 10 | + |
| 11 | +#include <BipedalLocomotion/System/Source.h> |
| 12 | +#include <iDynTree/KinDynComputations.h> |
| 13 | +#include <Eigen/Dense> |
| 14 | + |
| 15 | +#include <memory> |
| 16 | + |
| 17 | +namespace BipedalLocomotion |
| 18 | +{ |
| 19 | +namespace Estimators |
| 20 | +{ |
| 21 | + |
| 22 | +/** |
| 23 | + * Internal state of a constant height CoM Kalman Filter |
| 24 | + */ |
| 25 | +struct CoMKFState |
| 26 | +{ |
| 27 | + Eigen::Vector2d comPosition; |
| 28 | + Eigen::Vector2d comVelocity; |
| 29 | + Eigen::Vector2d comOffset; |
| 30 | +}; |
| 31 | + |
| 32 | +struct CoMKFInput |
| 33 | +{ |
| 34 | + Eigen::Vector2d globalCoP; |
| 35 | + Eigen::Vector3d acc, gyro; |
| 36 | +}; |
| 37 | + |
| 38 | +/** |
| 39 | + * Implements the constant height LIPM model based Kalman filter |
| 40 | + * described in the paper, |
| 41 | + * "Center of Mass Estimator for Humanoids and its Application in |
| 42 | + * Modelling Error Compensation, Fall Detection and Prevention" |
| 43 | + * to estimate the horizontal center of mass position and velocity |
| 44 | + * |
| 45 | + * assumptions, |
| 46 | + * - constant height CoM LIPM model |
| 47 | + * - the IMU is rigidly attached to the base link |
| 48 | + * - CoM is always close to the same rigid body as the IMU |
| 49 | + * - constant angular velocity is assumed, making angular acceleration is zero |
| 50 | + */ |
| 51 | +class CenterOfMassKalmanFilter : public BipedalLocomotion::System::Advanceable<CoMKFInput, CoMKFState> |
| 52 | +{ |
| 53 | +public: |
| 54 | + CenterOfMassKalmanFilter(); |
| 55 | + ~CenterOfMassKalmanFilter(); |
| 56 | + /** |
| 57 | + * Initialize the estimator. |
| 58 | + * @param paramHandler pointer to the parameters handler. |
| 59 | + * @note the following parameters are required by the class |
| 60 | + * | Parameter Name | Type | Description | Mandatory | |
| 61 | + * |:-----------------------------------------:|:--------:|:--------------------------------------------------------------------------------------:|:---------:| |
| 62 | + * | `sampling_time` | `double` | Sampling period in seconds | Yes | |
| 63 | + * | `base_link_imu` | `string` | name of the IMU attached to the base link | Yes | |
| 64 | + * | `com_position_measurement_noise_var` | `double` | covariance of center of mass position measurement noise | Yes | |
| 65 | + * | `com_acceleration_measurement_noise_var` | `double` | covariance of center of mass acceleration measurement noise | Yes | |
| 66 | + * | `com_position_prediction_noise_var` | `double` | covariance of center of mass position prediction noise | Yes | |
| 67 | + * | `com_velocity_prediction_noise_var` | `double` | covariance of center of mass velocity prediction noise | Yes | |
| 68 | + * | `com_offset_prediction_noise_var` | `double` | covariance of center of mass offset prediction noise | Yes | |
| 69 | + */ |
| 70 | + bool initialize(std::weak_ptr<const ParametersHandler::IParametersHandler> handler) override; |
| 71 | + |
| 72 | + /** |
| 73 | + * @note: This estimator will not modify the state of the KinDyn. |
| 74 | + * Assumes that the kindyn state is set externally before every advance() call of this method |
| 75 | + */ |
| 76 | + bool setKinDynObject(std::shared_ptr<iDynTree::KinDynComputations> kinDyn); |
| 77 | + bool setInitialState(const CoMKFState& initialState); |
| 78 | + bool setInput(const CoMKFInput& input) override; |
| 79 | + |
| 80 | + bool setGlobalCenterOfPressure(const double& copX, const double& copY); |
| 81 | + bool setBaseLinkIMUMeasurement(Eigen::Ref<Eigen::Vector3d> acc, |
| 82 | + Eigen::Ref<Eigen::Vector3d> gyro); |
| 83 | + bool advance() override; |
| 84 | + |
| 85 | + const CoMKFState& getOutput() const override; |
| 86 | + bool isOutputValid() const override; |
| 87 | +private: |
| 88 | + class Impl; |
| 89 | + std::unique_ptr<Impl> m_pimpl; |
| 90 | +}; |
| 91 | + |
| 92 | +} // namespace Estimators |
| 93 | +} // namespace BipedalLocomotion |
| 94 | + |
| 95 | + |
| 96 | +#endif // BIPEDAL_LOCOMOTION_ESTIMATORS_CENTER_OF_MASS_KALMAN_FILTER_H |
0 commit comments