Momentum
A library for solving nonlinear optimization problems related to human body kinematics
Loading...
Searching...
No Matches
fully_differentiable_distance_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
19
20template <typename T>
22 : public DistanceErrorFunctionT<T>,
24 public:
25 static constexpr const char* kOrigins = "origins";
26 static constexpr const char* kParents = "parents";
27 static constexpr const char* kOffsets = "offsets";
28 static constexpr const char* kWeights = "weights";
29 static constexpr const char* kTargets = "targets";
30
32 const momentum::Skeleton& skel,
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 "DistanceErrorFunction";
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 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
50
51 private:
52 // Compute dError/dModelParams^T * v for some v.
53 template <typename JetType>
54 JetType constraintGradient_dot(
55 const momentum::ModelParametersT<T>& modelParams,
56 const momentum::SkeletonStateT<T>& skelState,
57 const Eigen::Vector3<JetType>& origin_cons,
58 int parentJointIndex,
59 const Eigen::Vector3<JetType>& offset,
60 const JetType& weight_cons,
61 const JetType& target_cons,
62 Eigen::Ref<const Eigen::VectorX<T>> vec);
63
64 // weights for the error functions
67};
68
69} // namespace momentum
std::vector< DistanceConstraintDataT< float > > constraints_
DistanceErrorFunctionT(const momentum::Skeleton &skel, const momentum::ParameterTransform &pt)
void setInputImp(const std::string &name, Eigen::Ref< const Eigen::VectorX< T > > value) override
FullyDifferentiableDistanceErrorFunctionT(const momentum::Skeleton &skel, const momentum::ParameterTransform &pt)
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
void getInputImp(const std::string &name, Eigen::Ref< Eigen::VectorX< T > > result) const override
#define MOMENTUM_FWD_DECLARE_TEMPLATE_STRUCT(x)
Forward-declare a single-template-parameter struct x#T and define float/double instantiation aliases ...
Definition memory.h:93
#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
DistanceErrorFunctionT< float > DistanceErrorFunction
Definition fwd.h:590
ParameterTransformT< float > ParameterTransform
Definition fwd.h:244
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.