Momentum
A library for solving nonlinear optimization problems related to human body kinematics
Loading...
Searching...
No Matches
momentum::CenterOfMassConstraintT< T > Struct Template Reference

Constraint data for a center of mass target. More...

#include <center_of_mass_error_function.h>

Public Member Functions

T totalMass () const
 Returns the total mass (sum of all masses).

Public Attributes

std::vector< size_t > jointIndices
 Indices of joints contributing to this CoM constraint.
std::vector< T > masses
 Mass values for each joint (must match jointIndices size).
std::vector< Eigen::Vector3< T > > offsets
 Optional local center-of-mass offsets for each joint.
Eigen::Vector3< T > target = Eigen::Vector3<T>::Zero()
 Target position for the center of mass.
bool projectToPlane = false
 If true, project the computed center of mass to projectionNormal dot x - projectionD = 0 before comparing it to target.
Eigen::Vector3< T > projectionNormal = Eigen::Vector3<T>::UnitY()
 Normal for the optional projection plane.
T projectionD = T(0)
 Offset for the optional projection plane in the equation normal dot x - d = 0.
T weight = T(1)
 Weight of this constraint.
std::string name
 Optional name for debugging.

Detailed Description

template<typename T>
struct momentum::CenterOfMassConstraintT< T >

Constraint data for a center of mass target.

Represents a target position for the center of mass (CoM) computed from a weighted sum of joint positions. Each constraint can specify a different set of joints and masses to allow for partial body CoM computation.

Example

constraint.jointIndices = {0, 1, 2, 3}; // Spine joints
constraint.masses = {1.0f, 2.0f, 1.5f, 1.0f};
constraint.offsets = {
Eigen::Vector3f::Zero(),
Eigen::Vector3f(0.0f, 2.0f, 0.0f),
Eigen::Vector3f(0.0f, 1.5f, 0.0f),
Eigen::Vector3f::Zero()};
constraint.target = Eigen::Vector3f(0, 1.0f, 0); // Target CoM position
constraint.weight = 1.0f;
Constraint data for a center of mass target.
Eigen::Vector3< T > target
Target position for the center of mass.
std::vector< Eigen::Vector3< T > > offsets
Optional local center-of-mass offsets for each joint.
std::vector< T > masses
Mass values for each joint (must match jointIndices size).
std::vector< size_t > jointIndices
Indices of joints contributing to this CoM constraint.

Definition at line 41 of file center_of_mass_error_function.h.

Member Function Documentation

◆ totalMass()

template<typename T>
T momentum::CenterOfMassConstraintT< T >::totalMass ( ) const
nodiscard

Returns the total mass (sum of all masses).

Definition at line 85 of file center_of_mass_error_function.cpp.

References masses.

Referenced by momentum::CenterOfMassErrorFunctionT< T >::addConstraint().

Member Data Documentation

◆ jointIndices

template<typename T>
std::vector<size_t> momentum::CenterOfMassConstraintT< T >::jointIndices

Indices of joints contributing to this CoM constraint.

Definition at line 43 of file center_of_mass_error_function.h.

Referenced by momentum::CenterOfMassErrorFunctionT< T >::addConstraint().

◆ masses

template<typename T>
std::vector<T> momentum::CenterOfMassConstraintT< T >::masses

Mass values for each joint (must match jointIndices size).

Definition at line 46 of file center_of_mass_error_function.h.

Referenced by momentum::CenterOfMassErrorFunctionT< T >::addConstraint(), and totalMass().

◆ name

template<typename T>
std::string momentum::CenterOfMassConstraintT< T >::name

Optional name for debugging.

Definition at line 74 of file center_of_mass_error_function.h.

◆ offsets

template<typename T>
std::vector<Eigen::Vector3<T> > momentum::CenterOfMassConstraintT< T >::offsets

Optional local center-of-mass offsets for each joint.

If empty, all masses are treated as located at their joint origins. If present, this must match jointIndices size and each joint-local offset is transformed by the corresponding joint state before computing the weighted center of mass.

Definition at line 53 of file center_of_mass_error_function.h.

Referenced by momentum::CenterOfMassErrorFunctionT< T >::addConstraint().

◆ projectionD

template<typename T>
T momentum::CenterOfMassConstraintT< T >::projectionD = T(0)

Offset for the optional projection plane in the equation normal dot x - d = 0.

Definition at line 68 of file center_of_mass_error_function.h.

Referenced by momentum::CenterOfMassErrorFunctionT< T >::addConstraint().

◆ projectionNormal

template<typename T>
Eigen::Vector3<T> momentum::CenterOfMassConstraintT< T >::projectionNormal = Eigen::Vector3<T>::UnitY()

Normal for the optional projection plane.

Definition at line 65 of file center_of_mass_error_function.h.

Referenced by momentum::CenterOfMassErrorFunctionT< T >::addConstraint().

◆ projectToPlane

template<typename T>
bool momentum::CenterOfMassConstraintT< T >::projectToPlane = false

If true, project the computed center of mass to projectionNormal dot x - projectionD = 0 before comparing it to target.

The target is expected to already lie on the same projection plane.

Definition at line 62 of file center_of_mass_error_function.h.

Referenced by momentum::CenterOfMassErrorFunctionT< T >::addConstraint().

◆ target

template<typename T>
Eigen::Vector3<T> momentum::CenterOfMassConstraintT< T >::target = Eigen::Vector3<T>::Zero()

Target position for the center of mass.

Definition at line 56 of file center_of_mass_error_function.h.

◆ weight

template<typename T>
T momentum::CenterOfMassConstraintT< T >::weight = T(1)

Weight of this constraint.

Definition at line 71 of file center_of_mass_error_function.h.


The documentation for this struct was generated from the following files: