|
Momentum
A library for solving nonlinear optimization problems related to human body kinematics
|
Error function that penalizes deviation from a target position expressed in a reference joint's coordinate frame. More...
#include <joint_to_joint_position_error_function.h>
Public Member Functions | |
| JointToJointPositionErrorFunctionT (const Skeleton &skel, const ParameterTransform &pt) | |
| JointToJointPositionErrorFunctionT (const Character &character) | |
| 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, Ref< VectorX< T > > gradient) override |
| double | getJacobian (const ModelParametersT< T > ¶ms, const SkeletonStateT< T > &state, const MeshStateT< T > &meshState, Ref< MatrixX< T > > jacobian, Ref< VectorX< T > > residual, int &usedRows) override |
| size_t | getJacobianSize () const final |
| void | addConstraint (size_t sourceJoint, const Vector3< T > &sourceOffset, size_t referenceJoint, const Vector3< T > &referenceOffset, const Vector3< T > &target, T weight=T(1), const std::string &name={}) |
| Add a joint-to-joint position constraint. | |
| void | addConstraint (const JointToJointPositionDataT< T > &constraint) |
| Add a constraint using the JointToJointPositionDataT struct. | |
| void | clearConstraints () |
| Clear all constraints. | |
| const std::vector< JointToJointPositionDataT< T > > & | getConstraints () const |
| Get all 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 double | getGradient (const ModelParametersT< T > &, const SkeletonStateT< T > &, const MeshStateT< T > &, Eigen::Ref< Eigen::VectorX< T > >) |
| virtual double | getJacobian (const ModelParametersT< T > &, const SkeletonStateT< T > &, const MeshStateT< T > &, Eigen::Ref< Eigen::MatrixX< T > >, Eigen::Ref< Eigen::VectorX< T > >, int &usedRows) |
| 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 penalizes deviation from a target position expressed in a reference joint's coordinate frame.
This is useful for constraints where you want to control the relative position between two body parts, such as keeping a hand at a specific position relative to the body, or maintaining a specific relationship between two joints that should move together.
The error is computed as: error = T_ref^{-1} * (T_src * src_offset) - target
where T_ref and T_src are the global transformations of the reference and source joints respectively.
| T | Scalar type (float or double) |
Definition at line 74 of file joint_to_joint_position_error_function.h.
|
explicit |
Definition at line 20 of file joint_to_joint_position_error_function.cpp.
References momentum::SkeletonErrorFunctionT< T >::SkeletonErrorFunctionT().
Referenced by JointToJointPositionErrorFunctionT().
|
explicit |
Definition at line 26 of file joint_to_joint_position_error_function.cpp.
References JointToJointPositionErrorFunctionT().
| void momentum::JointToJointPositionErrorFunctionT< T >::addConstraint | ( | const JointToJointPositionDataT< T > & | constraint | ) |
Add a constraint using the JointToJointPositionDataT struct.
Definition at line 58 of file joint_to_joint_position_error_function.cpp.
References MT_CHECK, momentum::JointToJointPositionDataT< T >::referenceJoint, and momentum::JointToJointPositionDataT< T >::sourceJoint.
| void momentum::JointToJointPositionErrorFunctionT< T >::addConstraint | ( | size_t | sourceJoint, |
| const Vector3< T > & | sourceOffset, | ||
| size_t | referenceJoint, | ||
| const Vector3< T > & | referenceOffset, | ||
| const Vector3< T > & | target, | ||
| T | weight = T(1), | ||
| const std::string & | name = {} ) |
Add a joint-to-joint position constraint.
| [in] | sourceJoint | Index of the source joint. |
| [in] | sourceOffset | Offset from sourceJoint in local coordinates. |
| [in] | referenceJoint | Index of the reference joint. |
| [in] | referenceOffset | Offset from referenceJoint in local coordinates. |
| [in] | target | Target position in the reference joint's coordinate frame. |
| [in] | weight | Weight for this constraint. |
| [in] | name | Name of the constraint (for debugging). |
Definition at line 31 of file joint_to_joint_position_error_function.cpp.
References MT_CHECK, momentum::JointToJointPositionDataT< T >::name, momentum::JointToJointPositionDataT< T >::referenceJoint, momentum::JointToJointPositionDataT< T >::referenceOffset, momentum::SkeletonErrorFunctionT< T >::skeleton_, momentum::JointToJointPositionDataT< T >::sourceJoint, momentum::JointToJointPositionDataT< T >::sourceOffset, momentum::JointToJointPositionDataT< T >::target, and momentum::JointToJointPositionDataT< T >::weight.
| void momentum::JointToJointPositionErrorFunctionT< T >::clearConstraints | ( | ) |
Clear all constraints.
Definition at line 72 of file joint_to_joint_position_error_function.cpp.
|
inlinenodiscard |
Get all constraints.
Definition at line 126 of file joint_to_joint_position_error_function.h.
|
nodiscardfinalvirtual |
Reimplemented from momentum::SkeletonErrorFunctionT< T >.
Definition at line 77 of file joint_to_joint_position_error_function.cpp.
References momentum::SkeletonStateT< T >::jointState, and momentum::SkeletonErrorFunctionT< T >::weight_.
|
override |
Definition at line 110 of file joint_to_joint_position_error_function.cpp.
References momentum::SkeletonErrorFunctionT< T >::activeJointParams_, momentum::SkeletonStateT< T >::jointState, momentum::kInvalidIndex, momentum::kParametersPerJoint, MT_PROFILE_FUNCTION, momentum::SkeletonErrorFunctionT< T >::parameterTransform_, momentum::SkeletonErrorFunctionT< T >::skeleton_, and momentum::SkeletonErrorFunctionT< T >::weight_.
|
override |
Definition at line 285 of file joint_to_joint_position_error_function.cpp.
References momentum::SkeletonErrorFunctionT< T >::activeJointParams_, momentum::SkeletonStateT< T >::jointState, momentum::kInvalidIndex, momentum::kParametersPerJoint, MT_CHECK, MT_PROFILE_FUNCTION, momentum::SkeletonErrorFunctionT< T >::parameterTransform_, momentum::SkeletonErrorFunctionT< T >::skeleton_, and momentum::SkeletonErrorFunctionT< T >::weight_.
|
nodiscardfinalvirtual |
Reimplemented from momentum::SkeletonErrorFunctionT< T >.
Definition at line 497 of file joint_to_joint_position_error_function.cpp.
|
inlinenodiscard |
Returns the number of constraints.
Definition at line 131 of file joint_to_joint_position_error_function.h.