PlatformUnitObserver.cpp
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
24
25#include <SimoxUtility/math/convert/mat3f_to_rpy.h>
26
34
35#include "PlatformUnit.h"
36
37namespace armarx
38{
39 // ********************************************************************
40 // observer framework hooks
41 // ********************************************************************
42 void
44 {
45 // TODO: check if platformNodeName exists?
46 platformNodeName = getProperty<std::string>("PlatformName").getValue();
47
48
49 // register all checks
57
58 usingTopic(platformNodeName + "State");
59 usingTopic("GlobalRobotPoseLocalization");
60 }
61
62 void
64 {
65 // register all channels
66 offerChannel("platformPose", "Current Position of " + platformNodeName);
67 offerChannel("platformVelocity", "Current velocity of " + platformNodeName);
68 offerChannel("platformOdometryPose", "Current Odometry Position of " + platformNodeName);
69
70 // register all data fields
71 offerDataField("platformPose",
72 "positionX",
74 "Current X position of " + platformNodeName + " in mm");
75 offerDataField("platformPose",
76 "positionY",
78 "Current Y position of " + platformNodeName + " in mm");
79 offerDataField("platformPose",
80 "rotation",
82 "Current Rotation of " + platformNodeName + " in radian");
83
84 offerDataField("platformVelocity",
85 "velocityX",
87 "Current X velocity of " + platformNodeName + " in mm/s");
88 offerDataField("platformVelocity",
89 "velocityY",
91 "Current Y velocity of " + platformNodeName + " in mm/s");
92 offerDataField("platformVelocity",
93 "velocityRotation",
95 "Current Rotation velocity of " + platformNodeName + " in radian/s");
96
97 offerDataField("platformOdometryPose",
98 "positionX",
100 "Current Odometry X position of " + platformNodeName + " in mm");
101 offerDataField("platformOdometryPose",
102 "positionY",
104 "Current Odometry Y position of " + platformNodeName + " in mm");
105 offerDataField("platformOdometryPose",
106 "rotation",
108 "Current Odometry Rotation of " + platformNodeName + " in radian");
109
110 // odometry pose is always zero in the beginning - set it so that it can be queried
111 reportPlatformOdometryPose(0, 0, 0, Ice::emptyCurrent);
112 }
113
114 void
115 PlatformUnitObserver::reportGlobalRobotPose(const ::armarx::TransformStamped& transformStamped,
116 const ::Ice::Current&)
117 {
118 const Eigen::Isometry3f global_T_robot(transformStamped.transform);
119
120 const float x = global_T_robot.translation().x();
121 const float y = global_T_robot.translation().y();
122 const float rotationAroundZ = simox::math::mat3f_to_rpy(global_T_robot.linear()).z();
123
124 nameValueMapToDataFields("platformPose", x, y, rotationAroundZ);
125 updateChannel("platformPose");
126 }
127
128 void
129 PlatformUnitObserver::reportPlatformVelocity(::Ice::Float currentPlatformVelocityX,
130 ::Ice::Float currentPlatformVelocityY,
131 ::Ice::Float currentPlatformVelocityRotation,
132 const Ice::Current& c)
133 {
134 setDataField("platformVelocity", "velocityX", currentPlatformVelocityX);
135 setDataField("platformVelocity", "velocityY", currentPlatformVelocityY);
136 setDataField("platformVelocity", "velocityRotation", currentPlatformVelocityRotation);
137 updateChannel("platformVelocity");
138 }
139
140 // ********************************************************************
141 // private methods
142 // ********************************************************************
143 void
145 ::Ice::Float platformPositionX,
146 ::Ice::Float platformPositionY,
147 ::Ice::Float platformRotation)
148 {
149 setDataField(channelName, "positionX", platformPositionX);
150 setDataField(channelName, "positionY", platformPositionY);
151 setDataField(channelName, "rotation", platformRotation);
152 }
153
160
161 void
163 Ice::Float y,
164 Ice::Float angle,
165 const Ice::Current&)
166 {
167 nameValueMapToDataFields("platformOdometryPose", x, y, angle);
168 updateChannel("platformOdometryPose");
169 }
170
171
172} // namespace armarx
constexpr T c
std::string getConfigIdentifier()
Retrieve config identifier for this component as set in constructor.
Definition Component.cpp:90
Property< PropertyType > getProperty(const std::string &name)
Checks if the numbers published in the relevant data fields equal reference value with respect to a t...
Checks if the numbers published in the relevant data fields equal a reference value.
Checks if the numbers published in the relevant data fields are within a reference range.
Checks if the numbers published in the relevant data fields are larger than a reference value.
Checks if the numbers published in the relevant data fields are smaller than a reference value.
Checks if the relevant data fields have been updated since the installation of this condition.
Checks if the relevant data fields contain valid values.
void usingTopic(const std::string &name, bool orderedPublishing=false)
Registers a proxy for subscription after initialization.
void offerChannel(std::string channelName, std::string description)
Offer a channel.
Definition Observer.cpp:131
void offerDataField(std::string channelName, std::string datafieldName, VariantTypeId type, std::string description)
Offer a datafield without default value.
Definition Observer.cpp:201
void offerConditionCheck(std::string checkName, ConditionCheck *conditionCheck)
Offer a condition check.
Definition Observer.cpp:301
void updateChannel(const std::string &channelName, const std::set< std::string > &updatedDatafields=std::set< std::string >())
Update all conditions for a channel.
Definition Observer.cpp:788
void setDataField(const std::string &channelName, const std::string &datafieldName, const Variant &value, bool triggerFilterUpdate=true)
set datafield with datafieldName and in channel channelName
Definition Observer.cpp:508
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
PropertyDefinitionsPtr createPropertyDefinitions() override
void nameValueMapToDataFields(std::string channelName, ::Ice::Float platformPositionX, ::Ice::Float platformPositionY, ::Ice::Float platformRotation)
void onInitObserver() override
Framework hook.
const VariantTypeId Float
Definition Variant.h:919
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