velocities.hpp
Go to the documentation of this file.
1 #ifndef SOPHUS_VELOCITIES_HPP
2 #define SOPHUS_VELOCITIES_HPP
3 
4 #include <functional>
5 
6 #include "num_diff.hpp"
7 #include "se3.hpp"
8 
9 namespace Sophus {
10 namespace experimental {
11 // Experimental since the API will certainly change drastically in the future.
12 
13 // Transforms velocity vector by rotation ``foo_R_bar``.
14 //
15 // Note: vel_bar can be either a linear or a rotational velocity vector.
16 //
17 template <class Scalar>
19  Vector3<Scalar> const& vel_bar) {
20  // For rotational velocities note that:
21  //
22  // vel_bar = vee(foo_R_bar * hat(vel_bar) * foo_R_bar^T)
23  // = vee(hat(Adj(foo_R_bar) * vel_bar))
24  // = Adj(foo_R_bar) * vel_bar
25  // = foo_R_bar * vel_bar.
26  //
27  return foo_R_bar * vel_bar;
28 }
29 
30 // Transforms velocity vector by pose ``foo_T_bar``.
31 //
32 // Note: vel_bar can be either a linear or a rotational velocity vector.
33 //
34 template <class Scalar>
36  Vector3<Scalar> const& vel_bar) {
37  return transformVelocity(foo_T_bar.so3(), vel_bar);
38 }
39 
40 // finite difference approximation of instantanious velocity in frame foo
41 //
42 template <class Scalar>
44  std::function<SO3<Scalar>(Scalar)> const& foo_R_bar, Scalar t,
45  Scalar h = Constants<Scalar>::epsilon()) {
46  // https://en.wikipedia.org/w/index.php?title=Angular_velocity&oldid=791867792#Angular_velocity_tensor
47  //
48  // W = dR(t)/dt * R^{-1}(t)
49  Matrix3<Scalar> dR_dt_in_frame_foo = curveNumDiff(
50  [&foo_R_bar](Scalar t0) -> Matrix3<Scalar> {
51  return foo_R_bar(t0).matrix();
52  },
53  t, h);
54  // velocity tensor
55  Matrix3<Scalar> W_in_frame_foo =
56  dR_dt_in_frame_foo * (foo_R_bar(t)).inverse().matrix();
57  return SO3<Scalar>::vee(W_in_frame_foo);
58 }
59 
60 // finite difference approximation of instantanious velocity in frame foo
61 //
62 template <class Scalar>
64  std::function<SE3<Scalar>(Scalar)> const& foo_T_bar, Scalar t,
65  Scalar h = Constants<Scalar>::epsilon()) {
66  return finiteDifferenceRotationalVelocity<Scalar>(
67  [&foo_T_bar](Scalar t) -> SO3<Scalar> { return foo_T_bar(t).so3(); }, t,
68  h);
69 }
70 
71 } // namespace experimental
72 } // namespace Sophus
73 
74 #endif // SOPHUS_VELOCITIES_HPP
Sophus::SE3::so3
SOPHUS_FUNC SO3Member & so3()
Definition: se3.hpp:527
Sophus::experimental::transformVelocity
Vector3< Scalar > transformVelocity(SO3< Scalar > const &foo_R_bar, Vector3< Scalar > const &vel_bar)
Definition: velocities.hpp:18
Sophus::SO3
SO3 using default storage; derived from SO3Base.
Definition: so3.hpp:19
Sophus::SO3::vee
static SOPHUS_FUNC Tangent vee(Transformation const &Omega)
Definition: so3.hpp:749
Sophus::experimental::finiteDifferenceRotationalVelocity
Vector3< Scalar > finiteDifferenceRotationalVelocity(std::function< SO3< Scalar >(Scalar)> const &foo_R_bar, Scalar t, Scalar h=Constants< Scalar >::epsilon())
Definition: velocities.hpp:43
Sophus::Vector3
Vector< Scalar, 3, Options > Vector3
Definition: types.hpp:21
Sophus::curveNumDiff
auto curveNumDiff(Fn curve, Scalar t, Scalar h=Constants< Scalar >::epsilonSqrt()) -> decltype(details::Curve< Scalar >::num_diff(std::move(curve), t, h))
Definition: num_diff.hpp:72
Sophus
Definition: average.hpp:17
Sophus::SE3
SE3 using default storage; derived from SE3Base.
Definition: se3.hpp:11
se3.hpp
Sophus::Constants
Definition: common.hpp:146
Sophus::Matrix3
Matrix< Scalar, 3, 3 > Matrix3
Definition: types.hpp:49
num_diff.hpp


sophus
Author(s): Hauke Strasdat
autogenerated on Wed Mar 2 2022 01:01:48