Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
bodydynamics
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mobile_robotics
wolf_projects
wolf_lib
plugins
bodydynamics
Commits
87404a17
Commit
87404a17
authored
5 years ago
by
Médéric Fourmy
Browse files
Options
Downloads
Patches
Plain Diff
Solved measurement simulation bugs
parent
266645a0
No related branches found
No related tags found
2 merge requests
!18
Release after RAL
,
!17
After 2nd RAL submission
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
demos/mcapi_povcdl_estimation.cpp
+47
-22
47 additions, 22 deletions
demos/mcapi_povcdl_estimation.cpp
demos/mcapi_utils.cpp
+4
-5
4 additions, 5 deletions
demos/mcapi_utils.cpp
with
51 additions
and
27 deletions
demos/mcapi_povcdl_estimation.cpp
+
47
−
22
View file @
87404a17
...
@@ -91,7 +91,8 @@ int main (int argc, char **argv) {
...
@@ -91,7 +91,8 @@ int main (int argc, char **argv) {
std
::
cout
<<
"q_traj.dim(): "
<<
q_traj
.
dim
()
<<
std
::
endl
;
std
::
cout
<<
"q_traj.dim(): "
<<
q_traj
.
dim
()
<<
std
::
endl
;
double
dt
=
1e-2
;
// chosen data sampling
double
dt
=
1e-2
;
// chosen data sampling
double
min_t
=
q_traj
.
min
();
double
min_t
=
q_traj
.
min
();
double
mac_t
=
q_traj
.
max
();
// double max_t = q_traj.max();
double
max_t
=
0.25
;
// only the beginning
// initialize some vectors and fill them with dicretized data
// initialize some vectors and fill them with dicretized data
std
::
vector
<
double
>
t_arr
;
std
::
vector
<
double
>
t_arr
;
...
@@ -104,7 +105,7 @@ int main (int argc, char **argv) {
...
@@ -104,7 +105,7 @@ int main (int argc, char **argv) {
std
::
vector
<
VectorXd
>
L_traj_arr
;
std
::
vector
<
VectorXd
>
L_traj_arr
;
std
::
vector
<
VectorXd
>
ll_contactf_traj_arr
;
std
::
vector
<
VectorXd
>
ll_contactf_traj_arr
;
std
::
vector
<
VectorXd
>
rl_contactf_traj_arr
;
std
::
vector
<
VectorXd
>
rl_contactf_traj_arr
;
for
(
double
t
=
min_t
;
t
<=
ma
c
_t
;
t
+=
dt
){
for
(
double
t
=
min_t
;
t
<=
ma
x
_t
;
t
+=
dt
){
t_arr
.
push_back
(
t
);
t_arr
.
push_back
(
t
);
q_traj_arr
.
push_back
(
q_traj
(
t
));
q_traj_arr
.
push_back
(
q_traj
(
t
));
dq_traj_arr
.
push_back
(
dq_traj
(
t
));
dq_traj_arr
.
push_back
(
dq_traj
(
t
));
...
@@ -131,8 +132,10 @@ int main (int argc, char **argv) {
...
@@ -131,8 +132,10 @@ int main (int argc, char **argv) {
// std::cout << "q: " << q.transpose() << std::endl;
// std::cout << "q: " << q.transpose() << std::endl;
// // Perform the forward kinematics over the kinematic tree
// // Perform the forward kinematics over the kinematic tree
// forwardKinematics(model,data,q);
// forwardKinematics(model,data,q);
int
ll_sole_idx
=
model
.
getFrameId
(
"leg_left_sole_fix_joint"
);
int
left_leg_sole_idx
=
model
.
getFrameId
(
"leg_left_sole_fix_joint"
);
int
rl_sole_idx
=
model
.
getFrameId
(
"leg_right_sole_fix_joint"
);
int
right_leg_sole_idx
=
model
.
getFrameId
(
"leg_right_sole_fix_joint"
);
std
::
cout
<<
"left_leg_sole_idx: "
<<
left_leg_sole_idx
<<
std
::
endl
;
std
::
cout
<<
"right_leg_sole_idx: "
<<
right_leg_sole_idx
<<
std
::
endl
;
std
::
vector
<
Vector3d
>
contacts
=
contacts_from_footrect_center
();
std
::
vector
<
Vector3d
>
contacts
=
contacts_from_footrect_center
();
...
@@ -141,7 +144,7 @@ int main (int argc, char **argv) {
...
@@ -141,7 +144,7 @@ int main (int argc, char **argv) {
// Groundtruth
// Groundtruth
std
::
vector
<
Vector3d
>
p_ob_gtruth_v
;
std
::
vector
<
Vector3d
>
p_ob_gtruth_v
;
std
::
vector
<
Vector4d
>
q_ob_gtruth_v
;
std
::
vector
<
Vector4d
>
q_ob_gtruth_v
;
//
std::vector<Vector3d> v_
w
b_gtruth_v;
std
::
vector
<
Vector3d
>
v_
o
b_gtruth_v
;
// std::vector<VectorXd>& c_gtruth_v = c_traj_arr; // already have it directly
// std::vector<VectorXd>& c_gtruth_v = c_traj_arr; // already have it directly
// std::vector<VectorXd>& cd_gtruth_v = dc_traj_arr; // already have it directly
// std::vector<VectorXd>& cd_gtruth_v = dc_traj_arr; // already have it directly
// std::vector<Vector3d> Lc_gtruth_v;
// std::vector<Vector3d> Lc_gtruth_v;
...
@@ -166,13 +169,13 @@ int main (int argc, char **argv) {
...
@@ -166,13 +169,13 @@ int main (int argc, char **argv) {
* Groundtruth to recover (in world frame, vels/inertial frame):
* Groundtruth to recover (in world frame, vels/inertial frame):
* b position --> OK
* b position --> OK
* b orientation (quat) --> OK
* b orientation (quat) --> OK
* b velocity: linear classical one
-> careful
* b velocity: linear classical one
--> OK
* CoM posi --> OK
* CoM posi --> OK
* CoM vel
* CoM vel
* Angular momentum
* Angular momentum
*
*
* Measures to recover (in local frames):
* Measures to recover (in local frames):
* IMU readings -->
ALMOST
OK
* IMU readings --> OK
* Kinematics readings --> OK
* Kinematics readings --> OK
* Wrench readings --> OK
* Wrench readings --> OK
* CoM relative position/vel --> OK
* CoM relative position/vel --> OK
...
@@ -185,7 +188,7 @@ int main (int argc, char **argv) {
...
@@ -185,7 +188,7 @@ int main (int argc, char **argv) {
VectorXd
dq
=
dq_traj_arr
[
i
];
VectorXd
dq
=
dq_traj_arr
[
i
];
VectorXd
ddq
=
ddq_traj_arr
[
i
];
VectorXd
ddq
=
ddq_traj_arr
[
i
];
Vector3d
c
=
c_traj_arr
[
i
];
// gtruth
Vector3d
c
=
c_traj_arr
[
i
];
// gtruth
VectorXd
dc
=
dc_traj_arr
[
i
];
// gtruth
(??)
VectorXd
dc
=
dc_traj_arr
[
i
];
// gtruth
VectorXd
cw
=
cw_traj_arr
[
i
];
VectorXd
cw
=
cw_traj_arr
[
i
];
VectorXd
L
=
L_traj_arr
[
i
];
VectorXd
L
=
L_traj_arr
[
i
];
VectorXd
cf_ll
=
ll_contactf_traj_arr
[
i
];
VectorXd
cf_ll
=
ll_contactf_traj_arr
[
i
];
...
@@ -199,7 +202,7 @@ int main (int argc, char **argv) {
...
@@ -199,7 +202,7 @@ int main (int argc, char **argv) {
// global frame pose
// global frame pose
SE3
oMb
(
Quaterniond
(
quat_wb
).
toRotationMatrix
(),
p_wb
);
SE3
oMb
(
Quaterniond
(
quat_wb
).
toRotationMatrix
(),
p_wb
);
// body vel is expressed in body frame
// body vel is expressed in body frame
//
Vector3d w_v_wb = oMb.rotation() * dq.head<3>(); // NOT USED
Vector3d
w_v_wb
=
oMb
.
rotation
()
*
dq
.
head
<
3
>
();
// NOT USED
// com velocity is already expressed in world frame
// com velocity is already expressed in world frame
// Vector3d w_v_wc = dc; // TO STORE
// Vector3d w_v_wc = dc; // TO STORE
// Lc ??
// Lc ??
...
@@ -218,8 +221,14 @@ int main (int argc, char **argv) {
...
@@ -218,8 +221,14 @@ int main (int argc, char **argv) {
// update and retrieve kinematics
// update and retrieve kinematics
forwardKinematics
(
model
,
data
,
q
);
forwardKinematics
(
model
,
data
,
q
);
auto
oMll
=
data
.
oMf
[
ll_sole_idx
];
// auto oMll = data.oMf[left_leg_sole_idx];
auto
oMrl
=
data
.
oMf
[
rl_sole_idx
];
// auto oMrl = data.oMf[right_leg_sole_idx];
auto
frame_ll_sole_idx
=
model
.
frames
[
left_leg_sole_idx
];
auto
oMll
=
data
.
oMi
[
frame_ll_sole_idx
.
parent
].
act
(
frame_ll_sole_idx
.
placement
);
auto
frame_rl_sole_idx
=
model
.
frames
[
right_leg_sole_idx
];
auto
oMrl
=
data
.
oMi
[
frame_rl_sole_idx
.
parent
].
act
(
frame_rl_sole_idx
.
placement
);
std
::
cout
<<
"oMll.translation(): "
<<
oMll
.
translation
().
transpose
()
<<
std
::
endl
;
std
::
cout
<<
"oMrl.translation(): "
<<
oMrl
.
translation
().
transpose
()
<<
std
::
endl
;
auto
bMll
=
oMb
.
inverse
()
*
oMll
;
auto
bMll
=
oMb
.
inverse
()
*
oMll
;
auto
bMrl
=
oMb
.
inverse
()
*
oMrl
;
auto
bMrl
=
oMb
.
inverse
()
*
oMrl
;
Vector3d
b_p_ll
=
bMll
.
translation
();
// meas
Vector3d
b_p_ll
=
bMll
.
translation
();
// meas
...
@@ -260,7 +269,7 @@ int main (int argc, char **argv) {
...
@@ -260,7 +269,7 @@ int main (int argc, char **argv) {
p_ob_gtruth_v
.
push_back
(
p_wb
);
p_ob_gtruth_v
.
push_back
(
p_wb
);
q_ob_gtruth_v
.
push_back
(
quat_wb
);
q_ob_gtruth_v
.
push_back
(
quat_wb
);
//
v_
w
b_gtruth_v;
v_
o
b_gtruth_v
.
push_back
(
w_v_wb
)
;
// Lc_gtruth_v;
// Lc_gtruth_v;
// Measurements
// Measurements
...
@@ -343,7 +352,7 @@ int main (int argc, char **argv) {
...
@@ -343,7 +352,7 @@ int main (int argc, char **argv) {
// - call setOrigin on processors isMotion since the flag prior_is_set is not true when doing installProcessor (later)
// - call setOrigin on processors isMotion since the flag prior_is_set is not true when doing installProcessor (later)
TimeStamp
t0
(
t_arr
[
0
]);
TimeStamp
t0
(
t_arr
[
0
]);
VectorXd
x_origin
;
x_origin
.
resize
(
19
);
VectorXd
x_origin
;
x_origin
.
resize
(
19
);
x_origin
<<
p_ob_gtruth_v
[
0
],
q_ob_gtruth_v
[
0
],
ZERO3
,
ZERO3
,
ZERO3
,
ZERO3
;
// TODO: origin vel shoulde not be zero but v_wb_gtruth_v[0]
x_origin
<<
p_ob_gtruth_v
[
0
],
q_ob_gtruth_v
[
0
],
v_ob_gtruth_v
[
0
]
,
ZERO3
,
ZERO3
,
ZERO3
;
// TODO: origin vel shoulde not be zero but v_wb_gtruth_v[0]
MatrixXd
P_origin
=
pow
(
1e-3
,
2
)
*
Eigen
::
Matrix9d
::
Identity
();
MatrixXd
P_origin
=
pow
(
1e-3
,
2
)
*
Eigen
::
Matrix9d
::
Identity
();
FrameBasePtr
KF1
=
problem
->
emplaceFrame
(
KEY
,
x_origin
,
t0
);
FrameBasePtr
KF1
=
problem
->
emplaceFrame
(
KEY
,
x_origin
,
t0
);
// Prior pose factor
// Prior pose factor
...
@@ -389,7 +398,7 @@ int main (int argc, char **argv) {
...
@@ -389,7 +398,7 @@ int main (int argc, char **argv) {
// Force Torque
// Force Torque
Vector6d
f_meas
;
f_meas
<<
wrench_ll_meas_v
[
i
].
head
<
3
>
(),
wrench_rl_meas_v
[
i
].
head
<
3
>
();
Vector6d
f_meas
;
f_meas
<<
wrench_ll_meas_v
[
i
].
head
<
3
>
(),
wrench_rl_meas_v
[
i
].
head
<
3
>
();
Vector6d
tau_meas
;
tau_meas
<<
wrench_ll_meas_v
[
i
].
head
<
3
>
(),
wrench_rl_meas_v
[
i
].
head
<
3
>
();
Vector6d
tau_meas
;
tau_meas
<<
wrench_ll_meas_v
[
i
].
tail
<
3
>
(),
wrench_rl_meas_v
[
i
].
tail
<
3
>
();
VectorXd
kin_meas
(
14
);
VectorXd
kin_meas
(
14
);
kin_meas
<<
p_bll_meas_v
[
i
],
p_brl_meas_v
[
i
],
q_bll_meas_v
[
i
],
q_brl_meas_v
[
i
];
kin_meas
<<
p_bll_meas_v
[
i
],
p_brl_meas_v
[
i
],
q_bll_meas_v
[
i
],
q_brl_meas_v
[
i
];
...
@@ -405,13 +414,24 @@ int main (int argc, char **argv) {
...
@@ -405,13 +414,24 @@ int main (int argc, char **argv) {
Qftp
.
block
<
6
,
6
>
(
6
,
6
)
=
cov_tau
;
Qftp
.
block
<
6
,
6
>
(
6
,
6
)
=
cov_tau
;
Qftp
.
block
<
3
,
3
>
(
12
,
12
)
=
cov_pbc
;
Qftp
.
block
<
3
,
3
>
(
12
,
12
)
=
cov_pbc
;
std
::
cout
<<
"
\n
w_b_meas_v[i]: "
<<
w_b_meas_v
[
i
].
transpose
()
<<
std
::
endl
;
CaptureImuPtr
CImu2
=
std
::
make_shared
<
CaptureImu
>
(
ts
,
sen_imu
,
acc_gyr_meas
,
acc_gyr_cov
);
std
::
cout
<<
"Lq_meas_v[i]: "
<<
Lq_meas_v
[
i
].
transpose
()
<<
std
::
endl
;
CImu2
->
process
();
std
::
cout
<<
"Iq_meas_v[i]
\n
"
<<
Iq_meas_v
[
i
]
<<
std
::
endl
;
auto
CIKin2
=
std
::
make_shared
<
CaptureInertialKinematics
>
(
ts
,
sen_ikin
,
meas_ikin
,
Iq_meas_v
[
i
],
Lq_meas_v
[
i
]);
std
::
cout
<<
"wrench_ll_meas_v[i]: "
<<
wrench_ll_meas_v
[
i
].
transpose
()
<<
std
::
endl
;
CIKin2
->
process
();
std
::
cout
<<
"wrench_rl_meas_v[i]: "
<<
wrench_rl_meas_v
[
i
].
transpose
()
<<
std
::
endl
;
auto
CFTpreint2
=
std
::
make_shared
<
CaptureForceTorquePreint
>
(
ts
,
sen_ft
,
CIKin2
,
CImu2
,
cap_ftp_data
,
Qftp
);
std
::
cout
<<
"p_bc_meas_v[i]: "
<<
p_bc_meas_v
[
i
].
transpose
()
<<
std
::
endl
;
CFTpreint2
->
process
();
std
::
cout
<<
"p_bll_meas_v[i]: "
<<
p_bll_meas_v
[
i
].
transpose
()
<<
std
::
endl
;
std
::
cout
<<
"p_brl_meas_v[i]: "
<<
p_brl_meas_v
[
i
].
transpose
()
<<
std
::
endl
;
std
::
cout
<<
"q_bll_meas_v[i]: "
<<
q_bll_meas_v
[
i
].
transpose
()
<<
std
::
endl
;
std
::
cout
<<
"q_brl_meas_v[i]: "
<<
q_brl_meas_v
[
i
].
transpose
()
<<
std
::
endl
;
CaptureImuPtr
CImu
=
std
::
make_shared
<
CaptureImu
>
(
ts
,
sen_imu
,
acc_gyr_meas
,
acc_gyr_cov
);
CImu
->
process
();
auto
CIKin
=
std
::
make_shared
<
CaptureInertialKinematics
>
(
ts
,
sen_ikin
,
meas_ikin
,
Iq_meas_v
[
i
],
Lq_meas_v
[
i
]);
CIKin
->
process
();
auto
CFTpreint
=
std
::
make_shared
<
CaptureForceTorquePreint
>
(
ts
,
sen_ft
,
CIKin
,
CImu
,
cap_ftp_data
,
Qftp
);
CFTpreint
->
process
();
/////////////////////////////////////////////
/////////////////////////////////////////////
// Manually create an Odom3d factor when a new KF is detected (will be put in a processorLegOdom3d)
// Manually create an Odom3d factor when a new KF is detected (will be put in a processorLegOdom3d)
...
@@ -455,9 +475,14 @@ int main (int argc, char **argv) {
...
@@ -455,9 +475,14 @@ int main (int argc, char **argv) {
///////////////////////////////////////////
///////////////////////////////////////////
/////////// SOLVING AND PRINTING //////////
/////////// SOLVING AND PRINTING //////////
///////////////////////////////////////////
///////////////////////////////////////////
problem
->
print
(
4
,
true
,
true
,
true
);
std
::
string
report
=
ceres_manager
->
solve
(
SolverManager
::
ReportVerbosity
::
BRIEF
);
std
::
string
report
=
ceres_manager
->
solve
(
SolverManager
::
ReportVerbosity
::
BRIEF
);
problem
->
print
(
4
,
true
,
true
,
true
);
std
::
cout
<<
report
<<
std
::
endl
;
std
::
cout
<<
report
<<
std
::
endl
;
std
::
cout
<<
"Ground truth end: "
<<
std
::
endl
;
std
::
cout
<<
p_ob_gtruth_v
[
p_ob_gtruth_v
.
size
()
-
1
].
transpose
()
<<
std
::
endl
;
std
::
cout
<<
q_ob_gtruth_v
[
q_ob_gtruth_v
.
size
()
-
1
].
transpose
()
<<
std
::
endl
;
std
::
cout
<<
v_ob_gtruth_v
[
v_ob_gtruth_v
.
size
()
-
1
].
transpose
()
<<
std
::
endl
;
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
demos/mcapi_utils.cpp
+
4
−
5
View file @
87404a17
...
@@ -28,11 +28,10 @@ Matrix<double, 6, 1> contact_force_to_wrench(const std::vector<Vector3d>& contac
...
@@ -28,11 +28,10 @@ Matrix<double, 6, 1> contact_force_to_wrench(const std::vector<Vector3d>& contac
Vector3d
wf
=
w_cforces
.
segment
<
3
>
(
0
)
+
w_cforces
.
segment
<
3
>
(
3
)
+
w_cforces
.
segment
<
3
>
(
6
)
+
w_cforces
.
segment
<
3
>
(
9
);
Vector3d
wf
=
w_cforces
.
segment
<
3
>
(
0
)
+
w_cforces
.
segment
<
3
>
(
3
)
+
w_cforces
.
segment
<
3
>
(
6
)
+
w_cforces
.
segment
<
3
>
(
9
);
Vector3d
lf
=
wRl
.
inverse
()
*
wf
;
Vector3d
lf
=
wRl
.
inverse
()
*
wf
;
// torque at point l (center of the foot) in world frame
// torque at point l (center of the foot) in world frame
Vector3d
w_tau_l
=
contacts
[
0
].
cross
(
w_cforces
.
segment
<
3
>
(
0
))
Vector3d
l_tau_l
=
contacts
[
0
].
cross
(
wRl
.
inverse
()
*
w_cforces
.
segment
<
3
>
(
0
))
+
contacts
[
1
].
cross
(
w_cforces
.
segment
<
3
>
(
3
))
+
contacts
[
1
].
cross
(
wRl
.
inverse
()
*
w_cforces
.
segment
<
3
>
(
3
))
+
contacts
[
2
].
cross
(
w_cforces
.
segment
<
3
>
(
6
))
+
contacts
[
2
].
cross
(
wRl
.
inverse
()
*
w_cforces
.
segment
<
3
>
(
6
))
+
contacts
[
3
].
cross
(
w_cforces
.
segment
<
3
>
(
9
));
+
contacts
[
3
].
cross
(
wRl
.
inverse
()
*
w_cforces
.
segment
<
3
>
(
9
));
Vector3d
l_tau_l
=
wRl
.
inverse
()
*
w_tau_l
;
Matrix
<
double
,
6
,
1
>
l_wrench
;
l_wrench
<<
lf
,
l_tau_l
;
Matrix
<
double
,
6
,
1
>
l_wrench
;
l_wrench
<<
lf
,
l_tau_l
;
return
l_wrench
;
return
l_wrench
;
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment