Momentum
A library for solving nonlinear optimization problems related to human body kinematics
Loading...
Searching...
No Matches
model_parameters_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
14namespace momentum {
15
16template <typename T>
18 public:
21
22 [[nodiscard]] size_t numFrames() const final {
23 return 2;
24 }
25
26 double getError(
27 std::span<const ModelParametersT<T>> modelParameters,
28 std::span<const SkeletonStateT<T>> skelStates,
29 std::span<const MeshStateT<T>> meshStates) const final;
31 std::span<const ModelParametersT<T>> modelParameters,
32 std::span<const SkeletonStateT<T>> skelStates,
33 std::span<const MeshStateT<T>> meshStates,
34 Eigen::Ref<Eigen::VectorX<T>> gradient) const final;
35
36 // modelParameters: [numFrames() * parameterTransform] parameter vector
37 // skelStates: [numFrames()] array of skeleton states
38 // jacobian: [getJacobianSize()] x [numFrames() * parameterTransform] Jacobian matrix
39 // residual: [getJacobianSize()] residual vector.
41 std::span<const ModelParametersT<T>> modelParameters,
42 std::span<const SkeletonStateT<T>> skelStates,
43 std::span<const MeshStateT<T>> meshStates,
44 Eigen::Ref<Eigen::MatrixX<T>> jacobian,
45 Eigen::Ref<Eigen::VectorX<T>> residual,
46 int& usedRows) const final;
47
48 [[nodiscard]] size_t getJacobianSize() const final;
49
50 void setTargetWeights(const Eigen::VectorX<T>& weights) {
51 this->targetWeights_ = weights;
52 }
53
54 [[nodiscard]] const Eigen::VectorX<T>& getTargetWeights() const {
55 return this->targetWeights_;
56 }
57
58 private:
59 Eigen::VectorX<T> targetWeights_;
60
61 public:
62 static constexpr T kMotionWeight = 1e-1;
63};
64
65} // namespace momentum
ModelParametersSequenceErrorFunctionT(const Skeleton &skel, const ParameterTransform &pt)
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
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
SequenceErrorFunctionT(const Skeleton &skel, const ParameterTransform &pt)
Definition types.h:28
SkeletonT< float > Skeleton
Definition fwd.h:263
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
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.