Main Page
Namespaces
Classes
Files
File List
src
MathExpressionFilter.cpp
Go to the documentation of this file.
1
/*
2
* MathExpressionFilter.cpp
3
*
4
* Created on: Aug 16, 2017
5
* Author: Peter Fankhauser
6
* Institute: ETH Zurich, ANYbotics
7
*/
8
9
#include "
grid_map_filters/MathExpressionFilter.hpp
"
10
11
#include <
grid_map_core/grid_map_core.hpp
>
12
#include <
pluginlib/class_list_macros.h
>
13
14
using namespace
filters
;
15
16
namespace
grid_map
{
17
18
template
<
typename
T>
19
MathExpressionFilter<T>::MathExpressionFilter
()
20
{
21
}
22
23
template
<
typename
T>
24
MathExpressionFilter<T>::~MathExpressionFilter
()
25
{
26
}
27
28
template
<
typename
T>
29
bool
MathExpressionFilter<T>::configure
()
30
{
31
if
(!
FilterBase<T>::getParam
(std::string(
"expression"
), expression_)) {
32
ROS_ERROR
(
"MathExpressionFilter did not find parameter 'expression'."
);
33
return
false
;
34
}
35
36
if
(!
FilterBase<T>::getParam
(std::string(
"output_layer"
), outputLayer_)) {
37
ROS_ERROR
(
"MathExpressionFilter did not find parameter 'output_layer'."
);
38
return
false
;
39
}
40
41
// TODO Can we make caching work with changing shared variable?
42
// parser_.setCacheExpressions(true);
43
return
true
;
44
}
45
46
template
<
typename
T>
47
bool
MathExpressionFilter<T>::update
(
const
T& mapIn, T& mapOut)
48
{
49
mapOut = mapIn;
50
for
(
const
auto
& layer : mapOut.getLayers()) {
51
parser_.var(layer).setShared(mapOut[layer]);
52
}
53
EigenLab::Value<Eigen::MatrixXf>
result(parser_.eval(expression_));
54
mapOut.add(outputLayer_, result.matrix());
55
return
true
;
56
}
57
58
}
/* namespace */
59
60
PLUGINLIB_EXPORT_CLASS
(
grid_map::MathExpressionFilter<grid_map::GridMap>
,
filters::FilterBase<grid_map::GridMap>
)
grid_map::MathExpressionFilter
Definition:
MathExpressionFilter.hpp:23
filters::FilterBase
grid_map_core.hpp
MathExpressionFilter.hpp
EigenLab::Value
Definition:
EigenLab.h:50
grid_map
class_list_macros.h
filters
PLUGINLIB_EXPORT_CLASS
#define PLUGINLIB_EXPORT_CLASS(class_type, base_class_type)
ROS_ERROR
#define ROS_ERROR(...)
grid_map_filters
Author(s): Péter Fankhauser
, Martin Wermelinger
autogenerated on Tue Jun 25 2019 20:02:22