|
Momentum
A library for solving nonlinear optimization problems related to human body kinematics
|
Error function that penalizes deviation from a target orientation expressed relative to a reference joint's coordinate frame. More...
#include <joint_to_joint_orientation_error_function.h>
Public Member Functions | |
| JointToJointOrientationErrorFunctionT (const Skeleton &skel, const ParameterTransform &pt) | |
| JointToJointOrientationErrorFunctionT (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, size_t referenceJoint, const Eigen::Quaternion< T > &target, T weight=T(1), const std::string &name={}) |
| Add a joint-to-joint orientation constraint. | |
| void | addConstraint (const JointToJointOrientationDataT< T > &constraint) |
| Add a constraint using the JointToJointOrientationDataT struct. | |
| void | clearConstraints () |
| Clear all constraints. | |
| const std::vector< JointToJointOrientationDataT< T > > & | getConstraints () const |
| Get all constraints. | |
| size_t | numConstraints () const |
| Get 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 orientation expressed relative to a reference joint's coordinate frame.
This is useful for constraints where you want to control the relative orientation between two body parts, such as keeping a hand at a specific orientation relative to the body, or maintaining a specific rotational relationship between two joints.
The error is computed as the Frobenius norm of the difference between the actual and target relative rotation matrices: error = ||R_ref^T * R_src - R_target||_F^2
where R_ref and R_src are the global rotations of the reference and source joints respectively, and R_target is the target relative rotation.
Definition at line 66 of file joint_to_joint_orientation_error_function.h.
|
explicit |
Definition at line 20 of file joint_to_joint_orientation_error_function.cpp.
References momentum::SkeletonErrorFunctionT< T >::SkeletonErrorFunctionT().
Referenced by JointToJointOrientationErrorFunctionT().
|
explicit |
Definition at line 26 of file joint_to_joint_orientation_error_function.cpp.
References JointToJointOrientationErrorFunctionT().
| void momentum::JointToJointOrientationErrorFunctionT< T >::addConstraint | ( | const JointToJointOrientationDataT< T > & | constraint | ) |
Add a constraint using the JointToJointOrientationDataT struct.
Definition at line 54 of file joint_to_joint_orientation_error_function.cpp.
References MT_CHECK, momentum::JointToJointOrientationDataT< T >::referenceJoint, and momentum::JointToJointOrientationDataT< T >::sourceJoint.
| void momentum::JointToJointOrientationErrorFunctionT< T >::addConstraint | ( | size_t | sourceJoint, |
| size_t | referenceJoint, | ||
| const Eigen::Quaternion< T > & | target, | ||
| T | weight = T(1), | ||
| const std::string & | name = {} ) |
Add a joint-to-joint orientation constraint.
| [in] | sourceJoint | Index of the source joint. |
| [in] | referenceJoint | Index of the reference joint. |
| [in] | target | Target relative orientation (R_ref^T * R_src should match this). |
| [in] | weight | Weight for this constraint. |
| [in] | name | Name of the constraint (for debugging). |
Definition at line 31 of file joint_to_joint_orientation_error_function.cpp.
References MT_CHECK, momentum::JointToJointOrientationDataT< T >::name, momentum::JointToJointOrientationDataT< T >::referenceJoint, momentum::SkeletonErrorFunctionT< T >::skeleton_, momentum::JointToJointOrientationDataT< T >::sourceJoint, momentum::JointToJointOrientationDataT< T >::target, and momentum::JointToJointOrientationDataT< T >::weight.
| void momentum::JointToJointOrientationErrorFunctionT< T >::clearConstraints | ( | ) |
Clear all constraints.
Definition at line 68 of file joint_to_joint_orientation_error_function.cpp.
|
inlinenodiscard |
Get all constraints.
Definition at line 116 of file joint_to_joint_orientation_error_function.h.
|
nodiscardfinalvirtual |
Reimplemented from momentum::SkeletonErrorFunctionT< T >.
Definition at line 73 of file joint_to_joint_orientation_error_function.cpp.
References momentum::SkeletonStateT< T >::jointState, and momentum::SkeletonErrorFunctionT< T >::weight_.
|
override |
Definition at line 103 of file joint_to_joint_orientation_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 209 of file joint_to_joint_orientation_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 334 of file joint_to_joint_orientation_error_function.cpp.
|
inlinenodiscard |
Get number of constraints.
Definition at line 121 of file joint_to_joint_orientation_error_function.h.