Momentum
A library for solving nonlinear optimization problems related to human body kinematics
Loading...
Searching...
No Matches
fully_differentiable_projection_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
14
15namespace momentum {
16
18
19template <typename T>
23 public:
24 static constexpr const char* kParents = "parents";
25 static constexpr const char* kOffsets = "offsets";
26 static constexpr const char* kWeights = "weights";
27 static constexpr const char* kTargets = "targets";
28 static constexpr const char* kProjections = "projections";
29
31 const momentum::Skeleton& skel,
33 T nearClip = T(1));
34
35 [[nodiscard]] std::vector<std::string> inputs() const override;
36 [[nodiscard]] Eigen::Index getInputSize(const std::string& name) const override;
37 void getInputImp(const std::string& name, Eigen::Ref<Eigen::VectorX<T>> result) const override;
38 void setInputImp(const std::string& name, Eigen::Ref<const Eigen::VectorX<T>> value) override;
39 [[nodiscard]] const char* name() const override {
40 return "ProjectionErrorFunction";
41 }
42
43 Eigen::VectorX<T> d_gradient_d_input_dot(
44 const std::string& inputName,
45 const momentum::ModelParametersT<T>& modelParams,
46 const momentum::SkeletonStateT<T>& state,
47 Eigen::Ref<const Eigen::VectorX<T>> inputVec) override;
48
49 protected:
50 template <typename JetType>
52 const momentum::ModelParametersT<T>& modelParams,
53 const momentum::SkeletonStateT<T>& skelState,
54 int parentJointIndex_cons,
55 const Eigen::Vector3<JetType>& offset_cons,
56 const JetType& weight_cons,
57 const Eigen::Matrix<JetType, 3, 4>& projection_cons,
58 const Eigen::Vector2<JetType>& target_cons,
59 Eigen::Ref<const Eigen::VectorX<T>> inputVec) const;
60
63};
64
65} // namespace momentum
FullyDifferentiableProjectionErrorFunctionT(const momentum::Skeleton &skel, const momentum::ParameterTransform &pt, T nearClip=T(1))
JetType constraintGradient_dot(const momentum::ModelParametersT< T > &modelParams, const momentum::SkeletonStateT< T > &skelState, int parentJointIndex_cons, const Eigen::Vector3< JetType > &offset_cons, const JetType &weight_cons, const Eigen::Matrix< JetType, 3, 4 > &projection_cons, const Eigen::Vector2< JetType > &target_cons, Eigen::Ref< const Eigen::VectorX< T > > inputVec) const
void getInputImp(const std::string &name, Eigen::Ref< Eigen::VectorX< T > > result) const override
void setInputImp(const std::string &name, Eigen::Ref< const Eigen::VectorX< T > > value) override
Eigen::VectorX< T > d_gradient_d_input_dot(const std::string &inputName, const momentum::ModelParametersT< T > &modelParams, const momentum::SkeletonStateT< T > &state, Eigen::Ref< const Eigen::VectorX< T > > inputVec) override
#define MOMENTUM_FWD_DECLARE_TEMPLATE_CLASS(x)
Forward-declare a single-template-parameter class x#T and define float/double instantiation aliases p...
Definition memory.h:68
SkeletonT< float > Skeleton
Definition fwd.h:263
ParameterTransformT< float > ParameterTransform
Definition fwd.h:244
FullyDifferentiableProjectionErrorFunctionT< float > FullyDifferentiableProjectionErrorFunction
Definition fwd.h:273
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.