ConditionCheckMagnitudeChecks.cpp
Go to the documentation of this file.
1/*
2 * This file is part of ArmarX.
3 *
4 * Copyright (C) 2011-2016, High Performance Humanoid Technologies (H2T), Karlsruhe Institute of Technology (KIT), all rights reserved.
5 *
6 * ArmarX is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 * ArmarX is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 *
18 * @package
19 * @author
20 * @date
21 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
22 * GNU General Public License
23 */
25
27
28namespace armarx
29{
30
40
46
47 bool
49 {
50
51 if (dataFields.size() != 1)
52 {
53 throw InvalidConditionException(
54 "Wrong number of datafields for condition magnitude larger: expected 1 actual: " +
55 ValueToString(dataFields.size()));
56 }
57
58 const Variant& value = dataFields.begin()->second;
59 VariantTypeId type = value.getType();
60
61 if (type == VariantType::Vector3)
62 {
63 Eigen::Vector3f vec = value.getClass<Vector3>()->toEigen();
64 return (vec).norm() > getParameter(0).getFloat();
65 }
66
68 {
69 FramedDirectionPtr fV1 = value.getClass<FramedDirection>();
70 Eigen::Vector3f vec = value.getClass<FramedDirection>()->toEigen();
71 return (vec).norm() > getParameter(0).getFloat();
72 }
73
75 {
76 LinkedDirectionPtr lV1 = value.getClass<LinkedDirection>();
77
78 Eigen::Vector3f vec = value.getClass<LinkedDirection>()->toEigen();
79 return (vec).norm() > getParameter(0).getFloat();
80 }
81
82 return false;
83 }
84
94
100
101 bool
103 {
104
105 if (dataFields.size() != 1)
106 {
107 ARMARX_WARNING_S << "Size of dataFields: %d\n" << dataFields.size();
108 throw InvalidConditionException("Wrong number of datafields for condition equals ");
109 }
110
111 const Variant& value = dataFields.begin()->second;
112 VariantTypeId type = value.getType();
113
114 if (type == VariantType::Vector3)
115 {
116 Eigen::Vector3f vec = value.getClass<Vector3>()->toEigen();
117 return (vec).norm() < getParameter(0).getFloat();
118 }
119
121 {
122 // FramedDirectionPtr fV1 = value.getClass<FramedDirection>();
123 Eigen::Vector3f vec = value.getClass<FramedDirection>()->toEigen();
124 return (vec).norm() < getParameter(0).getFloat();
125 }
126
128 {
129 // LinkedDirectionPtr lV1 = value.getClass<LinkedDirection>();
130 Eigen::Vector3f vec = value.getClass<LinkedDirection>()->toEigen();
131 return (vec).norm() < getParameter(0).getFloat();
132 }
133
134 return false;
135 }
136
147
153
154 bool
156 {
157 if (dataFields.size() != 1)
158 {
159 ARMARX_WARNING_S << "Size of dataFields: " << dataFields.size();
160 throw InvalidConditionException("Wrong number of datafields for condition InRange ");
161 }
162
163 const Variant& value = dataFields.begin()->second;
164 VariantTypeId type = value.getType();
165
166 if (type == VariantType::Vector3)
167 {
168 Eigen::Vector3f vec = value.getClass<Vector3>()->toEigen();
169 return ((vec).norm() > getParameter(0).getFloat()) &&
170 ((vec).norm() < getParameter(1).getFloat());
171 }
172
174 {
175 // FramedDirectionPtr fV1 = value.getClass<FramedDirection>();
176 Eigen::Vector3f vec = value.getClass<FramedDirection>()->toEigen();
177 return ((vec).norm() > getParameter(0).getFloat()) &&
178 ((vec).norm() < getParameter(1).getFloat());
179 }
180
182 {
183 // LinkedDirectionPtr lV1 = value.getClass<LinkedDirection>();
184 Eigen::Vector3f vec = value.getClass<LinkedDirection>()->toEigen();
185 return ((vec).norm() > getParameter(0).getFloat()) &&
186 ((vec).norm() < getParameter(1).getFloat());
187 }
188
189 return false;
190 }
191
192} // namespace armarx
ConditionCheck * clone() override
Clones the current check.
bool evaluate(const StringVariantMap &dataFields) override
Evaluate the condition based on the current data field values.
ConditionCheck * clone() override
Clones the current check.
bool evaluate(const StringVariantMap &dataFields) override
Evaluate the condition based on the current data field values.
ConditionCheck * clone() override
Clones the current check.
bool evaluate(const StringVariantMap &dataFields) override
Evaluate the condition based on the current data field values.
A ConditionCheck implements a check on the sensor data stream of a Sensor-Actor Unit.
static ParameterTypeList createParameterTypeList(int numberTypes,...)
void setNumberParameters(int numberParameters)
Sets the number of paramaters required for this check.
const Variant & getParameter(int index)
Retrieve parameters of check.
void addSupportedType(VariantTypeId dataFieldType=0, ParameterTypeList parameterTypes=ParameterTypeList())
Add a supported type for elementary condition check marks pairs of (dataFieldType,...
FramedDirection is a 3 dimensional direction vector with a reference frame.
Definition FramedPose.h:87
direction vector (NOT a position vector) with an attached robotstate proxy for frame changes.
Definition LinkedPose.h:119
The Variant class is described here: Variants.
Definition Variant.h:224
float getFloat(const Ice::Current &c=Ice::emptyCurrent) const override
Return the Variant's value as float.
Definition Variant.cpp:532
The Vector3 class.
Definition Pose.h:113
#define ARMARX_WARNING_S
The logging level for unexpected behaviour, but not a serious problem.
Definition Logging.h:213
const VariantTypeId FramedDirection
Definition FramedPose.h:37
const VariantTypeId LinkedDirection
Definition LinkedPose.h:44
const VariantTypeId Vector3
Definition Pose.h:38
const VariantTypeId Float
Definition Variant.h:919
This file offers overloads of toIce() and fromIce() functions for STL container types.
IceInternal::Handle< FramedDirection > FramedDirectionPtr
Definition FramedPose.h:84
Ice::Int VariantTypeId
Definition Variant.h:43
std::map< std::string, Variant > StringVariantMap
Definition Variant.h:748
Eigen::Vector3f toEigen(const pcl::PointXYZ &pt)
IceInternal::Handle< LinkedDirection > LinkedDirectionPtr
Definition LinkedPose.h:181
std::string ValueToString(const T &value)
double norm(const Point &a)
Definition point.hpp:102