Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Guilhem Saurel
pinocchio
Commits
3807421b
Commit
3807421b
authored
Dec 19, 2016
by
Joseph Mirabel
Committed by
Joseph Mirabel
Dec 19, 2016
Browse files
[C++] Planar joints uses (cos,sin) instead of angle.
parent
3917b447
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/multibody/joint/joint-planar.hpp
View file @
3807421b
...
@@ -269,7 +269,7 @@ namespace se3
...
@@ -269,7 +269,7 @@ namespace se3
struct
traits
<
JointPlanar
>
struct
traits
<
JointPlanar
>
{
{
enum
{
enum
{
NQ
=
3
,
NQ
=
4
,
NV
=
3
NV
=
3
};
};
typedef
double
Scalar
;
typedef
double
Scalar
;
...
@@ -330,7 +330,8 @@ namespace se3
...
@@ -330,7 +330,8 @@ namespace se3
{
{
EIGEN_STATIC_ASSERT_SAME_VECTOR_SIZE
(
ConfigVector_t
,
V
);
EIGEN_STATIC_ASSERT_SAME_VECTOR_SIZE
(
ConfigVector_t
,
V
);
double
c_theta
,
s_theta
;
SINCOS
(
q_joint
(
2
),
&
s_theta
,
&
c_theta
);
const
double
&
c_theta
=
q_joint
(
2
),
s_theta
=
q_joint
(
3
);
M
.
rotation
().
topLeftCorner
<
2
,
2
>
()
<<
c_theta
,
-
s_theta
,
s_theta
,
c_theta
;
M
.
rotation
().
topLeftCorner
<
2
,
2
>
()
<<
c_theta
,
-
s_theta
,
s_theta
,
c_theta
;
M
.
translation
().
head
<
2
>
()
=
q_joint
.
template
head
<
2
>();
M
.
translation
().
head
<
2
>
()
=
q_joint
.
template
head
<
2
>();
...
@@ -341,7 +342,8 @@ namespace se3
...
@@ -341,7 +342,8 @@ namespace se3
{
{
Eigen
::
VectorXd
::
ConstFixedSegmentReturnType
<
NQ
>::
Type
&
q
=
qs
.
segment
<
NQ
>
(
idx_q
());
Eigen
::
VectorXd
::
ConstFixedSegmentReturnType
<
NQ
>::
Type
&
q
=
qs
.
segment
<
NQ
>
(
idx_q
());
double
c_theta
,
s_theta
;
SINCOS
(
q
(
2
),
&
s_theta
,
&
c_theta
);
const
double
&
c_theta
=
q
(
2
),
s_theta
=
q
(
3
);
data
.
M
.
rotation
().
topLeftCorner
<
2
,
2
>
()
<<
c_theta
,
-
s_theta
,
s_theta
,
c_theta
;
data
.
M
.
rotation
().
topLeftCorner
<
2
,
2
>
()
<<
c_theta
,
-
s_theta
,
s_theta
,
c_theta
;
data
.
M
.
translation
().
head
<
2
>
()
=
q
.
head
<
2
>
();
data
.
M
.
translation
().
head
<
2
>
()
=
q
.
head
<
2
>
();
...
@@ -353,9 +355,10 @@ namespace se3
...
@@ -353,9 +355,10 @@ namespace se3
const
Eigen
::
VectorXd
&
vs
)
const
const
Eigen
::
VectorXd
&
vs
)
const
{
{
Eigen
::
VectorXd
::
ConstFixedSegmentReturnType
<
NQ
>::
Type
&
q
=
qs
.
segment
<
NQ
>
(
idx_q
());
Eigen
::
VectorXd
::
ConstFixedSegmentReturnType
<
NQ
>::
Type
&
q
=
qs
.
segment
<
NQ
>
(
idx_q
());
Eigen
::
VectorXd
::
ConstFixedSegmentReturnType
<
NV
>::
Type
&
q_dot
=
vs
.
segment
<
N
Q
>
(
idx_v
());
Eigen
::
VectorXd
::
ConstFixedSegmentReturnType
<
NV
>::
Type
&
q_dot
=
vs
.
segment
<
N
V
>
(
idx_v
());
double
c_theta
,
s_theta
;
SINCOS
(
q
(
2
),
&
s_theta
,
&
c_theta
);
const
double
&
c_theta
=
q
(
2
),
s_theta
=
q
(
3
);
data
.
M
.
rotation
().
topLeftCorner
<
2
,
2
>
()
<<
c_theta
,
-
s_theta
,
s_theta
,
c_theta
;
data
.
M
.
rotation
().
topLeftCorner
<
2
,
2
>
()
<<
c_theta
,
-
s_theta
,
s_theta
,
c_theta
;
data
.
M
.
translation
().
head
<
2
>
()
=
q
.
head
<
2
>
();
data
.
M
.
translation
().
head
<
2
>
()
=
q
.
head
<
2
>
();
...
@@ -393,14 +396,14 @@ namespace se3
...
@@ -393,14 +396,14 @@ namespace se3
typedef
Eigen
::
Matrix
<
double
,
2
,
2
>
Matrix22
;
typedef
Eigen
::
Matrix
<
double
,
2
,
2
>
Matrix22
;
typedef
Eigen
::
Matrix
<
double
,
2
,
1
>
Vector2
;
typedef
Eigen
::
Matrix
<
double
,
2
,
1
>
Vector2
;
double
c0
,
s0
;
SINCOS
(
q
(
2
),
&
s0
,
&
c0
);
const
double
&
c0
=
q
(
2
),
s0
=
q
(
3
);
Matrix22
R0
;
Matrix22
R0
;
R0
<<
c0
,
-
s0
,
s0
,
c0
;
R0
<<
c0
,
-
s0
,
s0
,
c0
;
const
double
&
t
=
q_dot
[
2
];
const
double
&
t
=
q_dot
[
2
];
const
double
theta
=
std
::
fabs
(
t
);
const
double
theta
=
std
::
fabs
(
t
);
ConfigVector_t
res
(
q
)
;
ConfigVector_t
res
;
if
(
theta
>
1e-14
)
if
(
theta
>
1e-14
)
{
{
// q_dot = [ x, y, t ]
// q_dot = [ x, y, t ]
...
@@ -427,15 +430,19 @@ namespace se3
...
@@ -427,15 +430,19 @@ namespace se3
const
double
s_coeff
=
st
*
inv_theta
;
const
double
s_coeff
=
st
*
inv_theta
;
const
Vector2
Sp_v
(
-
v
[
1
],
v
[
0
]);
const
Vector2
Sp_v
(
-
v
[
1
],
v
[
0
]);
if
(
t
>
0
)
res
.
head
<
2
>
()
+=
R0
*
(
s_coeff
*
v
+
c_coeff
*
Sp_v
);
if
(
t
>
0
)
res
.
head
<
2
>
()
=
q
.
head
<
2
>
()
+
R0
*
(
s_coeff
*
v
+
c_coeff
*
Sp_v
);
else
res
.
head
<
2
>
()
+=
R0
*
(
s_coeff
*
v
-
c_coeff
*
Sp_v
);
else
res
.
head
<
2
>
()
=
q
.
head
<
2
>
()
+
R0
*
(
s_coeff
*
v
-
c_coeff
*
Sp_v
);
res
[
2
]
+=
t
;
res
(
2
)
=
c0
*
ct
-
s0
*
st
;
res
(
3
)
=
s0
*
ct
+
c0
*
st
;
return
res
;
return
res
;
}
}
else
else
{
{
res
.
head
<
2
>
()
+=
R0
*
q_dot
.
head
<
2
>
();
res
.
head
<
2
>
()
=
q
.
head
<
2
>
()
+
R0
*
q_dot
.
head
<
2
>
();
res
[
2
]
+=
t
;
// TODO: theta is small. Use a 1st order approx
double
ct
,
st
;
SINCOS
(
theta
,
&
st
,
&
ct
);
res
(
2
)
=
c0
*
ct
-
s0
*
st
;
res
(
3
)
=
s0
*
ct
+
c0
*
st
;
}
}
return
res
;
return
res
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment