Momentum
A library for solving nonlinear optimization problems related to human body kinematics
Loading...
Searching...
No Matches
model_parameters_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
14namespace momentum {
15
16template <typename T>
18 public:
20 explicit ModelParametersErrorFunctionT(const Character& character);
21
22 // Create a ModelParametersError that only targets the specified parameters:
23 ModelParametersErrorFunctionT(const Character& character, const ParameterSet& active);
24
25 [[nodiscard]] double getError(
26 const ModelParametersT<T>& parameters,
27 const SkeletonStateT<T>& state,
28 const MeshStateT<T>& meshState) final;
30 const ModelParametersT<T>& parameters,
31 const SkeletonStateT<T>& state,
32 const MeshStateT<T>& meshState,
33 Ref<Eigen::VectorX<T>> gradient) final;
35 const ModelParametersT<T>& parameters,
36 const SkeletonStateT<T>& state,
37 const MeshStateT<T>& meshState,
38 Ref<Eigen::MatrixX<T>> jacobian,
39 Ref<Eigen::VectorX<T>> residual,
40 int& usedRows) final;
41 [[nodiscard]] size_t getJacobianSize() const final;
42
43 void setTargetParameters(const ModelParametersT<T>& params, const Eigen::VectorX<T>& weights) {
44 this->targetParameters_ = params;
45 this->targetWeights_ = weights;
46 }
47
48 [[nodiscard]] const ModelParametersT<T>& getTargetParameters() const {
49 return this->targetParameters_;
50 }
51
52 [[nodiscard]] const Eigen::VectorX<T>& getTargetWeights() const {
53 return this->targetWeights_;
54 }
55
56 private:
57 ModelParametersT<T> targetParameters_;
58 Eigen::VectorX<T> targetWeights_;
59
60 public:
61 static constexpr T kMotionWeight = 1e-1;
62};
63
64} // namespace momentum
ModelParametersErrorFunctionT(const Character &character, const ParameterSet &active)
void setTargetParameters(const ModelParametersT< float > &params, const Eigen::VectorX< float > &weights)
const ModelParametersT< T > & getTargetParameters() const
double getJacobian(const ModelParametersT< T > &parameters, const SkeletonStateT< T > &state, const MeshStateT< T > &meshState, Ref< Eigen::MatrixX< T > > jacobian, Ref< Eigen::VectorX< T > > residual, int &usedRows) final
double getError(const ModelParametersT< T > &parameters, const SkeletonStateT< T > &state, const MeshStateT< T > &meshState) final
ModelParametersErrorFunctionT(const Skeleton &skel, const ParameterTransform &pt)
const Eigen::VectorX< T > & getTargetWeights() const
double getGradient(const ModelParametersT< T > &parameters, const SkeletonStateT< T > &state, const MeshStateT< T > &meshState, Ref< Eigen::VectorX< T > > gradient) final
SkeletonErrorFunctionT(const Skeleton &skel, const ParameterTransform &pt)
Definition types.h:28
SkeletonT< float > Skeleton
Definition fwd.h:263
Eigen::Ref< T > Ref
Definition types.h:43
ParameterTransformT< float > ParameterTransform
Definition fwd.h:244
Vector< T, Dynamic > VectorX
Dynamic-size column vector. Common return type for solver residuals and parameter vectors.
Definition types.h:207
std::bitset< kMaxModelParams > ParameterSet
Bitset for model parameter enablement.
Definition types.h:430
A character model with skeletal structure, mesh, and optional components.
Definition character.h:32
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.