Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
wolf
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
wolf
Commits
b2b71afd
Commit
b2b71afd
authored
8 years ago
by
Dinesh Atchuthan
Browse files
Options
Downloads
Patches
Plain Diff
fixture design
parent
25ba50f8
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/test/gtest_processor_imu.cpp
+65
-12
65 additions, 12 deletions
src/test/gtest_processor_imu.cpp
with
65 additions
and
12 deletions
src/test/gtest_processor_imu.cpp
+
65
−
12
View file @
b2b71afd
...
@@ -18,7 +18,60 @@
...
@@ -18,7 +18,60 @@
#include
<iostream>
#include
<iostream>
using
namespace
wolf
;
class
ProcessorIMU
:
public
testing
::
Test
{
public:
wolf
::
ProblemPtr
problem
;
wolf
::
SensorBasePtr
sensor_ptr
;
wolf
::
TimeStamp
t
;
wolf
::
Scalar
mti_clock
,
tmp
;
Eigen
::
Vector6s
data
;
Eigen
::
Matrix6s
data_cov
;
Eigen
::
VectorXs
x0
;
std
::
shared_ptr
<
wolf
::
CaptureIMU
>
cap_imu_ptr
;
virtual
void
SetUp
()
{
using
namespace
wolf
;
using
namespace
Eigen
;
using
std
::
shared_ptr
;
using
std
::
make_shared
;
using
std
::
static_pointer_cast
;
using
namespace
wolf
::
Constants
;
// Wolf problem
problem
=
Problem
::
create
(
FRM_PQVBB_3D
);
Vector7s
extrinsics
=
(
Vector7s
()
<<
1
,
0
,
0
,
0
,
0
,
0
,
1
).
finished
();
sensor_ptr
=
problem
->
installSensor
(
"IMU"
,
"Main IMU"
,
extrinsics
,
shared_ptr
<
IntrinsicsBase
>
());
ProcessorBasePtr
processor_ptr
=
problem
->
installProcessor
(
"IMU"
,
"IMU pre-integrator"
,
"Main IMU"
,
""
);
// Time and data variables
data
=
Vector6s
::
Zero
();
data_cov
=
Matrix6s
::
Identity
();
// Set the origin
x0
.
resize
(
16
);
// Create one capture to store the IMU data arriving from (sensor / callback / file / etc.)
cap_imu_ptr
=
make_shared
<
CaptureIMU
>
(
t
,
sensor_ptr
,
data
);
}
virtual
void
TearDown
()
{
// code here will be called just after the test completes
// ok to through exceptions from here if need be
/*
You can do deallocation of resources in TearDown or the destructor routine.
However, if you want exception handling you must do it only in the TearDown code because throwing an exception
from the destructor results in undefined behavior.
The Google assertion macros may throw exceptions in platforms where they are enabled in future releases.
Therefore, it's a good idea to use assertion macros in the TearDown code for better maintenance.
*/
}
};
/*using namespace wolf;
using namespace Eigen;
using namespace Eigen;
using std::shared_ptr;
using std::shared_ptr;
using std::make_shared;
using std::make_shared;
...
@@ -44,10 +97,10 @@ VectorXs x0(16);
...
@@ -44,10 +97,10 @@ VectorXs x0(16);
// Create one capture to store the IMU data arriving from (sensor / callback / file / etc.)
// Create one capture to store the IMU data arriving from (sensor / callback / file / etc.)
shared_ptr<CaptureIMU> cap_imu_ptr = make_shared<CaptureIMU>(t, sensor_ptr, data);
shared_ptr<CaptureIMU> cap_imu_ptr = make_shared<CaptureIMU>(t, sensor_ptr, data);
*/
TEST_F
(
ProcessorIMU
,
acc_x
)
TEST
(
ProcessorIMU
,
acc_x
)
{
{
t
.
set
(
0
);
// clock in 0,1 ms ticks
t
.
set
(
0
);
// clock in 0,1 ms ticks
x0
<<
0
,
0
,
0
,
0
,
0
,
0
,
1
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
;
// Try some non-zero biases
x0
<<
0
,
0
,
0
,
0
,
0
,
0
,
1
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
;
// Try some non-zero biases
...
@@ -61,13 +114,13 @@ TEST(ProcessorIMU, acc_x)
...
@@ -61,13 +114,13 @@ TEST(ProcessorIMU, acc_x)
sensor_ptr
->
process
(
cap_imu_ptr
);
sensor_ptr
->
process
(
cap_imu_ptr
);
// Expected state after one integration
// Expected state after one integration
VectorXs
x
(
16
);
Eigen
::
VectorXs
x
(
16
);
x
<<
0.01
,
0
,
0
,
0
,
0
,
0
,
1
,
0.2
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
;
// advanced at a=2m/s2 during 0.1s ==> dx = 0.5*2*0.1^2 = 0.01; dvx = 2*0.1 = 0.2
x
<<
0.01
,
0
,
0
,
0
,
0
,
0
,
1
,
0.2
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
;
// advanced at a=2m/s2 during 0.1s ==> dx = 0.5*2*0.1^2 = 0.01; dvx = 2*0.1 = 0.2
ASSERT_TRUE
((
problem
->
getCurrentState
()
-
x
).
isMuchSmallerThan
(
1
,
EPS_SMALL
));
ASSERT_TRUE
((
problem
->
getCurrentState
()
-
x
).
isMuchSmallerThan
(
1
,
wolf
::
Constants
::
EPS_SMALL
));
}
}
TEST
(
ProcessorIMU
,
acc_y
)
TEST
_F
(
ProcessorIMU
,
acc_y
)
{
{
t
.
set
(
0
);
// clock in 0,1 ms ticks
t
.
set
(
0
);
// clock in 0,1 ms ticks
x0
<<
0
,
0
,
0
,
0
,
0
,
0
,
1
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
;
// Try some non-zero biases
x0
<<
0
,
0
,
0
,
0
,
0
,
0
,
1
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
;
// Try some non-zero biases
...
@@ -81,13 +134,13 @@ TEST(ProcessorIMU, acc_y)
...
@@ -81,13 +134,13 @@ TEST(ProcessorIMU, acc_y)
sensor_ptr
->
process
(
cap_imu_ptr
);
sensor_ptr
->
process
(
cap_imu_ptr
);
// Expected state after one integration
// Expected state after one integration
VectorXs
x
(
16
);
Eigen
::
VectorXs
x
(
16
);
x
<<
0
,
0.00001
,
0
,
0
,
0
,
0
,
1
,
0
,
0.02
,
0
,
0
,
0
,
0
,
0
,
0
,
0
;
// advanced at a=20m/s2 during 0.001s ==> dx = 0.5*20*0.001^2 = 0.00001; dvx = 20*0.001 = 0.02
x
<<
0
,
0.00001
,
0
,
0
,
0
,
0
,
1
,
0
,
0.02
,
0
,
0
,
0
,
0
,
0
,
0
,
0
;
// advanced at a=20m/s2 during 0.001s ==> dx = 0.5*20*0.001^2 = 0.00001; dvx = 20*0.001 = 0.02
ASSERT_TRUE
((
problem
->
getCurrentState
()
-
x
).
isMuchSmallerThan
(
1
,
EPS_SMALL
));
ASSERT_TRUE
((
problem
->
getCurrentState
()
-
x
).
isMuchSmallerThan
(
1
,
wolf
::
Constants
::
EPS_SMALL
));
}
}
TEST
(
ProcessorIMU
,
acc_z
)
TEST
_F
(
ProcessorIMU
,
acc_z
)
{
{
t
.
set
(
0
);
// clock in 0,1 ms ticks
t
.
set
(
0
);
// clock in 0,1 ms ticks
x0
<<
0
,
0
,
0
,
0
,
0
,
0
,
1
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
;
// Try some non-zero biases
x0
<<
0
,
0
,
0
,
0
,
0
,
0
,
1
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
;
// Try some non-zero biases
...
@@ -101,13 +154,13 @@ TEST(ProcessorIMU, acc_z)
...
@@ -101,13 +154,13 @@ TEST(ProcessorIMU, acc_z)
sensor_ptr
->
process
(
cap_imu_ptr
);
sensor_ptr
->
process
(
cap_imu_ptr
);
// Expected state after one integration
// Expected state after one integration
VectorXs
x
(
16
);
Eigen
::
VectorXs
x
(
16
);
x
<<
0
,
0
,
0.01
,
0
,
0
,
0
,
1
,
0
,
0
,
0.2
,
0
,
0
,
0
,
0
,
0
,
0
;
// advanced at a=2m/s2 during 0.1s ==> dz = 0.5*2*0.1^2 = 0.01; dvz = 2*0.1 = 0.2
x
<<
0
,
0
,
0.01
,
0
,
0
,
0
,
1
,
0
,
0
,
0.2
,
0
,
0
,
0
,
0
,
0
,
0
;
// advanced at a=2m/s2 during 0.1s ==> dz = 0.5*2*0.1^2 = 0.01; dvz = 2*0.1 = 0.2
ASSERT_TRUE
((
problem
->
getCurrentState
()
-
x
).
isMuchSmallerThan
(
1
,
EPS_SMALL
));
ASSERT_TRUE
((
problem
->
getCurrentState
()
-
x
).
isMuchSmallerThan
(
1
,
wolf
::
Constants
::
EPS_SMALL
));
}
}
TEST
(
ProcessorIMU
,
Covariances
)
TEST
_F
(
ProcessorIMU
,
Covariances
)
{
{
data_cov
.
topLeftCorner
(
3
,
3
)
*=
0.01
;
// acc variance
data_cov
.
topLeftCorner
(
3
,
3
)
*=
0.01
;
// acc variance
data_cov
.
bottomRightCorner
(
3
,
3
)
*=
0.01
;
// gyro variance
data_cov
.
bottomRightCorner
(
3
,
3
)
*=
0.01
;
// gyro variance
...
...
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