Momentum
A library for solving nonlinear optimization problems related to human body kinematics
Loading...
Searching...
No Matches
joint_to_joint_sequence_error_function.h
Go to the documentation of this file.
1/*
2 * Copyright (c) Meta Platforms, Inc. and affiliates.
3 *
4 * This source code is licensed under the MIT license found in the
5 * LICENSE file in the root directory of this source tree.
6 */
7
8#pragma once
9
13#include <momentum/math/types.h>
14
15#include <Eigen/Core>
16#include <Eigen/Geometry>
17
18namespace momentum {
19
24template <typename T>
28
31
33 T weight = T(1);
34
36 std::string name = {};
37};
38
56template <typename T>
58 public:
61
62 [[nodiscard]] size_t numFrames() const final {
63 return 2;
64 }
65
66 double getError(
67 std::span<const ModelParametersT<T>> modelParameters,
68 std::span<const SkeletonStateT<T>> skelStates,
69 std::span<const MeshStateT<T>> meshStates) const final;
70
72 std::span<const ModelParametersT<T>> modelParameters,
73 std::span<const SkeletonStateT<T>> skelStates,
74 std::span<const MeshStateT<T>> meshStates,
75 Eigen::Ref<Eigen::VectorX<T>> gradient) const final;
76
78 std::span<const ModelParametersT<T>> modelParameters,
79 std::span<const SkeletonStateT<T>> skelStates,
80 std::span<const MeshStateT<T>> meshStates,
81 Eigen::Ref<Eigen::MatrixX<T>> jacobian,
82 Eigen::Ref<Eigen::VectorX<T>> residual,
83 int& usedRows) const final;
84
85 [[nodiscard]] size_t getJacobianSize() const final;
86
89
92 size_t sourceJoint,
93 size_t referenceJoint,
94 T weight = T(1),
95 const std::string& name = {});
96
99
101 [[nodiscard]] const std::vector<JointToJointSequenceConstraintT<T>>& getConstraints() const {
102 return constraints_;
103 }
104
106 [[nodiscard]] size_t getNumConstraints() const {
107 return constraints_.size();
108 }
109
111 posWgt_ = w;
112 }
114 rotWgt_ = w;
115 }
116
117 [[nodiscard]] T getPositionWeight() const {
118 return posWgt_;
119 }
120 [[nodiscard]] T getOrientationWeight() const {
121 return rotWgt_;
122 }
123
124 private:
125 std::vector<JointToJointSequenceConstraintT<T>> constraints_;
126 T posWgt_ = T(1);
127 T rotWgt_ = T(1);
128};
129
130} // namespace momentum
double getError(std::span< const ModelParametersT< T > > modelParameters, std::span< const SkeletonStateT< T > > skelStates, std::span< const MeshStateT< T > > meshStates) const final
double getGradient(std::span< const ModelParametersT< T > > modelParameters, std::span< const SkeletonStateT< T > > skelStates, std::span< const MeshStateT< T > > meshStates, Eigen::Ref< Eigen::VectorX< T > > gradient) const final
double getJacobian(std::span< const ModelParametersT< T > > modelParameters, std::span< const SkeletonStateT< T > > skelStates, std::span< const MeshStateT< T > > meshStates, Eigen::Ref< Eigen::MatrixX< T > > jacobian, Eigen::Ref< Eigen::VectorX< T > > residual, int &usedRows) const final
size_t getNumConstraints() const
Returns the number of constraints.
const std::vector< JointToJointSequenceConstraintT< T > > & getConstraints() const
Get all constraints.
JointToJointSequenceErrorFunctionT(const Skeleton &skel, const ParameterTransform &pt)
void addConstraint(const JointToJointSequenceConstraintT< float > &constraint)
SequenceErrorFunctionT(const Skeleton &skel, const ParameterTransform &pt)
SkeletonT< float > Skeleton
Definition fwd.h:263
ParameterTransformT< float > ParameterTransform
Definition fwd.h:244
constexpr size_t kInvalidIndex
Sentinel value indicating an invalid or unset size_t index.
Definition types.h:182
A character model with skeletal structure, mesh, and optional components.
Definition character.h:32
Constraint data for the joint-to-joint sequence error function.
Represents the complete state of a model's mesh.
Definition mesh_state.h:24
A vector of size numModelParams holding the values of all model parameters for a character.
Definition types.h:99
Represents the complete state of a skeleton.