-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathDynamics.h
More file actions
93 lines (82 loc) · 2.94 KB
/
Copy pathDynamics.h
File metadata and controls
93 lines (82 loc) · 2.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
/* ----------------------------------------------------------------------------
* GTDynamics Copyright 2020-2021, Georgia Tech Research Corporation,
* Atlanta, Georgia 30332-0415
* All Rights Reserved
* See LICENSE for the license information
* -------------------------------------------------------------------------- */
/**
* @file Dynamics.h
* @brief Wrench calculations for configurations in motion.
* @author Frank Dellaert, Mandy Xie, Yetong Zhang, and Gerry Chen
*/
#pragma once
#include <gtdynamics/dynamics/DynamicsParameters.h>
#include <gtdynamics/universal_robot/Robot.h>
#include <gtdynamics/utils/Interval.h>
#include <gtdynamics/utils/PointOnLink.h>
#include <gtdynamics/utils/Slice.h>
#include <gtsam/base/Matrix.h>
#include <gtsam/base/OptionalJacobian.h>
#include <gtsam/base/Vector.h>
#include <gtsam/nonlinear/NonlinearFactorGraph.h>
namespace gtdynamics {
/**
* Calculate Coriolis wrench term and Jacobian with respect to twist.
* @param inertia Spatial inertia matrix.
* @param twist Spatial twist.
* @param H_twist Optional Jacobian with respect to twist.
*/
gtsam::Vector6 Coriolis(const gtsam::Matrix6 &inertia,
const gtsam::Vector6 &twist,
gtsam::OptionalJacobian<6, 6> H_twist = {});
/// Matrix vector multiplication.
template <int M, int N>
inline Eigen::Matrix<double, M, 1> MatVecMult(
const Eigen::Matrix<double, M, N> &constant_matrix,
const Eigen::Matrix<double, N, 1> &vector,
gtsam::OptionalJacobian<M, N> H_vector) {
if (H_vector) {
*H_vector = constant_matrix;
}
return constant_matrix * vector;
}
/**
* Dynamics factor builder for moving configurations.
*
* For the templated API below, `CONTEXT` is typically `Slice`, `Interval`,
* or `Phase`.
*/
class Dynamics {
protected:
const DynamicsParameters p_;
public:
/**
* Constructor.
* @param parameters Dynamics parameter bundle with mechanics + dynamic-only
* noise models and settings.
*/
Dynamics(const DynamicsParameters& parameters = DynamicsParameters())
: p_(parameters) {}
/**
* Return acceleration-level factor graph.
* @param contact_points Optional contact points with zero-acceleration
* constraints.
*/
template <class CONTEXT>
gtsam::NonlinearFactorGraph aFactors(
const CONTEXT& context, const Robot& robot,
const std::optional<PointOnLinks>& contact_points = {}) const;
/**
* Return dynamic-only wrench factors for a context.
* This excludes factor groups provided via the Statics slice interface.
* @param contact_points Optional contact points that add friction/moment
* factors and contact wrench keys.
* @param mu Optional friction coefficient (defaults to 1.0).
*/
template <class CONTEXT>
gtsam::NonlinearFactorGraph graph(
const CONTEXT& context, const Robot& robot,
const std::optional<PointOnLinks>& contact_points = {},
const std::optional<double>& mu = {}) const;
};
} // namespace gtdynamics