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 
27 
28 #include <RobotAPI/interface/core/RobotLocalization.h>
29 #include <RobotAPI/interface/observers/PlatformUnitObserverInterface.h>
30 #include <ArmarXCore/interface/observers/VariantBase.h>
31 
35 
36 #include <string>
37 
38 namespace armarx
39 {
40  ARMARX_CREATE_CHECK(PlatformUnitObserver, equals)
41  ARMARX_CREATE_CHECK(PlatformUnitObserver, larger)
42  ARMARX_CREATE_CHECK(PlatformUnitObserver, inrange)
43 
44  /**
45  * \class PlatformUnitPropertyDefinitions
46  * \brief Defines all necessary properties for armarx::PlatformUnit
47  */
50  {
51  public:
54  {
55  defineOptionalProperty<std::string>("PlatformName", "Platform", "Name of the platform (will publish values on PlatformName + 'State')");
56  }
57  };
58 
59  /**
60  * \class PlatformUnitObserver
61  * \ingroup RobotAPI-SensorActorUnits-observers
62  * \brief Observer monitoring platform-related sensor values.
63  *
64  * The PlatformUnitObserver allows the installation of conditions on all channel reported by the PlatformUnit.
65  * These include current and target position.
66  *
67  * The PlatformUnitObserver retrieves its platform configuration via properties.
68  * The name must exist in the used Simox robot model file.
69  *
70  * Available condition checks are: *valid*, *updated*, *equals*, *inrange*, *approx*, *larger* and *smaller*.
71  */
73  virtual public Observer,
74  virtual public PlatformUnitObserverInterface
75  {
76  public:
77  // framework hooks
78  void onInitObserver() override;
79  void onConnectObserver() override;
80 
81  // slice interface implementation
82  void reportPlatformVelocity(::Ice::Float currentPlatformVelocityX, ::Ice::Float currentPlatformVelocityY, ::Ice::Float currentPlatformVelocityRotation, const Ice::Current& c = Ice::emptyCurrent) override;
83  void reportPlatformOdometryPose(Ice::Float x, Ice::Float y, Ice::Float angle, const Ice::Current&) override;
84 
85  // slice interface implementation
86  void reportGlobalRobotPose(const ::armarx::TransformStamped&, const ::Ice::Current& = ::Ice::emptyCurrent) override;
87 
88 
89  std::string getDefaultName() const override
90  {
91  return "PlatformUnitObserver";
92  }
93 
94  /**
95  * \see PropertyUser::createPropertyDefinitions()
96  */
97  PropertyDefinitionsPtr createPropertyDefinitions() override;
98 
99  protected:
100  void nameValueMapToDataFields(std::string channelName, ::Ice::Float platformPositionX, ::Ice::Float platformPositionY, ::Ice::Float platformRotation);
101 
102  private:
103  std::string platformNodeName;
104 
105  };
106 
107  /**
108  * \class PlatformUnitDatafieldCreator
109  * \brief
110  * \ingroup RobotAPI-SensorActorUnits-util
111  */
113  {
114  public:
115  PlatformUnitDatafieldCreator(const std::string& channelName) :
116  channelName(channelName)
117  {}
118 
119  /**
120  * \brief Function to create a Channel Representation for a PlatformUnitObserver
121  * \param platformUnitOberserverName Name of the PlatformUnitObserver
122  * \param platformName Name of the platform of the robot like it is specified
123  * in the simox-robot-xml-file
124  * \return returns a ChannelRepresentationPtr
125  */
126  DataFieldIdentifier getDatafield(const std::string& platformUnitObserverName, const std::string& platformName) const
127  {
128  if (platformUnitObserverName.empty())
129  {
130  throw LocalException("kinematicUnitObserverName must not be empty!");
131  }
132 
133  if (platformName.empty())
134  {
135  throw LocalException("jointName must not be empty!");
136  }
137 
138  return DataFieldIdentifier(platformUnitObserverName, channelName, platformName);
139  }
140 
141  private:
142  std::string channelName;
143  };
144 }
145 
147 {
148  const PlatformUnitDatafieldCreator platformPose("platformPose");
149  const PlatformUnitDatafieldCreator platformVelocity("platformVelocity");
150 }
armarx::channels::PlatformUnitObserver::platformVelocity
const PlatformUnitDatafieldCreator platformVelocity("platformVelocity")
armarx::VariantType::Float
const VariantTypeId Float
Definition: Variant.h:918
armarx::Observer
Baseclass for all ArmarX Observers.
Definition: Observer.h:80
armarx::PlatformUnitObserverPropertyDefinitions
Definition: PlatformUnitObserver.h:48
c
constexpr T c
Definition: UnscentedKalmanFilterTest.cpp:43
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:126
armarx::channels::PlatformUnitObserver
Definition: PlatformUnitObserver.h:146
ARMARX_CREATE_CHECK
#define ARMARX_CREATE_CHECK(OFFERER, NEWCHECK)
Definition: ConditionCheck.h:205
Component.h
armarx::PlatformUnitObserver
Observer monitoring platform-related sensor values.
Definition: PlatformUnitObserver.h:72
armarx::channels::PlatformUnitObserver::platformPose
const PlatformUnitDatafieldCreator platformPose("platformPose")
IceUtil::Handle
Definition: forward_declarations.h:29
ImportExport.h
angle
double angle(const Point &a, const Point &b, const Point &c)
Definition: point.hpp:100
ConditionCheck.h
ARMARXCORE_IMPORT_EXPORT
#define ARMARXCORE_IMPORT_EXPORT
Definition: ImportExport.h:38
armarx::PlatformUnitDatafieldCreator::PlatformUnitDatafieldCreator
PlatformUnitDatafieldCreator(const std::string &channelName)
Definition: PlatformUnitObserver.h:115
armarx::ObserverPropertyDefinitions
Definition: Observer.h:50
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28
armarx::PlatformUnitDatafieldCreator
Definition: PlatformUnitObserver.h:112
armarx::PlatformUnitObserverPropertyDefinitions::PlatformUnitObserverPropertyDefinitions
PlatformUnitObserverPropertyDefinitions(std::string prefix)
Definition: PlatformUnitObserver.h:52
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:89