corelib
src
IMUFilter.cpp
Go to the documentation of this file.
1
/*
2
Copyright (c) 2010-2019, Mathieu Labbe - IntRoLab - Universite de Sherbrooke
3
All rights reserved.
4
5
Redistribution and use in source and binary forms, with or without
6
modification, are permitted provided that the following conditions are met:
7
* Redistributions of source code must retain the above copyright
8
notice, this list of conditions and the following disclaimer.
9
* Redistributions in binary form must reproduce the above copyright
10
notice, this list of conditions and the following disclaimer in the
11
documentation and/or other materials provided with the distribution.
12
* Neither the name of the Universite de Sherbrooke nor the
13
names of its contributors may be used to endorse or promote products
14
derived from this software without specific prior written permission.
15
16
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
20
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26
*/
27
28
29
#include <
rtabmap/core/IMUFilter.h
>
30
#include <
rtabmap/utilite/ULogger.h
>
31
#include "
imufilter/ComplementaryFilter.h
"
32
#ifdef RTABMAP_MADGWICK
33
#include "
imufilter/MadgwickFilter.h
"
34
#endif
35
36
namespace
rtabmap
{
37
38
IMUFilter
*
IMUFilter::create
(
const
ParametersMap
& parameters)
39
{
40
int
type
= Parameters::defaultKpDetectorStrategy();
41
Parameters::parse
(parameters, Parameters::kKpDetectorStrategy(),
type
);
42
return
create
((
IMUFilter::Type
)
type
, parameters);
43
}
44
45
IMUFilter
*
IMUFilter::create
(
IMUFilter::Type
type
,
const
ParametersMap
& parameters)
46
{
47
#ifndef RTABMAP_MADGWICK
48
if
(
type
==
IMUFilter::kMadgwick
)
49
{
50
UWARN
(
"Madgwick filter cannot be used as RTAB-Map is not built with the option enabled. Complementary filter is used instead."
);
51
type
=
IMUFilter::kComplementaryFilter
;
52
}
53
#endif
54
55
IMUFilter
* filter = 0;
56
switch
(
type
)
57
{
58
#ifdef RTABMAP_MADGWICK
59
case
IMUFilter::kMadgwick
:
60
filter =
new
MadgwickFilter
(parameters);
61
break
;
62
#endif
63
default
:
64
filter =
new
ComplementaryFilter
(parameters);
65
type
=
IMUFilter::kComplementaryFilter
;
66
break
;
67
68
}
69
return
filter;
70
}
71
72
void
IMUFilter::update
(
73
double
gx,
double
gy,
double
gz,
74
double
ax,
double
ay,
double
az,
75
double
stamp)
76
{
77
if
(
previousStamp_
== 0.0)
78
{
79
previousStamp_
= stamp;
80
}
81
double
dt
= stamp -
previousStamp_
;
82
83
updateImpl
(gx, gy, gz, ax, ay, az,
dt
);
84
85
previousStamp_
= stamp;
86
}
87
88
}
MadgwickFilter.h
dt
const double dt
type
rtabmap::ComplementaryFilter
Definition:
ComplementaryFilter.h:37
rtabmap::ParametersMap
std::map< std::string, std::string > ParametersMap
Definition:
Parameters.h:43
rtabmap::IMUFilter::create
static IMUFilter * create(const ParametersMap ¶meters=ParametersMap())
Definition:
IMUFilter.cpp:38
rtabmap::IMUFilter::update
void update(double gx, double gy, double gz, double ax, double ay, double az, double stamp)
Definition:
IMUFilter.cpp:72
rtabmap::IMUFilter::kMadgwick
@ kMadgwick
Definition:
IMUFilter.h:41
rtabmap::IMUFilter::Type
Type
Definition:
IMUFilter.h:40
rtabmap::Parameters::parse
static bool parse(const ParametersMap ¶meters, const std::string &key, bool &value)
Definition:
Parameters.cpp:500
rtabmap::IMUFilter
Definition:
IMUFilter.h:37
rtabmap::IMUFilter::kComplementaryFilter
@ kComplementaryFilter
Definition:
IMUFilter.h:42
rtabmap::IMUFilter::updateImpl
virtual void updateImpl(double gx, double gy, double gz, double ax, double ay, double az, double dt)=0
UWARN
#define UWARN(...)
ULogger.h
ULogger class and convenient macros.
rtabmap::MadgwickFilter
Definition:
MadgwickFilter.h:34
IMUFilter.h
ComplementaryFilter.h
rtabmap
Definition:
CameraARCore.cpp:35
rtabmap::IMUFilter::previousStamp_
double previousStamp_
Definition:
IMUFilter.h:74
rtabmap
Author(s): Mathieu Labbe
autogenerated on Thu Jul 25 2024 02:50:11