Momentum
A library for solving nonlinear optimization problems related to human body kinematics
Loading...
Searching...
No Matches
fully_differentiable_pose_prior_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
14
15#include <Eigen/Core>
16
17namespace momentum {
18
19template <typename T>
22 public PosePriorErrorFunctionT<T> {
23 public:
25 const Skeleton& skel,
26 const ParameterTransform& pt,
27 std::vector<std::string> names);
30 default;
37
39 const VectorX<T>& pi,
40 const MatrixX<T>& mmu,
41 const std::vector<MatrixX<T>>& W,
42 const VectorX<T>& sigma);
43
44 static constexpr const char* kPi = "pi";
45 static constexpr const char* kMu = "mu";
46 static constexpr const char* kW = "W";
47 static constexpr const char* kSigma = "sigma";
48 static constexpr const char* kParameterIndices = "parameter_indices";
49
50 [[nodiscard]] std::vector<std::string> inputs() const final;
51 [[nodiscard]] Eigen::Index getInputSize(const std::string& name) const final;
52 [[nodiscard]] const char* name() const final {
53 return "MarkerErrorFunction";
54 }
55
56 Eigen::VectorX<T> d_gradient_d_input_dot(
57 const std::string& inputName,
58 const ModelParametersT<T>& params,
59 const SkeletonStateT<T>& state,
60 Eigen::Ref<const Eigen::VectorX<T>> inputVec) final;
61
62 protected:
63 void getInputImp(const std::string& name, Eigen::Ref<Eigen::VectorX<T>> value) const final;
64 void setInputImp(const std::string& name, Eigen::Ref<const Eigen::VectorX<T>> value) final;
65
66 // pi_ are the mixture weights
67 Eigen::VectorX<T> pi_;
68
69 // The columns of mu are the means for the different mixtures
70 Eigen::MatrixX<T> mmu_;
71
72 // Each matrix W is the basis for a mixture:
73 std::vector<Eigen::MatrixX<T>> W_;
74
75 // The covariance matrix is (sigma^2 * I + W^T * W)^{-1}
76 // Note that this is sigma, not sigma squared, because the scaling should
77 // be more reasonable (sigma is the same order of magnitude as the mu and
78 // W arrays).
79 Eigen::VectorX<T> sigma_;
80
81 const std::vector<std::string> names_;
82};
83
84} // namespace momentum
std::vector< std::string > inputs() const final
void setPosePrior(const VectorX< float > &pi, const MatrixX< float > &mmu, const std::vector< MatrixX< float > > &W, const VectorX< float > &sigma)
FullyDifferentiablePosePriorErrorFunctionT(FullyDifferentiablePosePriorErrorFunctionT &&) noexcept=default
Eigen::Index getInputSize(const std::string &name) const final
void getInputImp(const std::string &name, Eigen::Ref< Eigen::VectorX< T > > value) const final
void setInputImp(const std::string &name, Eigen::Ref< const Eigen::VectorX< T > > value) final
Eigen::VectorX< T > d_gradient_d_input_dot(const std::string &inputName, const ModelParametersT< T > &params, const SkeletonStateT< T > &state, Eigen::Ref< const Eigen::VectorX< T > > inputVec) final
FullyDifferentiablePosePriorErrorFunctionT(const FullyDifferentiablePosePriorErrorFunctionT &)=default
FullyDifferentiablePosePriorErrorFunctionT(const Skeleton &skel, const ParameterTransform &pt, std::vector< std::string > names)
PosePriorErrorFunctionT(const Skeleton &skel, const ParameterTransform &pt, std::shared_ptr< const MppcaT< T > > pp)
Definition types.h:28
SkeletonT< float > Skeleton
Definition fwd.h:263
ParameterTransformT< float > ParameterTransform
Definition fwd.h:244
Eigen::Matrix< T, Dynamic, Dynamic > MatrixX
Dynamic-size, column-major dense matrix.
Definition types.h:80
Vector< T, Dynamic > VectorX
Dynamic-size column vector. Common return type for solver residuals and parameter vectors.
Definition types.h:207
constexpr T pi() noexcept
Returns the mathematical constant pi.
Definition constants.h:50
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.