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
9a7b775d
Commit
9a7b775d
authored
2 years ago
by
Joan Solà Ortega
Browse files
Options
Downloads
Patches
Plain Diff
Cleanup code
parent
a6221b11
No related branches found
No related tags found
2 merge requests
!31
devel->main
,
!30
Complete UAV identification setup
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
test/gtest_simulation_problem_force_torque_inertial_dynamics.cpp
+44
-60
44 additions, 60 deletions
...est_simulation_problem_force_torque_inertial_dynamics.cpp
with
44 additions
and
60 deletions
test/gtest_simulation_problem_force_torque_inertial_dynamics.cpp
+
44
−
60
View file @
9a7b775d
...
@@ -67,14 +67,15 @@ class Test_SimulationProblemForceTorqueInertialDynamics_yaml : public testing::T
...
@@ -67,14 +67,15 @@ class Test_SimulationProblemForceTorqueInertialDynamics_yaml : public testing::T
Vector3d
cdm_true
;
Vector3d
cdm_true
;
Vector3d
inertia_true
;
Vector3d
inertia_true
;
double
mass_true
;
double
mass_true
;
Vector
<
double
,
12
>
data_fti
;
double
dt
;
// Pose sensor
// Pose sensor
SensorBasePtr
SP
;
SensorBasePtr
SP
;
Vector7d
pose
;
Vector7d
data_pose
;
double
dt
;
// Reading csv data
// Reading csv data
_fti
std
::
vector
<
double
>
time_stamp
;
std
::
vector
<
double
>
time_stamp
;
std
::
vector
<
Vector3d
>
position
,
vlin
,
vang
,
force
,
torque
,
a_meas
;
std
::
vector
<
Vector3d
>
position
,
vlin
,
vang
,
force
,
torque
,
a_meas
;
std
::
vector
<
Quaterniond
>
quaternion
;
std
::
vector
<
Quaterniond
>
quaternion
;
...
@@ -97,11 +98,11 @@ class Test_SimulationProblemForceTorqueInertialDynamics_yaml : public testing::T
...
@@ -97,11 +98,11 @@ class Test_SimulationProblemForceTorqueInertialDynamics_yaml : public testing::T
while
(
std
::
getline
(
data_simulation
,
line_data
))
while
(
std
::
getline
(
data_simulation
,
line_data
))
{
{
std
::
stringstream
data
(
line_data
);
std
::
stringstream
data
_str
(
line_data
);
// time stamp
// time stamp
string
string_time_stamp
;
string
string_time_stamp
;
std
::
getline
(
data
,
string_time_stamp
,
delimiter
);
std
::
getline
(
data
_str
,
string_time_stamp
,
delimiter
);
time_stamp
.
push_back
(
std
::
stod
(
string_time_stamp
));
time_stamp
.
push_back
(
std
::
stod
(
string_time_stamp
));
// position
// position
...
@@ -109,9 +110,9 @@ class Test_SimulationProblemForceTorqueInertialDynamics_yaml : public testing::T
...
@@ -109,9 +110,9 @@ class Test_SimulationProblemForceTorqueInertialDynamics_yaml : public testing::T
string
string_pos_y
;
string
string_pos_y
;
string
string_pos_z
;
string
string_pos_z
;
std
::
getline
(
data
,
string_pos_x
,
delimiter
);
std
::
getline
(
data
_str
,
string_pos_x
,
delimiter
);
std
::
getline
(
data
,
string_pos_y
,
delimiter
);
std
::
getline
(
data
_str
,
string_pos_y
,
delimiter
);
std
::
getline
(
data
,
string_pos_z
,
delimiter
);
std
::
getline
(
data
_str
,
string_pos_z
,
delimiter
);
position_i
(
0
)
=
std
::
stod
(
string_pos_x
);
position_i
(
0
)
=
std
::
stod
(
string_pos_x
);
position_i
(
1
)
=
std
::
stod
(
string_pos_y
);
position_i
(
1
)
=
std
::
stod
(
string_pos_y
);
...
@@ -125,10 +126,10 @@ class Test_SimulationProblemForceTorqueInertialDynamics_yaml : public testing::T
...
@@ -125,10 +126,10 @@ class Test_SimulationProblemForceTorqueInertialDynamics_yaml : public testing::T
string
string_quat_z
;
string
string_quat_z
;
string
string_quat_w
;
string
string_quat_w
;
std
::
getline
(
data
,
string_quat_x
,
delimiter
);
std
::
getline
(
data
_str
,
string_quat_x
,
delimiter
);
std
::
getline
(
data
,
string_quat_y
,
delimiter
);
std
::
getline
(
data
_str
,
string_quat_y
,
delimiter
);
std
::
getline
(
data
,
string_quat_z
,
delimiter
);
std
::
getline
(
data
_str
,
string_quat_z
,
delimiter
);
std
::
getline
(
data
,
string_quat_w
,
delimiter
);
std
::
getline
(
data
_str
,
string_quat_w
,
delimiter
);
Quaterniond
quaternion_i
(
std
::
stod
(
string_quat_w
),
Quaterniond
quaternion_i
(
std
::
stod
(
string_quat_w
),
std
::
stod
(
string_quat_x
),
std
::
stod
(
string_quat_x
),
...
@@ -142,9 +143,9 @@ class Test_SimulationProblemForceTorqueInertialDynamics_yaml : public testing::T
...
@@ -142,9 +143,9 @@ class Test_SimulationProblemForceTorqueInertialDynamics_yaml : public testing::T
string
string_vlin_y
;
string
string_vlin_y
;
string
string_vlin_z
;
string
string_vlin_z
;
std
::
getline
(
data
,
string_vlin_x
,
delimiter
);
std
::
getline
(
data
_str
,
string_vlin_x
,
delimiter
);
std
::
getline
(
data
,
string_vlin_y
,
delimiter
);
std
::
getline
(
data
_str
,
string_vlin_y
,
delimiter
);
std
::
getline
(
data
,
string_vlin_z
,
delimiter
);
std
::
getline
(
data
_str
,
string_vlin_z
,
delimiter
);
vlin_i
(
0
)
=
std
::
stod
(
string_vlin_x
);
vlin_i
(
0
)
=
std
::
stod
(
string_vlin_x
);
vlin_i
(
1
)
=
std
::
stod
(
string_vlin_y
);
vlin_i
(
1
)
=
std
::
stod
(
string_vlin_y
);
...
@@ -157,9 +158,9 @@ class Test_SimulationProblemForceTorqueInertialDynamics_yaml : public testing::T
...
@@ -157,9 +158,9 @@ class Test_SimulationProblemForceTorqueInertialDynamics_yaml : public testing::T
string
string_vang_y
;
string
string_vang_y
;
string
string_vang_z
;
string
string_vang_z
;
std
::
getline
(
data
,
string_vang_x
,
delimiter
);
std
::
getline
(
data
_str
,
string_vang_x
,
delimiter
);
std
::
getline
(
data
,
string_vang_y
,
delimiter
);
std
::
getline
(
data
_str
,
string_vang_y
,
delimiter
);
std
::
getline
(
data
,
string_vang_z
,
delimiter
);
std
::
getline
(
data
_str
,
string_vang_z
,
delimiter
);
vang_i
(
0
)
=
std
::
stod
(
string_vang_x
);
vang_i
(
0
)
=
std
::
stod
(
string_vang_x
);
vang_i
(
1
)
=
std
::
stod
(
string_vang_y
);
vang_i
(
1
)
=
std
::
stod
(
string_vang_y
);
...
@@ -172,9 +173,9 @@ class Test_SimulationProblemForceTorqueInertialDynamics_yaml : public testing::T
...
@@ -172,9 +173,9 @@ class Test_SimulationProblemForceTorqueInertialDynamics_yaml : public testing::T
string
string_force_y
;
string
string_force_y
;
string
string_force_z
;
string
string_force_z
;
std
::
getline
(
data
,
string_force_x
,
delimiter
);
std
::
getline
(
data
_str
,
string_force_x
,
delimiter
);
std
::
getline
(
data
,
string_force_y
,
delimiter
);
std
::
getline
(
data
_str
,
string_force_y
,
delimiter
);
std
::
getline
(
data
,
string_force_z
,
delimiter
);
std
::
getline
(
data
_str
,
string_force_z
,
delimiter
);
force_i
(
0
)
=
std
::
stod
(
string_force_x
);
force_i
(
0
)
=
std
::
stod
(
string_force_x
);
force_i
(
1
)
=
std
::
stod
(
string_force_y
);
force_i
(
1
)
=
std
::
stod
(
string_force_y
);
...
@@ -187,9 +188,9 @@ class Test_SimulationProblemForceTorqueInertialDynamics_yaml : public testing::T
...
@@ -187,9 +188,9 @@ class Test_SimulationProblemForceTorqueInertialDynamics_yaml : public testing::T
string
string_torque_y
;
string
string_torque_y
;
string
string_torque_z
;
string
string_torque_z
;
std
::
getline
(
data
,
string_torque_x
,
delimiter
);
std
::
getline
(
data
_str
,
string_torque_x
,
delimiter
);
std
::
getline
(
data
,
string_torque_y
,
delimiter
);
std
::
getline
(
data
_str
,
string_torque_y
,
delimiter
);
std
::
getline
(
data
,
string_torque_z
,
delimiter
);
std
::
getline
(
data
_str
,
string_torque_z
,
delimiter
);
torque_i
(
0
)
=
std
::
stod
(
string_torque_x
);
torque_i
(
0
)
=
std
::
stod
(
string_torque_x
);
torque_i
(
1
)
=
std
::
stod
(
string_torque_y
);
torque_i
(
1
)
=
std
::
stod
(
string_torque_y
);
...
@@ -210,7 +211,7 @@ class Test_SimulationProblemForceTorqueInertialDynamics_yaml : public testing::T
...
@@ -210,7 +211,7 @@ class Test_SimulationProblemForceTorqueInertialDynamics_yaml : public testing::T
{
{
bias_true
=
Vector6d
::
Zero
();
bias_true
=
Vector6d
::
Zero
();
cdm_true
=
{
0
,
0
,
0
};
cdm_true
=
{
0
,
0
,
0
};
inertia_true
=
{
0.0134943
,
0.0141622
,
0.0237319
};
// rounded {0.017598, 0.017957, 0.029599}
inertia_true
=
{
0.0134943
,
0.0141622
,
0.0237319
};
mass_true
=
1.9828
;
mass_true
=
1.9828
;
std
::
string
wolf_bodydynamics_root
=
_WOLF_BODYDYNAMICS_ROOT_DIR
;
std
::
string
wolf_bodydynamics_root
=
_WOLF_BODYDYNAMICS_ROOT_DIR
;
...
@@ -317,23 +318,18 @@ TEST_F(Test_SimulationProblemForceTorqueInertialDynamics_yaml, preintegration_an
...
@@ -317,23 +318,18 @@ TEST_F(Test_SimulationProblemForceTorqueInertialDynamics_yaml, preintegration_an
p
->
getOrigin
()
->
getFrame
()
->
getStateBlock
(
'L'
)
->
setState
(
ang_mom_init
);
p
->
getOrigin
()
->
getFrame
()
->
getStateBlock
(
'L'
)
->
setState
(
ang_mom_init
);
for
(
int
i
=
i_init
+
1
;
i
<
time_stamp
.
size
();
i
++
)
// start with second data
for
(
int
i
=
i_init
+
1
;
i
<
time_stamp
.
size
();
i
++
)
// start with second data
_fti
{
{
// SIMULATOR
// SIMULATOR
TimeStamp
t
=
time_stamp
[
i
];
TimeStamp
t
=
time_stamp
[
i
];
// Data
// Data
VectorXd
data
=
VectorXd
::
Zero
(
12
);
// [ a, w, f, t ]
data_fti
<<
a_meas
[
i
],
vang
[
i
],
force
[
i
],
torque
[
i
];
data
.
segment
<
3
>
(
0
)
=
a_meas
[
i
];
data
.
segment
<
3
>
(
3
)
=
vang
[
i
];
data
.
segment
<
3
>
(
6
)
=
force
[
i
];
data
.
segment
<
3
>
(
9
)
=
torque
[
i
];
MatrixXd
data_cov
=
S
->
getNoiseCov
();
// ESTIMATOR
// ESTIMATOR
CaptureMotionPtr
C
=
std
::
make_shared
<
CaptureForceTorqueInertial
>
(
t
,
S
,
data
,
data_cov
,
nullptr
);
CaptureMotionPtr
C
=
std
::
make_shared
<
CaptureForceTorqueInertial
>
(
t
,
S
,
data
_fti
,
S
->
getNoiseCov
()
,
nullptr
);
C
->
process
();
C
->
process
();
// results printed in the csv in the order established before
// results printed in the csv in the order established before
...
@@ -396,8 +392,8 @@ TEST_F(Test_SimulationProblemForceTorqueInertialDynamics_yaml, simulation_online
...
@@ -396,8 +392,8 @@ TEST_F(Test_SimulationProblemForceTorqueInertialDynamics_yaml, simulation_online
int
i_init
=
0
;
int
i_init
=
0
;
// Pose
// Pose
pose
<<
position
[
i_init
]
,
quaternion
[
i_init
].
coeffs
();
data_
pose
<<
position
[
i_init
]
,
quaternion
[
i_init
].
coeffs
();
CaptureBasePtr
CP
=
std
::
make_shared
<
CapturePose
>
(
time_stamp
[
i_init
],
SP
,
pose
,
SP
->
getNoiseCov
());
CaptureBasePtr
CP
=
std
::
make_shared
<
CapturePose
>
(
time_stamp
[
i_init
],
SP
,
data_
pose
,
SP
->
getNoiseCov
());
CP
->
process
();
CP
->
process
();
unsigned
int
last_kf_id
=
p
->
getOrigin
()
->
getFrame
()
->
id
();
unsigned
int
last_kf_id
=
p
->
getOrigin
()
->
getFrame
()
->
id
();
...
@@ -409,21 +405,15 @@ TEST_F(Test_SimulationProblemForceTorqueInertialDynamics_yaml, simulation_online
...
@@ -409,21 +405,15 @@ TEST_F(Test_SimulationProblemForceTorqueInertialDynamics_yaml, simulation_online
TimeStamp
t
=
time_stamp
[
i
];
TimeStamp
t
=
time_stamp
[
i
];
// Data
// Data
VectorXd
data
=
VectorXd
::
Zero
(
12
);
// [ a, w, f, t ]
data_fti
<<
a_meas
[
i
],
vang
[
i
],
force
[
i
],
torque
[
i
];
data
.
segment
<
3
>
(
0
)
=
a_meas
[
i
];
data_pose
<<
position
[
i
]
,
quaternion
[
i
].
coeffs
();
data
.
segment
<
3
>
(
3
)
=
vang
[
i
];
data
.
segment
<
3
>
(
6
)
=
force
[
i
];
data
.
segment
<
3
>
(
9
)
=
torque
[
i
];
MatrixXd
data_cov
=
S
->
getNoiseCov
();
pose
<<
position
[
i
]
,
quaternion
[
i
].
coeffs
();
// ESTIMATOR
// ESTIMATOR
CaptureMotionPtr
C
=
std
::
make_shared
<
CaptureForceTorqueInertial
>
(
t
,
S
,
data
,
data_cov
,
nullptr
);
CaptureMotionPtr
C
=
std
::
make_shared
<
CaptureForceTorqueInertial
>
(
t
,
S
,
data
_fti
,
S
->
getNoiseCov
()
,
nullptr
);
C
->
process
();
C
->
process
();
CaptureBasePtr
CP
=
std
::
make_shared
<
CapturePose
>
(
t
,
SP
,
pose
,
SP
->
getNoiseCov
());
CaptureBasePtr
CP
=
std
::
make_shared
<
CapturePose
>
(
t
,
SP
,
data_
pose
,
SP
->
getNoiseCov
());
CP
->
process
();
CP
->
process
();
// check if new KF and solve
// check if new KF and solve
...
@@ -506,12 +496,12 @@ TEST_F(Test_SimulationProblemForceTorqueInertialDynamics_yaml, simulation_batch)
...
@@ -506,12 +496,12 @@ TEST_F(Test_SimulationProblemForceTorqueInertialDynamics_yaml, simulation_batch)
// Force FTI processor to make a KF at t=0
// Force FTI processor to make a KF at t=0
CaptureMotionPtr
C0
=
CaptureMotionPtr
C0
=
std
::
make_shared
<
CaptureForceTorqueInertial
>
(
0
,
S
,
VectorXd
::
Zero
(
12
),
MatrixXd
::
Identity
(
12
,
12
),
nullptr
);
std
::
make_shared
<
CaptureForceTorqueInertial
>
(
0
,
S
,
VectorXd
::
Zero
(
12
),
S
->
getNoiseCov
(
),
nullptr
);
C0
->
process
();
C0
->
process
();
// Pose
// Pose
pose
<<
position
[
i_init
]
,
quaternion
[
i_init
].
coeffs
();
data_
pose
<<
position
[
i_init
]
,
quaternion
[
i_init
].
coeffs
();
CaptureBasePtr
CP
=
std
::
make_shared
<
CapturePose
>
(
time_stamp
[
i_init
],
SP
,
pose
,
SP
->
getNoiseCov
());
CaptureBasePtr
CP
=
std
::
make_shared
<
CapturePose
>
(
time_stamp
[
i_init
],
SP
,
data_
pose
,
SP
->
getNoiseCov
());
CP
->
process
();
CP
->
process
();
for
(
int
i
=
i_init
+
1
;
i
<
time_stamp
.
size
();
i
++
)
// start with second data
for
(
int
i
=
i_init
+
1
;
i
<
time_stamp
.
size
();
i
++
)
// start with second data
...
@@ -520,23 +510,17 @@ TEST_F(Test_SimulationProblemForceTorqueInertialDynamics_yaml, simulation_batch)
...
@@ -520,23 +510,17 @@ TEST_F(Test_SimulationProblemForceTorqueInertialDynamics_yaml, simulation_batch)
TimeStamp
t
=
time_stamp
[
i
];
TimeStamp
t
=
time_stamp
[
i
];
// Data
// Data
VectorXd
data
=
VectorXd
::
Zero
(
12
);
// [ a, w, f, t ]
data_fti
<<
a_meas
[
i
],
vang
[
i
],
force
[
i
],
torque
[
i
];
data
.
segment
<
3
>
(
0
)
=
a_meas
[
i
];
data_pose
<<
position
[
i
]
,
quaternion
[
i
].
coeffs
();
data
.
segment
<
3
>
(
3
)
=
vang
[
i
];
data
.
segment
<
3
>
(
6
)
=
force
[
i
];
data
.
segment
<
3
>
(
9
)
=
torque
[
i
];
MatrixXd
data_cov
=
S
->
getNoiseCov
();
pose
<<
position
[
i
]
,
quaternion
[
i
].
coeffs
();
// ESTIMATOR
// ESTIMATOR
//
FTI
//
fti
CaptureMotionPtr
C
=
std
::
make_shared
<
CaptureForceTorqueInertial
>
(
t
,
S
,
data
,
data_cov
,
nullptr
);
CaptureMotionPtr
C
=
std
::
make_shared
<
CaptureForceTorqueInertial
>
(
t
,
S
,
data
_fti
,
S
->
getNoiseCov
()
,
nullptr
);
C
->
process
();
C
->
process
();
// Pose
// Pose
CaptureBasePtr
CP
=
std
::
make_shared
<
CapturePose
>
(
t
,
SP
,
pose
,
SP
->
getNoiseCov
());
CaptureBasePtr
CP
=
std
::
make_shared
<
CapturePose
>
(
t
,
SP
,
data_
pose
,
SP
->
getNoiseCov
());
CP
->
process
();
CP
->
process
();
}
}
...
...
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