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
37namespace armarx
38{
42
43 /**
44 * \class PlatformUnitPropertyDefinitions
45 * \brief Defines all necessary properties for armarx::PlatformUnit
46 */
48 {
49 public:
52 {
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,
89 Ice::Float angle,
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{
162} // namespace armarx::channels::PlatformUnitObserver
#define ARMARX_CREATE_CHECK(OFFERER, NEWCHECK)
#define ARMARXCORE_IMPORT_EXPORT
constexpr T c
DataFieldIdentifier provide the basis to identify data field within a distributed ArmarX scenario.
ObserverPropertyDefinitions(std::string prefix)
Definition Observer.h:52
PlatformUnitDatafieldCreator(const std::string &channelName)
DataFieldIdentifier getDatafield(const std::string &platformUnitObserverName, const std::string &platformName) const
Function to create a Channel Representation for a PlatformUnitObserver.
Observer monitoring platform-related sensor values.
void reportPlatformOdometryPose(Ice::Float x, Ice::Float y, Ice::Float angle, const Ice::Current &) override
void onConnectObserver() override
Framework hook.
void reportGlobalRobotPose(const ::armarx::TransformStamped &, const ::Ice::Current &=::Ice::emptyCurrent) override
void reportPlatformVelocity(::Ice::Float currentPlatformVelocityX, ::Ice::Float currentPlatformVelocityY, ::Ice::Float currentPlatformVelocityRotation, const Ice::Current &c=Ice::emptyCurrent) override
void onInitObserver() override
Framework hook.
std::string getDefaultName() const override
Retrieve default name of component.
std::string prefix
Prefix of the properties such as namespace, domain, component name, etc.
PropertyDefinition< PropertyType > & defineOptionalProperty(const std::string &name, PropertyType defaultValue, const std::string &description="", PropertyDefinitionBase::PropertyConstness constness=PropertyDefinitionBase::eConstant)
const PlatformUnitDatafieldCreator platformPose("platformPose")
const PlatformUnitDatafieldCreator platformVelocity("platformVelocity")
This file offers overloads of toIce() and fromIce() functions for STL container types.
IceUtil::Handle< class PropertyDefinitionContainer > PropertyDefinitionsPtr
PropertyDefinitions smart pointer type.
double angle(const Point &a, const Point &b, const Point &c)
Definition point.hpp:109