From 442173acb80381beff09c8c9cc45a43d5cb4a6a5 Mon Sep 17 00:00:00 2001 From: Ines Date: Fri, 3 Mar 2023 12:26:37 +0100 Subject: [PATCH] Change StateDynamics class in Dynamics --- src/Estimators/CMakeLists.txt | 4 +- .../{StateDynamics.h => Dynamics.h} | 42 +++++++------- .../FrictionTorqueDynamics.h | 4 +- .../JointVelocityDynamics.h | 4 +- .../RobotDynamicsEstimator/UKFModelCreator.h | 56 ------------------- .../ZeroVelocityDynamics.h | 4 +- src/Estimators/src/Dynamics.cpp | 37 ++++++++++++ src/Estimators/src/FrictionTorqueDynamics.cpp | 6 +- src/Estimators/src/JointVelocityDynamics.cpp | 2 +- src/Estimators/src/StateDynamics.cpp | 37 ------------ src/Estimators/src/UKFModelCreator.cpp | 23 -------- src/Estimators/src/ZeroVelocityDynamics.cpp | 6 +- .../FrictionTorqueDynamicsTest.cpp | 2 +- .../JointVelocityDynamicsTest.cpp | 2 +- .../ZeroVelocityDynamicsTest.cpp | 2 +- 15 files changed, 74 insertions(+), 157 deletions(-) rename src/Estimators/include/BipedalLocomotion/RobotDynamicsEstimator/{StateDynamics.h => Dynamics.h} (55%) delete mode 100644 src/Estimators/include/BipedalLocomotion/RobotDynamicsEstimator/UKFModelCreator.h create mode 100644 src/Estimators/src/Dynamics.cpp delete mode 100644 src/Estimators/src/StateDynamics.cpp delete mode 100644 src/Estimators/src/UKFModelCreator.cpp diff --git a/src/Estimators/CMakeLists.txt b/src/Estimators/CMakeLists.txt index 84a5525a47..696ca97e62 100644 --- a/src/Estimators/CMakeLists.txt +++ b/src/Estimators/CMakeLists.txt @@ -29,14 +29,14 @@ if(FRAMEWORK_COMPILE_RobotDynamicsEstimator) NAME RobotDynamicsEstimator SOURCES src/SubModel.cpp src/SubModelKinDynWrapper.cpp - src/StateDynamics.cpp + src/Dynamics.cpp src/ZeroVelocityDynamics.cpp src/FrictionTorqueDynamics.cpp src/JointVelocityDynamics.cpp SUBDIRECTORIES tests/RobotDynamicsEstimator PUBLIC_HEADERS ${H_PREFIX}/SubModel.h ${H_PREFIX}/SubModelKinDynWrapper.h - ${H_PREFIX}/StateDynamics.h + ${H_PREFIX}/Dynamics.h ${H_PREFIX}/ZeroVelocityDynamics.h ${H_PREFIX}/FrictionTorqueDynamics.h ${H_PREFIX}/JointVelocityDynamics.h diff --git a/src/Estimators/include/BipedalLocomotion/RobotDynamicsEstimator/StateDynamics.h b/src/Estimators/include/BipedalLocomotion/RobotDynamicsEstimator/Dynamics.h similarity index 55% rename from src/Estimators/include/BipedalLocomotion/RobotDynamicsEstimator/StateDynamics.h rename to src/Estimators/include/BipedalLocomotion/RobotDynamicsEstimator/Dynamics.h index ef416ea3d3..d03c26e936 100644 --- a/src/Estimators/include/BipedalLocomotion/RobotDynamicsEstimator/StateDynamics.h +++ b/src/Estimators/include/BipedalLocomotion/RobotDynamicsEstimator/Dynamics.h @@ -1,12 +1,12 @@ /** - * @file StateDynamics.h + * @file Dynamics.h * @authors Ines Sorrentino * @copyright 2023 Istituto Italiano di Tecnologia (IIT). This software may be modified and * distributed under the terms of the BSD-3-Clause license. */ -#ifndef BIPEDAL_LOCOMOTION_ESTIMATORS_STATEDYNAMICS_H -#define BIPEDAL_LOCOMOTION_ESTIMATORS_STATEDYNAMICS_H +#ifndef BIPEDAL_LOCOMOTION_ESTIMATORS_DYNAMICS_H +#define BIPEDAL_LOCOMOTION_ESTIMATORS_DYNAMICS_H #include #include @@ -24,21 +24,20 @@ namespace RobotDynamicsEstimator { /** - * StateDynamics describes a generic dynamic model for a UKF state. + * Dynamics describes a generic dynamic model for a UKF state or measurement. */ -class StateDynamics +class Dynamics { protected: - int m_size; /**< Size of the sub-state associate to the StateDynamics object. */ - Eigen::VectorXd m_updatedState; /**< Next state computed using the dynamic model. It returns the sub-state associated to the StateDynamics object. */ - std::string m_description{"Generic State Dynamics Element"}; /**< String describing the content of - the task */ - std::string m_name; /**< Name of state dynamics. */ - Eigen::VectorXd m_covariances; /**< Vector of covariances of the sub-state m_nextState. */ - std::vector m_elements = {}; /**< Elements composing the substate m_name. This parameter is optional. */ + int m_size; /**< Size of the variable associate to the Dynamics object. */ + Eigen::VectorXd m_updatedVariable; /**< Updated variable computed using the dynamic model. */ + std::string m_description{"Generic Dynamics Element"}; /**< String describing the type of the dynamics */ + std::string m_name; /**< Name of dynamics. */ + Eigen::VectorXd m_covariances; /**< Vector of covariances. */ + std::vector m_elements = {}; /**< Elements composing the variable vector. */ std::string m_dynamicModel; - bool m_isInitialized{false}; /**< True if the state dynamics has been initialized. */ - System::VariablesHandler m_variableHandler; + bool m_isInitialized{false}; /**< True if the dynamics has been initialized. */ + System::VariablesHandler m_variableHandler; /**< Variable handler describing the variables and the sizes in the ukf state/measurement vector. */ public: /** @@ -56,16 +55,16 @@ class StateDynamics virtual bool setVariableHandler(System::VariablesHandler variableHandler); /** - * Update the dynamics of the state. + * Update the dynamics of the variable. * @return True in case of success, false otherwise. */ virtual bool update(); /** - * Get the next state m_nextState. - * @return a const reference to the next state. + * Get the next value m_updatedVariable. + * @return a const reference to the next variable value. */ - Eigen::Ref getUpdatedSubState() const; + Eigen::Ref getUpdatedVariable() const; /** * Get the size of the state. @@ -83,14 +82,11 @@ class StateDynamics /** * Destructor. */ - virtual ~StateDynamics() = default; - - - // aggiungere il toString + virtual ~Dynamics() = default; }; } // RobotDynamicsEstimator } // Estimators } // BipedalLocomotion -#endif // BIPEDAL_LOCOMOTION_ESTIMATORS_STATEDYNAMICS_H +#endif // BIPEDAL_LOCOMOTION_ESTIMATORS_DYNAMICS_H diff --git a/src/Estimators/include/BipedalLocomotion/RobotDynamicsEstimator/FrictionTorqueDynamics.h b/src/Estimators/include/BipedalLocomotion/RobotDynamicsEstimator/FrictionTorqueDynamics.h index f9315eaf2c..b84dae92a6 100644 --- a/src/Estimators/include/BipedalLocomotion/RobotDynamicsEstimator/FrictionTorqueDynamics.h +++ b/src/Estimators/include/BipedalLocomotion/RobotDynamicsEstimator/FrictionTorqueDynamics.h @@ -9,7 +9,7 @@ #define BIPEDAL_LOCOMOTION_ESTIMATORS_FRICTION_TORQUE_DYNAMICS_H #include -#include +#include namespace BipedalLocomotion { @@ -35,7 +35,7 @@ namespace RobotDynamicsEstimator * \f] */ -class FrictionTorqueDynamics : public StateDynamics +class FrictionTorqueDynamics : public Dynamics { Eigen::VectorXd m_jointVelocity; /**< Vector of joint velocities. */ Eigen::VectorXd m_currentFrictionTorque; /**< Vector of friction torques. */ diff --git a/src/Estimators/include/BipedalLocomotion/RobotDynamicsEstimator/JointVelocityDynamics.h b/src/Estimators/include/BipedalLocomotion/RobotDynamicsEstimator/JointVelocityDynamics.h index fd3f6547b0..faba9c24cd 100644 --- a/src/Estimators/include/BipedalLocomotion/RobotDynamicsEstimator/JointVelocityDynamics.h +++ b/src/Estimators/include/BipedalLocomotion/RobotDynamicsEstimator/JointVelocityDynamics.h @@ -12,7 +12,7 @@ #include #include -#include +#include #include #include @@ -33,7 +33,7 @@ namespace RobotDynamicsEstimator * \f] */ -class JointVelocityDynamics : public StateDynamics +class JointVelocityDynamics : public Dynamics { std::shared_ptr m_kinDynWrapper; /**< object containing the kinematics and dynamics properties of a sub-model. */ SubModel m_subModel; /**< Sub-model object storing information about the model (joints, sensors, applied wrenches) */ diff --git a/src/Estimators/include/BipedalLocomotion/RobotDynamicsEstimator/UKFModelCreator.h b/src/Estimators/include/BipedalLocomotion/RobotDynamicsEstimator/UKFModelCreator.h deleted file mode 100644 index cbeb524e12..0000000000 --- a/src/Estimators/include/BipedalLocomotion/RobotDynamicsEstimator/UKFModelCreator.h +++ /dev/null @@ -1,56 +0,0 @@ -/** - * @file UKFModelCreator.h - * @authors Ines Sorrentino - * @copyright 2023 Istituto Italiano di Tecnologia (IIT). This software may be modified and - * distributed under the terms of the BSD-3-Clause license. - */ - -#ifndef BIPEDAL_LOCOMOTION_ESTIMATORS_UKFMODELCREATOR_H -#define BIPEDAL_LOCOMOTION_ESTIMATORS_UKFMODELCREATOR_H - -#include -#include - -#include - -// BayesFilters -#include -#include - -// BLF -#include -#include -#include -#include - -namespace BipedalLocomotion -{ -namespace Estimators -{ -namespace RobotDynamicsEstimator -{ - -class UKFModelCreator -{ -ParametersHandler::IParametersHandler::shared_ptr stateHandler; -ParametersHandler::IParametersHandler::shared_ptr measurementHandler; - -public: - // Initialize deve costruire il modello dello stato. - // Quindi deve creare un variableHandler e settarlo a UKFProcessModel - // creare la lista di oggetti StateDynamics e settarla a UKFProcessModel - // creare la matrice di covarianze e settarla a UKFProcessModel - bool buildStateModel(std::weak_ptr stateHandler, - std::vector stochasticDynamicsLsit, - BipedalLocomotion::System::VariablesHandler & variableHandler); - - - -}; // class UKFModelCreator - - -} // namespace RobotDynamicsEstimator -} // namespace Estimators -} // namespace BipedalLocomotion - -#endif // BIPEDAL_LOCOMOTION_ESTIMATORS_UKFMODELCREATOR_H diff --git a/src/Estimators/include/BipedalLocomotion/RobotDynamicsEstimator/ZeroVelocityDynamics.h b/src/Estimators/include/BipedalLocomotion/RobotDynamicsEstimator/ZeroVelocityDynamics.h index eec44fd104..d21bcdd921 100644 --- a/src/Estimators/include/BipedalLocomotion/RobotDynamicsEstimator/ZeroVelocityDynamics.h +++ b/src/Estimators/include/BipedalLocomotion/RobotDynamicsEstimator/ZeroVelocityDynamics.h @@ -9,7 +9,7 @@ #define BIPEDAL_LOCOMOTION_ESTIMATORS_ZERO_VELOCITY_DYNAMICS_H #include -#include +#include namespace BipedalLocomotion { @@ -31,7 +31,7 @@ namespace RobotDynamicsEstimator * \f] */ -class ZeroVelocityDynamics : public StateDynamics +class ZeroVelocityDynamics : public Dynamics { Eigen::VectorXd m_currentState; /**< Current state. */ diff --git a/src/Estimators/src/Dynamics.cpp b/src/Estimators/src/Dynamics.cpp new file mode 100644 index 0000000000..b2d58a9c1e --- /dev/null +++ b/src/Estimators/src/Dynamics.cpp @@ -0,0 +1,37 @@ +/** + * @file Dynamics.cpp + * @authors Ines Sorrentino + * @copyright 2023 Istituto Italiano di Tecnologia (IIT). This software may be modified and + * distributed under the terms of the BSD-3-Clause license. + */ + +#include + +namespace RDE = BipedalLocomotion::Estimators::RobotDynamicsEstimator; +using namespace BipedalLocomotion::System; +using namespace BipedalLocomotion::ParametersHandler; + +bool RDE::Dynamics::initialize(std::weak_ptr paramHandler) +{ + return true; +} + +bool RDE::Dynamics::update() +{ + return true; +} + +Eigen::Ref RDE::Dynamics::getUpdatedVariable() const +{ + return m_updatedVariable; +} + +int RDE::Dynamics::size() const +{ + return m_size; +} + +bool RDE::Dynamics::setVariableHandler(System::VariablesHandler variableHandler) +{ + return true; +} diff --git a/src/Estimators/src/FrictionTorqueDynamics.cpp b/src/Estimators/src/FrictionTorqueDynamics.cpp index e208d6c053..5101fde32e 100644 --- a/src/Estimators/src/FrictionTorqueDynamics.cpp +++ b/src/Estimators/src/FrictionTorqueDynamics.cpp @@ -83,8 +83,8 @@ bool RDE::FrictionTorqueDynamics::initialize(std::weak_ptr - -namespace RDE = BipedalLocomotion::Estimators::RobotDynamicsEstimator; -using namespace BipedalLocomotion::System; -using namespace BipedalLocomotion::ParametersHandler; - -bool RDE::StateDynamics::initialize(std::weak_ptr paramHandler) -{ - return true; -} - -bool RDE::StateDynamics::update() -{ - return true; -} - -Eigen::Ref RDE::StateDynamics::getUpdatedSubState() const -{ - return m_updatedState; -} - -int RDE::StateDynamics::size() const -{ - return m_size; -} - -bool RDE::StateDynamics::setVariableHandler(System::VariablesHandler variableHandler) -{ - return true; -} diff --git a/src/Estimators/src/UKFModelCreator.cpp b/src/Estimators/src/UKFModelCreator.cpp deleted file mode 100644 index a42078dc64..0000000000 --- a/src/Estimators/src/UKFModelCreator.cpp +++ /dev/null @@ -1,23 +0,0 @@ -/** - * @file UKFModelCreator.h - * @authors Ines Sorrentino - * @copyright 2023 Istituto Italiano di Tecnologia (IIT). This software may be modified and - * distributed under the terms of the BSD-3-Clause license. - */ - -#include - -namespace RDE = BipedalLocomotion::Estimators::RobotDynamicsEstimator; - -void RDE::UKFStateModel::setJointStateProvider(std::shared_ptr jointPositions) -{ - m_jointPosition = jointPositions; -} - -//bool RDE::UKFModelCreator::makeUKFStateModel(BipedalLocomotion::System::VariablesHandler & stateHandler, -// RDE::UKFStateModel && stateModel) -//{ - - -// return true; -//} diff --git a/src/Estimators/src/ZeroVelocityDynamics.cpp b/src/Estimators/src/ZeroVelocityDynamics.cpp index 37417d29f3..8afff9de58 100644 --- a/src/Estimators/src/ZeroVelocityDynamics.cpp +++ b/src/Estimators/src/ZeroVelocityDynamics.cpp @@ -56,8 +56,8 @@ bool RDE::ZeroVelocityDynamics::initialize(std::weak_ptr