|
Momentum
A library for solving nonlinear optimization problems related to human body kinematics
|
Error function that constrains the center of mass to a target position. More...
#include <center_of_mass_error_function.h>
Public Types | |
| using | ConstraintType = CenterOfMassConstraintT<T> |
Public Member Functions | |
| CenterOfMassErrorFunctionT (const Skeleton &skeleton, const ParameterTransform ¶meterTransform) | |
| Constructs the error function. | |
| ~CenterOfMassErrorFunctionT () override=default | |
| double | getError (const ModelParametersT< T > ¶ms, const SkeletonStateT< T > &state, const MeshStateT< T > &meshState) final |
| double | getGradient (const ModelParametersT< T > ¶ms, const SkeletonStateT< T > &state, const MeshStateT< T > &meshState, Eigen::Ref< Eigen::VectorX< T > > gradient) override |
| double | getJacobian (const ModelParametersT< T > ¶ms, const SkeletonStateT< T > &state, const MeshStateT< T > &meshState, Eigen::Ref< Eigen::MatrixX< T > > jacobian, Eigen::Ref< Eigen::VectorX< T > > residual, int &usedRows) override |
| size_t | getJacobianSize () const final |
| void | addConstraint (const ConstraintType &constraint) |
| Adds a center of mass constraint. | |
| void | setConstraints (std::span< const ConstraintType > constraints) |
| Sets all constraints, replacing any existing ones. | |
| void | clearConstraints () |
| Clears all constraints. | |
| const std::vector< ConstraintType > & | getConstraints () const |
| Returns the current constraints. | |
| size_t | getNumConstraints () const |
| Returns the number of constraints. | |
| Public Member Functions inherited from momentum::SkeletonErrorFunctionT< T > | |
| SkeletonErrorFunctionT (const Skeleton &skel, const ParameterTransform &pt) | |
| virtual | ~SkeletonErrorFunctionT ()=default |
| const Skeleton & | getSkeleton () const |
| const ParameterTransform & | getParameterTransform () const |
| virtual const Character * | getCharacter () const |
| For mesh-based error functions, get access to the underlying character. | |
| void | setWeight (T w) |
| T | getWeight () const |
| void | setActiveJoints (const VectorX< bool > &aj) |
| void | setEnabledParameters (const ParameterSet &ps) |
| virtual void | getHessian (const ModelParametersT< T > &, const SkeletonStateT< T > &, const MeshStateT< T > &, Eigen::Ref< Eigen::MatrixX< T > >) |
| virtual double | getSolverDerivatives (const ModelParametersT< T > ¶meters, const SkeletonStateT< T > &state, const MeshStateT< T > &meshState, const size_t actualParameters, Eigen::MatrixX< T > &hess, Eigen::VectorX< T > &grad) |
| virtual bool | needsMesh () const |
Additional Inherited Members | |
| Protected Attributes inherited from momentum::SkeletonErrorFunctionT< T > | |
| const Skeleton & | skeleton_ |
| const ParameterTransform & | parameterTransform_ |
| T | weight_ |
| VectorX< bool > | activeJointParams_ |
| ParameterSet | enabledParameters_ |
| bool | useHessian_ {false} |
Error function that constrains the center of mass to a target position.
The center of mass is computed as: CoM = (sum m_k * p_k) / (sum m_k)
where m_k is the mass at joint k and p_k is the world position of joint k.
The residual is: f = CoM - target or, when projection is enabled: f = project(CoM) - target where project(x) orthogonally projects x to the configured plane.
This uses SkeletonDerivativeT for efficient hierarchy walks, similar to CameraProjectionErrorFunctionT.
| T | Scalar type (float or double) |
Definition at line 111 of file center_of_mass_error_function.h.
| using momentum::CenterOfMassErrorFunctionT< T >::ConstraintType = CenterOfMassConstraintT<T> |
Definition at line 113 of file center_of_mass_error_function.h.
| momentum::CenterOfMassErrorFunctionT< T >::CenterOfMassErrorFunctionT | ( | const Skeleton & | skeleton, |
| const ParameterTransform & | parameterTransform ) |
Constructs the error function.
| skeleton | The skeleton structure |
| parameterTransform | Maps joint parameters to model parameters |
Definition at line 94 of file center_of_mass_error_function.cpp.
References momentum::SkeletonErrorFunctionT< T >::activeJointParams_, momentum::SkeletonErrorFunctionT< T >::enabledParameters_, and momentum::SkeletonErrorFunctionT< T >::SkeletonErrorFunctionT().
|
overridedefault |
| void momentum::CenterOfMassErrorFunctionT< T >::addConstraint | ( | const ConstraintType & | constraint | ) |
Adds a center of mass constraint.
| constraint | The constraint to add |
Definition at line 105 of file center_of_mass_error_function.cpp.
References momentum::CenterOfMassConstraintT< T >::jointIndices, momentum::CenterOfMassConstraintT< T >::masses, MT_CHECK, momentum::CenterOfMassConstraintT< T >::offsets, momentum::CenterOfMassConstraintT< T >::projectionD, momentum::CenterOfMassConstraintT< T >::projectionNormal, momentum::CenterOfMassConstraintT< T >::projectToPlane, momentum::SkeletonErrorFunctionT< T >::skeleton_, and momentum::CenterOfMassConstraintT< T >::totalMass().
Referenced by setConstraints().
| void momentum::CenterOfMassErrorFunctionT< T >::clearConstraints | ( | ) |
Clears all constraints.
Definition at line 146 of file center_of_mass_error_function.cpp.
|
nodiscard |
Returns the current constraints.
Definition at line 151 of file center_of_mass_error_function.cpp.
|
nodiscardfinalvirtual |
Reimplemented from momentum::SkeletonErrorFunctionT< T >.
Definition at line 162 of file center_of_mass_error_function.cpp.
References momentum::SkeletonStateT< T >::jointState, and momentum::SkeletonErrorFunctionT< T >::weight_.
|
overridevirtual |
Reimplemented from momentum::SkeletonErrorFunctionT< T >.
Definition at line 182 of file center_of_mass_error_function.cpp.
References momentum::SkeletonStateT< T >::jointState, MT_PROFILE_FUNCTION, momentum::SkeletonErrorFunctionT< T >::parameterTransform_, and momentum::SkeletonErrorFunctionT< T >::weight_.
|
overridevirtual |
Reimplemented from momentum::SkeletonErrorFunctionT< T >.
Definition at line 258 of file center_of_mass_error_function.cpp.
References momentum::SkeletonStateT< T >::jointState, MT_PROFILE_FUNCTION, and momentum::SkeletonErrorFunctionT< T >::weight_.
|
nodiscardfinalvirtual |
Reimplemented from momentum::SkeletonErrorFunctionT< T >.
Definition at line 334 of file center_of_mass_error_function.cpp.
|
nodiscard |
Returns the number of constraints.
Definition at line 157 of file center_of_mass_error_function.cpp.
| void momentum::CenterOfMassErrorFunctionT< T >::setConstraints | ( | std::span< const ConstraintType > | constraints | ) |
Sets all constraints, replacing any existing ones.
| constraints | The new list of constraints |
Definition at line 137 of file center_of_mass_error_function.cpp.
References addConstraint().