Skip to content

Commit 35fe154

Browse files
committed
spatial: Apply new convention on se3 headers
1 parent ebdecf1 commit 35fe154

File tree

6 files changed

+735
-686
lines changed

6 files changed

+735
-686
lines changed
Lines changed: 225 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,225 @@
1+
//
2+
// Copyright (c) 2015-2025 CNRS INRIA
3+
// Copyright (c) 2016 Wandercraft, 86 rue de Paris 91400 Orsay, France.
4+
//
5+
6+
#ifndef __pinocchio_spatial_se3_base_def_hxx__
7+
#define __pinocchio_spatial_se3_base_def_hxx__
8+
9+
#ifdef PINOCCHIO_LSP
10+
#include "pinocchio/spatial/se3-base.hpp"
11+
#endif
12+
13+
namespace pinocchio
14+
{
15+
/** \brief Base class for rigid transformation.
16+
*
17+
* The rigid transform aMb can be seen in two ways:
18+
*
19+
* - given a point p expressed in frame B by its coordinate vector \f$ ^bp \f$, \f$ ^aM_b \f$
20+
* computes its coordinates in frame A by \f$ ^ap = {}^aM_b {}^bp \f$.
21+
* - \f$ ^aM_b \f$ displaces a solid S centered at frame A into the solid centered in
22+
* B. In particular, the origin of A is displaced at the origin of B:
23+
* \f$^aM_b {}^aA = {}^aB \f$.
24+
25+
* The rigid displacement is stored as a rotation matrix and translation vector by:
26+
* \f$ ^aM_b x = {}^aR_b x + {}^aAB \f$
27+
* where \f$^aAB\f$ is the vector from origin A to origin B expressed in coordinates A.
28+
*
29+
* \cheatsheet \f$ {}^aM_c = {}^aM_b {}^bM_c \f$
30+
*
31+
* \ingroup pinocchio_spatial
32+
*/
33+
template<class Derived>
34+
struct SE3Base : NumericalBase<Derived>
35+
{
36+
PINOCCHIO_SE3_TYPEDEF_TPL(Derived);
37+
38+
Derived & derived()
39+
{
40+
return *static_cast<Derived *>(this);
41+
}
42+
const Derived & derived() const
43+
{
44+
return *static_cast<const Derived *>(this);
45+
}
46+
47+
Derived & const_cast_derived() const
48+
{
49+
return *const_cast<Derived *>(&derived());
50+
}
51+
52+
ConstAngularRef rotation() const
53+
{
54+
return derived().rotation_impl();
55+
}
56+
ConstLinearRef translation() const
57+
{
58+
return derived().translation_impl();
59+
}
60+
AngularRef rotation()
61+
{
62+
return derived().rotation_impl();
63+
}
64+
LinearRef translation()
65+
{
66+
return derived().translation_impl();
67+
}
68+
void rotation(const AngularType & R)
69+
{
70+
derived().rotation_impl(R);
71+
}
72+
void translation(const LinearType & t)
73+
{
74+
derived().translation_impl(t);
75+
}
76+
77+
HomogeneousMatrixType toHomogeneousMatrix() const
78+
{
79+
return derived().toHomogeneousMatrix_impl();
80+
}
81+
operator HomogeneousMatrixType() const
82+
{
83+
return toHomogeneousMatrix();
84+
}
85+
86+
/**
87+
* @brief The action matrix \f$ {}^aX_b \f$ of \f$ {}^aM_b \f$.
88+
*
89+
* With \f$ {}^aM_b = \left( \begin{array}{cc} R & t \\ 0 & 1 \\ \end{array} \right) \f$,
90+
* \f[
91+
* {}^aX_b = \left( \begin{array}{cc} R & \hat{t} R \\ 0 & R \\ \end{array} \right)
92+
* \f]
93+
*
94+
* \cheatsheet \f$ {}^a\nu_c = {}^aX_b {}^b\nu_c \f$
95+
*/
96+
ActionMatrixType toActionMatrix() const
97+
{
98+
return derived().toActionMatrix_impl();
99+
}
100+
operator ActionMatrixType() const
101+
{
102+
return toActionMatrix();
103+
}
104+
105+
template<typename Matrix6Like>
106+
void toActionMatrix(const Eigen::MatrixBase<Matrix6Like> & action_matrix) const
107+
{
108+
derived().toActionMatrix_impl(action_matrix);
109+
}
110+
111+
/**
112+
* @brief The action matrix \f$ {}^bX_a \f$ of \f$ {}^aM_b \f$.
113+
* \sa toActionMatrix()
114+
*/
115+
ActionMatrixType toActionMatrixInverse() const
116+
{
117+
return derived().toActionMatrixInverse_impl();
118+
}
119+
120+
template<typename Matrix6Like>
121+
void toActionMatrixInverse(const Eigen::MatrixBase<Matrix6Like> & action_matrix_inverse) const
122+
{
123+
derived().toActionMatrixInverse_impl(action_matrix_inverse.const_cast_derived());
124+
}
125+
126+
ActionMatrixType toDualActionMatrix() const
127+
{
128+
return derived().toDualActionMatrix_impl();
129+
}
130+
131+
void disp(std::ostream & os) const
132+
{
133+
static_cast<const Derived *>(this)->disp_impl(os);
134+
}
135+
136+
template<typename Matrix6Like>
137+
void toDualActionMatrix(const Eigen::MatrixBase<Matrix6Like> & dual_action_matrix) const
138+
{
139+
derived().toDualActionMatrix_impl(dual_action_matrix);
140+
}
141+
142+
typename SE3GroupAction<Derived>::ReturnType operator*(const Derived & m2) const
143+
{
144+
return derived().__mult__(m2);
145+
}
146+
147+
/// ay = aXb.act(by)
148+
template<typename D>
149+
typename SE3GroupAction<D>::ReturnType act(const D & d) const
150+
{
151+
return derived().act_impl(d);
152+
}
153+
154+
/// by = aXb.actInv(ay)
155+
template<typename D>
156+
typename SE3GroupAction<D>::ReturnType actInv(const D & d) const
157+
{
158+
return derived().actInv_impl(d);
159+
}
160+
161+
bool operator==(const Derived & other) const
162+
{
163+
return derived().isEqual(other);
164+
}
165+
166+
bool operator!=(const Derived & other) const
167+
{
168+
return !(*this == other);
169+
}
170+
171+
bool isApprox(
172+
const Derived & other,
173+
const Scalar & prec = Eigen::NumTraits<Scalar>::dummy_precision()) const
174+
{
175+
return derived().isApprox_impl(other, prec);
176+
}
177+
178+
friend std::ostream & operator<<(std::ostream & os, const SE3Base<Derived> & X)
179+
{
180+
X.disp(os);
181+
return os;
182+
}
183+
184+
///
185+
/// \returns true if *this is approximately equal to the identity placement, within the
186+
/// precision given by prec.
187+
///
188+
bool isIdentity(
189+
const typename traits<Derived>::Scalar & prec =
190+
Eigen::NumTraits<typename traits<Derived>::Scalar>::dummy_precision()) const
191+
{
192+
return derived().isIdentity(prec);
193+
}
194+
195+
///
196+
/// \returns true if the rotational part of *this is a rotation matrix (normalized columns),
197+
/// within the precision given by prec.
198+
///
199+
bool isNormalized(const Scalar & prec = Eigen::NumTraits<Scalar>::dummy_precision()) const
200+
{
201+
return derived().isNormalized(prec);
202+
}
203+
204+
///
205+
/// \brief Normalize *this in such a way the rotation part of *this lies on SO(3).
206+
///
207+
void normalize()
208+
{
209+
derived().normalize();
210+
}
211+
212+
///
213+
/// \returns a Normalized version of *this, in such a way the rotation part of the returned
214+
/// transformation lies on SO(3).
215+
///
216+
PlainType normalized() const
217+
{
218+
derived().normalized();
219+
}
220+
221+
}; // struct SE3Base
222+
223+
} // namespace pinocchio
224+
225+
#endif // ifndef __pinocchio_spatial_se3_base_def_hxx__

0 commit comments

Comments
 (0)