wuzp
Wrong Unit? Zero Points! Compile-time checks for units, coordinate systems and points vs. vectors.
Loading...
Searching...
No Matches
kinematics.hpp
Go to the documentation of this file.
1#pragma once
2
10#include "wuzp/core/traits.hpp"
11
12// The transport formulas of rigid body kinematics: the velocity and the acceleration of a point fixed to a rigid body from those
13// of another point of the body, like the shifts of Drake's spatial velocities and accelerations
14// (https://drake.mit.edu/doxygen_cxx/group__multibody__spatial__vectors.html). The spatial vectors, which also track the frame the
15// motion is measured in and the point it is about, shift with them (see SpatialVelocity::shift() and SpatialAcceleration::shift()).
16
17namespace wuzp {
18namespace internal {
19
24template <typename TensorT_, typename UnitT_>
25using KinematicVector3 =
26 Tensor<Indices<Up>,
27 Quantities<typename Rebind<typename TensorT_::ValuesT, typename TensorT_::ValueT, 3, 1>::type, TypeMatrix<3, 1, UnitT_>>,
28 typename TensorT_::CoordinateSystemT, Relative>;
29
31template <typename TensorT_>
32using KinematicUnits = AccessUnits<AccessImplementation<typename TensorT_::ValueT>>;
33
34} // namespace internal
35
46template <AnyTensor VelocityT_, AnyTensor AngularVelocityT_, AnyTensor OffsetT_>
47auto velocityOfBodyFixedPoint(const VelocityT_& velocity, const AngularVelocityT_& angularVelocity, const OffsetT_& offset) {
48 using UnitsT = internal::KinematicUnits<VelocityT_>;
49 const internal::KinematicVector3<VelocityT_, typename UnitsT::AngularVelocity> w{angularVelocity};
50 return velocity + w.crossProduct(internal::KinematicVector3<VelocityT_, typename UnitsT::Length>{offset});
51}
52
62template <AnyTensor AccelerationT_, AnyTensor AngularAccelerationT_, AnyTensor AngularVelocityT_, AnyTensor OffsetT_>
63auto accelerationOfBodyFixedPoint(const AccelerationT_& acceleration, const AngularAccelerationT_& angularAcceleration,
64 const AngularVelocityT_& angularVelocity, const OffsetT_& offset) {
65 using UnitsT = internal::KinematicUnits<AccelerationT_>;
66 const internal::KinematicVector3<AccelerationT_, typename UnitsT::AngularAcceleration> alpha{angularAcceleration};
67 const internal::KinematicVector3<AccelerationT_, typename UnitsT::AngularVelocity> w{angularVelocity};
68 const internal::KinematicVector3<AccelerationT_, typename UnitsT::Length> p{offset};
69 return acceleration + alpha.crossProduct(p) + w.crossProduct(w.crossProduct(p));
70}
71
72} // namespace wuzp
auto crossProduct(const Tensor< IndicesOtherT_, QuantitiesOtherT_, CoordinateSystemOtherT_, AbsoluteOtherT_ > &other) const
The cross product a x b of two three-dimensional vectors in the same Euclidean coordinate system (see...
Definition Tensor.hpp:297
auto accelerationOfBodyFixedPoint(const AccelerationT_ &acceleration, const AngularAccelerationT_ &angularAcceleration, const AngularVelocityT_ &angularVelocity, const OffsetT_ &offset)
The acceleration a_Q = a_P + alpha x p_PQ + w x (w x p_PQ) of a point Q fixed to a rigid body,...
internal::AbsoluteImpl< false > Relative
Definition Absolute.hpp:18
auto velocityOfBodyFixedPoint(const VelocityT_ &velocity, const AngularVelocityT_ &angularVelocity, const OffsetT_ &offset)
The velocity v_Q = v_P + w x p_PQ of a point Q fixed to a rigid body, from the velocity v_P of a poin...
typename CreateTypeMatrix< RowsV_, ColsV_, Types... >::type TypeMatrix
A matrix storing types at compile-time.