Momentum
A library for solving nonlinear optimization problems related to human body kinematics
Loading...
Searching...
No Matches
velocity_magnitude_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
20template <typename T>
21inline constexpr T kVelocityMagnitudeEpsilon = T(1e-6);
22
43template <typename T>
45 public:
48
49 [[nodiscard]] size_t numFrames() const final {
50 return 2;
51 }
52
53 [[nodiscard]] double getError(
54 std::span<const ModelParametersT<T>> modelParameters,
55 std::span<const SkeletonStateT<T>> skelStates,
56 std::span<const MeshStateT<T>> meshStates) const final;
57
58 [[nodiscard]] double getGradient(
59 std::span<const ModelParametersT<T>> modelParameters,
60 std::span<const SkeletonStateT<T>> skelStates,
61 std::span<const MeshStateT<T>> meshStates,
62 Eigen::Ref<Eigen::VectorX<T>> gradient) const final;
63
65 std::span<const ModelParametersT<T>> modelParameters,
66 std::span<const SkeletonStateT<T>> skelStates,
67 std::span<const MeshStateT<T>> meshStates,
68 Eigen::Ref<Eigen::MatrixX<T>> jacobian,
69 Eigen::Ref<Eigen::VectorX<T>> residual,
70 int& usedRows) const final;
71
72 [[nodiscard]] size_t getJacobianSize() const final;
73
76 void setTargetWeights(const Eigen::VectorX<T>& weights);
77
80 void setTargetSpeed(T speed);
81
84 void setTargetSpeeds(const Eigen::VectorX<T>& speeds);
85
87 void reset();
88
89 [[nodiscard]] const Eigen::VectorX<T>& getTargetWeights() const {
90 return targetWeights_;
91 }
92
93 [[nodiscard]] const Eigen::VectorX<T>& getTargetSpeeds() const {
94 return targetSpeeds_;
95 }
96
97 private:
98 Eigen::VectorX<T> targetWeights_;
99 Eigen::VectorX<T> targetSpeeds_;
100};
101
102} // namespace momentum
SequenceErrorFunctionT(const Skeleton &skel, const ParameterTransform &pt)
double getError(std::span< const ModelParametersT< T > > modelParameters, std::span< const SkeletonStateT< T > > skelStates, std::span< const MeshStateT< T > > meshStates) const final
VelocityMagnitudeSequenceErrorFunctionT(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 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
void setTargetWeights(const Eigen::VectorX< float > &weights)
void setTargetSpeeds(const Eigen::VectorX< float > &speeds)
Definition types.h:28
SkeletonT< float > Skeleton
Definition fwd.h:263
ParameterTransformT< float > ParameterTransform
Definition fwd.h:244
constexpr T kVelocityMagnitudeEpsilon
Epsilon for smooth velocity magnitude approximation: ||v||_smooth = sqrt(||v||^2 + eps^2).
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.