PlatformUnitObserver.h
Go to the documentation of this file.
1 /*
2 * This file is part of ArmarX.
3 *
4 * ArmarX is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 *
8 * ArmarX is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * @package ArmarX::Core
17 * @author Kai Welke (welke _at_ kit _dot_ edu)
18 * @date 2011 Kai Welke
19 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
20 * GNU General Public License
21 */
22 
23 #pragma once
24 
25 #include <string>
26 
29 #include <ArmarXCore/interface/observers/VariantBase.h>
33 
34 #include <RobotAPI/interface/core/RobotLocalization.h>
35 #include <RobotAPI/interface/observers/PlatformUnitObserverInterface.h>
36 
37 namespace armarx
38 {
39  ARMARX_CREATE_CHECK(PlatformUnitObserver, equals)
40  ARMARX_CREATE_CHECK(PlatformUnitObserver, larger)
41  ARMARX_CREATE_CHECK(PlatformUnitObserver, inrange)
42 
43  /**
44  * \class PlatformUnitPropertyDefinitions
45  * \brief Defines all necessary properties for armarx::PlatformUnit
46  */
48  {
49  public:
52  {
53  defineOptionalProperty<std::string>(
54  "PlatformName",
55  "Platform",
56  "Name of the platform (will publish values on PlatformName + 'State')");
57  }
58  };
59 
60  /**
61  * \class PlatformUnitObserver
62  * \ingroup RobotAPI-SensorActorUnits-observers
63  * \brief Observer monitoring platform-related sensor values.
64  *
65  * The PlatformUnitObserver allows the installation of conditions on all channel reported by the PlatformUnit.
66  * These include current and target position.
67  *
68  * The PlatformUnitObserver retrieves its platform configuration via properties.
69  * The name must exist in the used Simox robot model file.
70  *
71  * Available condition checks are: *valid*, *updated*, *equals*, *inrange*, *approx*, *larger* and *smaller*.
72  */
74  virtual public Observer,
75  virtual public PlatformUnitObserverInterface
76  {
77  public:
78  // framework hooks
79  void onInitObserver() override;
80  void onConnectObserver() override;
81 
82  // slice interface implementation
83  void reportPlatformVelocity(::Ice::Float currentPlatformVelocityX,
84  ::Ice::Float currentPlatformVelocityY,
85  ::Ice::Float currentPlatformVelocityRotation,
86  const Ice::Current& c = Ice::emptyCurrent) override;
87  void reportPlatformOdometryPose(Ice::Float x,
88  Ice::Float y,
90  const Ice::Current&) override;
91 
92  // slice interface implementation
93  void reportGlobalRobotPose(const ::armarx::TransformStamped&,
94  const ::Ice::Current& = ::Ice::emptyCurrent) override;
95 
96  std::string
97  getDefaultName() const override
98  {
99  return "PlatformUnitObserver";
100  }
101 
102  /**
103  * \see PropertyUser::createPropertyDefinitions()
104  */
105  PropertyDefinitionsPtr createPropertyDefinitions() override;
106 
107  protected:
108  void nameValueMapToDataFields(std::string channelName,
109  ::Ice::Float platformPositionX,
110  ::Ice::Float platformPositionY,
111  ::Ice::Float platformRotation);
112 
113  private:
114  std::string platformNodeName;
115  };
116 
117  /**
118  * \class PlatformUnitDatafieldCreator
119  * \brief
120  * \ingroup RobotAPI-SensorActorUnits-util
121  */
123  {
124  public:
125  PlatformUnitDatafieldCreator(const std::string& channelName) : channelName(channelName)
126  {
127  }
128 
129  /**
130  * \brief Function to create a Channel Representation for a PlatformUnitObserver
131  * \param platformUnitOberserverName Name of the PlatformUnitObserver
132  * \param platformName Name of the platform of the robot like it is specified
133  * in the simox-robot-xml-file
134  * \return returns a ChannelRepresentationPtr
135  */
137  getDatafield(const std::string& platformUnitObserverName,
138  const std::string& platformName) const
139  {
140  if (platformUnitObserverName.empty())
141  {
142  throw LocalException("kinematicUnitObserverName must not be empty!");
143  }
144 
145  if (platformName.empty())
146  {
147  throw LocalException("jointName must not be empty!");
148  }
149 
150  return DataFieldIdentifier(platformUnitObserverName, channelName, platformName);
151  }
152 
153  private:
154  std::string channelName;
155  };
156 } // namespace armarx
157 
159 {
160  const PlatformUnitDatafieldCreator platformPose("platformPose");
161  const PlatformUnitDatafieldCreator platformVelocity("platformVelocity");
162 } // namespace armarx::channels::PlatformUnitObserver
armarx::channels::PlatformUnitObserver::platformVelocity
const PlatformUnitDatafieldCreator platformVelocity("platformVelocity")
armarx::VariantType::Float
const VariantTypeId Float
Definition: Variant.h:919
armarx::Observer
Baseclass for all ArmarX Observers.
Definition: Observer.h:84
armarx::PlatformUnitObserverPropertyDefinitions
Definition: PlatformUnitObserver.h:47
c
constexpr T c
Definition: UnscentedKalmanFilterTest.cpp:46
Observer.h
ObserverObjectFactories.h
armarx::PlatformUnitDatafieldCreator::getDatafield
DataFieldIdentifier getDatafield(const std::string &platformUnitObserverName, const std::string &platformName) const
Function to create a Channel Representation for a PlatformUnitObserver.
Definition: PlatformUnitObserver.h:137
armarx::channels::PlatformUnitObserver
Definition: PlatformUnitObserver.h:158
ARMARX_CREATE_CHECK
#define ARMARX_CREATE_CHECK(OFFERER, NEWCHECK)
Definition: ConditionCheck.h:222
Component.h
armarx::PlatformUnitObserver
Observer monitoring platform-related sensor values.
Definition: PlatformUnitObserver.h:73
armarx::channels::PlatformUnitObserver::platformPose
const PlatformUnitDatafieldCreator platformPose("platformPose")
IceUtil::Handle
Definition: forward_declarations.h:30
ImportExport.h
angle
double angle(const Point &a, const Point &b, const Point &c)
Definition: point.hpp:109
ConditionCheck.h
ARMARXCORE_IMPORT_EXPORT
#define ARMARXCORE_IMPORT_EXPORT
Definition: ImportExport.h:38
armarx::PlatformUnitDatafieldCreator::PlatformUnitDatafieldCreator
PlatformUnitDatafieldCreator(const std::string &channelName)
Definition: PlatformUnitObserver.h:125
armarx::ObserverPropertyDefinitions
Definition: Observer.h:49
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:27
armarx::PlatformUnitDatafieldCreator
Definition: PlatformUnitObserver.h:122
armarx::PlatformUnitObserverPropertyDefinitions::PlatformUnitObserverPropertyDefinitions
PlatformUnitObserverPropertyDefinitions(std::string prefix)
Definition: PlatformUnitObserver.h:50
armarx::DataFieldIdentifier
DataFieldIdentifier provide the basis to identify data field within a distributed ArmarX scenario.
Definition: DataFieldIdentifier.h:48
armarx::PlatformUnitObserver::getDefaultName
std::string getDefaultName() const override
Retrieve default name of component.
Definition: PlatformUnitObserver.h:97