|
Momentum
A library for solving nonlinear optimization problems related to human body kinematics
|
Error function that penalizes deviation from a target distance between two points attached to different joints. More...
#include <joint_to_joint_distance_error_function.h>
Public Member Functions | |
| JointToJointDistanceErrorFunctionT (const Skeleton &skel, const ParameterTransform &pt) | |
| JointToJointDistanceErrorFunctionT (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 joint1, const Vector3< T > &offset1, size_t joint2, const Vector3< T > &offset2, T targetDistance, T weight=T(1)) |
| Add a constraint between two joints with local offsets. | |
| void | clearConstraints () |
| Clear all constraints. | |
| const std::vector< JointToJointDistanceConstraintT< 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 |
Static Public Attributes | |
| static constexpr T | kDistanceWeight = 1e-2 |
| Default weight for distance constraints. | |
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 distance between two points attached to different joints.
This is useful for enforcing distance constraints between different parts of a character, such as maintaining a fixed distance between hands or ensuring two joints stay a certain distance apart.
The residual is: f = ||p1 - p2|| - targetDistance
where p1 and p2 are the world-space positions of the two joint points.
| T | Scalar type (float or double) |
Definition at line 67 of file joint_to_joint_distance_error_function.h.
|
explicit |
Definition at line 21 of file joint_to_joint_distance_error_function.cpp.
References momentum::SkeletonErrorFunctionT< T >::SkeletonErrorFunctionT().
Referenced by JointToJointDistanceErrorFunctionT().
|
explicit |
Definition at line 27 of file joint_to_joint_distance_error_function.cpp.
References JointToJointDistanceErrorFunctionT().
| void momentum::JointToJointDistanceErrorFunctionT< T >::addConstraint | ( | size_t | joint1, |
| const Vector3< T > & | offset1, | ||
| size_t | joint2, | ||
| const Vector3< T > & | offset2, | ||
| T | targetDistance, | ||
| T | weight = T(1) ) |
Add a constraint between two joints with local offsets.
Definition at line 32 of file joint_to_joint_distance_error_function.cpp.
References MT_CHECK, and momentum::SkeletonErrorFunctionT< T >::skeleton_.
| void momentum::JointToJointDistanceErrorFunctionT< T >::clearConstraints | ( | ) |
Clear all constraints.
Definition at line 49 of file joint_to_joint_distance_error_function.cpp.
|
inlinenodiscard |
Get all constraints.
Definition at line 107 of file joint_to_joint_distance_error_function.h.
|
nodiscardfinalvirtual |
Reimplemented from momentum::SkeletonErrorFunctionT< T >.
Definition at line 54 of file joint_to_joint_distance_error_function.cpp.
References momentum::SkeletonStateT< T >::jointState, kDistanceWeight, momentum::sqr(), and momentum::SkeletonErrorFunctionT< T >::weight_.
|
override |
Definition at line 82 of file joint_to_joint_distance_error_function.cpp.
References momentum::SkeletonErrorFunctionT< T >::activeJointParams_, momentum::Eps(), momentum::SkeletonStateT< T >::jointState, kDistanceWeight, momentum::kInvalidIndex, momentum::kParametersPerJoint, momentum::SkeletonErrorFunctionT< T >::parameterTransform_, momentum::SkeletonErrorFunctionT< T >::skeleton_, momentum::sqr(), and momentum::SkeletonErrorFunctionT< T >::weight_.
|
override |
Definition at line 165 of file joint_to_joint_distance_error_function.cpp.
References momentum::SkeletonErrorFunctionT< T >::activeJointParams_, momentum::Eps(), momentum::SkeletonStateT< T >::jointState, kDistanceWeight, momentum::kInvalidIndex, momentum::kParametersPerJoint, MT_CHECK, MT_PROFILE_FUNCTION, momentum::SkeletonErrorFunctionT< T >::parameterTransform_, momentum::SkeletonErrorFunctionT< T >::skeleton_, momentum::sqr(), and momentum::SkeletonErrorFunctionT< T >::weight_.
|
nodiscardfinalvirtual |
Reimplemented from momentum::SkeletonErrorFunctionT< T >.
Definition at line 273 of file joint_to_joint_distance_error_function.cpp.
|
inlinenodiscard |
Returns the number of constraints.
Definition at line 112 of file joint_to_joint_distance_error_function.h.
|
staticconstexpr |
Default weight for distance constraints.
Definition at line 117 of file joint_to_joint_distance_error_function.h.
Referenced by getError(), getGradient(), and getJacobian().