AgentInstance.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 MemoryX::Core
17 * @author Thomas von der Heyde (tvh242 at hotmail dot com)
18 * @date 2014
19 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
20 * GNU General Public License
21 */
22 
23 #pragma once
24 
25 #include <RobotAPI/interface/core/RobotState.h>
27 
29 #include <MemoryX/interface/core/EntityBase.h>
30 #include <MemoryX/interface/memorytypes/MemoryEntities.h>
31 
32 namespace memoryx
33 {
34 
35  class AgentInstance;
36  /**
37  * Typedef of AgentEntityPtr as IceInternal::Handle<AgentEntity> for convenience.
38  */
40 
41  /*!
42  * AgentInstance represents an agent (robot) in the working memory. It allows acces to the agent's position and orientation, as well as to a stringified version of the SharedRobotInterfacePrx
43  * of that agent, allowing querying of the agents joint values, and the path to the agents XML data file.
44  */
45  class AgentInstance : public AgentInstanceBase, public Entity
46  {
47  public:
48  /*!
49  * Default AgentInstance constructor.
50  */
51  AgentInstance();
53  /*!
54  * Creates an AgentInstance with the given name, and optionally, ID.
55  */
56  AgentInstance(const std::string& name, const std::string& id = "");
57 
58  /*!
59  * Gets a pointer to the agents position attribute.
60  */
61  EntityAttributeBasePtr getPositionAttribute() const;
62  /*!
63  * Gets the agents framed position.
64  */
66  /*!
67  * Sets the agents framed position.
68  * \param position Agents framed position.
69  */
70  void setPosition(const armarx::FramedPositionBasePtr& position,
71  const ::Ice::Current& = Ice::emptyCurrent) override;
72 
73  /*!
74  * Gets a pointer to the agents orientation attribute.
75  */
76  EntityAttributeBasePtr getOrientationAttribute() const;
77  /*!
78  * Gets the agents framed orientation.
79  */
81  /*!
82  * Sets the agents framed orientation.
83  * \param orientation Agents framed orientation.
84  */
85  void setOrientation(const armarx::FramedOrientationBasePtr& orientation,
86  const ::Ice::Current& = Ice::emptyCurrent) override;
87 
88  /*!
89  * Gets the agents framed pose.
90  */
92  /*!
93  * Sets the agents framed orientation.
94  * \param orientation Agents framed orientation.
95  */
96  void setPose(const armarx::FramedPoseBasePtr& newPose);
97 
98  /*!
99  * Gets the agents SharedRobotInterfacePrx in string format. This can be converted back to proxy format using the ICE communicator.
100  */
102  const ::Ice::Current& c = Ice::emptyCurrent) const override;
103  /*!
104  * Sets the agents SharedRobotInterfacePrx in string format. A proxy can be converted to string format using the ICE communicator.
105  */
107  const std::string& stringifiedSharedRobotInterfaceProxy,
108  const ::Ice::Current& c = Ice::emptyCurrent) override;
109 
110  /*!
111  * Gets the path of the agents XML data file.
112  */
113  std::string getAgentFilePath(const ::Ice::Current& c = Ice::emptyCurrent) const override;
114  /*!
115  * Sets the path of the agents XML data file.
116  * \param agentFilePath Path of the XML data file.
117  */
118  void setAgentFilePath(const std::string& agentFilePath,
119  const ::Ice::Current& c = Ice::emptyCurrent) override;
120 
122  getSharedRobot(const Ice::Current& c = Ice::emptyCurrent) const override;
123 
124  /**
125  * @brief set the proxy to a SharedRobot for this agent. This entity takes the name from the robot in
126  * the given proxy
127  * @param robot
128  */
130  const Ice::Current& c = Ice::emptyCurrent) override;
131 
132 
133  /* Cloning. */
134  Ice::ObjectPtr ice_clone() const override;
135  AgentInstancePtr clone(const Ice::Current& c = Ice::emptyCurrent) const;
136 
137  protected:
138  /* Ice interface implementation on Base data types. Replaces in C++ by derived instance getters, setters. */
139  armarx::FramedPositionBasePtr
140  getPositionBase(const ::Ice::Current& = Ice::emptyCurrent) const override;
141  armarx::FramedOrientationBasePtr
142  getOrientationBase(const ::Ice::Current& = Ice::emptyCurrent) const override;
143  armarx::FramedPoseBasePtr
144  getPoseBase(const ::Ice::Current& = Ice::emptyCurrent) const override;
145 
146 
147  public:
148  /* Streaming operator. */
149  friend std::ostream&
150  operator<<(std::ostream& stream, const AgentInstance& rhs)
151  {
152  rhs.output(stream);
153  return stream;
154  }
155 
156  friend std::ostream&
157  operator<<(std::ostream& stream, const AgentInstancePtr& rhs)
158  {
159  rhs->output(stream);
160  return stream;
161  }
162 
163  friend std::ostream&
164  operator<<(std::ostream& stream, const AgentInstanceBasePtr& rhs)
165  {
166  stream << AgentInstancePtr::dynamicCast(rhs);
167  return stream;
168  }
169  };
170 
171 } // namespace memoryx
memoryx::AgentInstance::getPositionAttribute
EntityAttributeBasePtr getPositionAttribute() const
Definition: AgentInstance.cpp:55
memoryx::AgentInstance::getOrientation
armarx::FramedOrientationPtr getOrientation() const
Definition: AgentInstance.cpp:79
memoryx::AgentInstance::getPoseBase
armarx::FramedPoseBasePtr getPoseBase(const ::Ice::Current &=Ice::emptyCurrent) const override
Definition: AgentInstance.cpp:185
memoryx::AgentInstance::getStringifiedSharedRobotInterfaceProxy
std::string getStringifiedSharedRobotInterfaceProxy(const ::Ice::Current &c=Ice::emptyCurrent) const override
Definition: AgentInstance.cpp:107
memoryx::AgentInstance::getPosition
armarx::FramedPositionPtr getPosition() const
Definition: AgentInstance.cpp:61
memoryx
VirtualRobot headers.
Definition: CommonPlacesTester.cpp:48
c
constexpr T c
Definition: UnscentedKalmanFilterTest.cpp:46
memoryx::AgentInstance::operator<<
friend std::ostream & operator<<(std::ostream &stream, const AgentInstance &rhs)
Definition: AgentInstance.h:150
memoryx::AgentInstance::getPose
armarx::FramedPosePtr getPose() const
Definition: AgentInstance.cpp:92
memoryx::Entity::output
void output(std::ostream &stream) const
Definition: Entity.cpp:436
IceInternal::Handle< AgentInstance >
memoryx::AgentInstance::setAgentFilePath
void setAgentFilePath(const std::string &agentFilePath, const ::Ice::Current &c=Ice::emptyCurrent) override
Definition: AgentInstance.cpp:127
FramedPose.h
memoryx::AgentInstance::clone
AgentInstancePtr clone(const Ice::Current &c=Ice::emptyCurrent) const
Definition: AgentInstance.cpp:155
memoryx::AgentInstance::getOrientationAttribute
EntityAttributeBasePtr getOrientationAttribute() const
Definition: AgentInstance.cpp:73
boost::source
Vertex source(const detail::edge_base< Directed, Vertex > &e, const PCG &)
Definition: point_cloud_graph.h:661
memoryx::AgentInstance::getSharedRobot
armarx::SharedRobotInterfacePrx getSharedRobot(const Ice::Current &c=Ice::emptyCurrent) const override
Definition: AgentInstance.cpp:133
memoryx::AgentInstance::getOrientationBase
armarx::FramedOrientationBasePtr getOrientationBase(const ::Ice::Current &=Ice::emptyCurrent) const override
Definition: AgentInstance.cpp:178
memoryx::AgentInstance::getPositionBase
armarx::FramedPositionBasePtr getPositionBase(const ::Ice::Current &=Ice::emptyCurrent) const override
Definition: AgentInstance.cpp:171
memoryx::AgentInstance::setSharedRobot
void setSharedRobot(const armarx::SharedRobotInterfacePrx &robot, const Ice::Current &c=Ice::emptyCurrent) override
set the proxy to a SharedRobot for this agent.
Definition: AgentInstance.cpp:139
memoryx::AgentInstance::setPosition
void setPosition(const armarx::FramedPositionBasePtr &position, const ::Ice::Current &=Ice::emptyCurrent) override
Definition: AgentInstance.cpp:67
memoryx::AgentInstance::getAgentFilePath
std::string getAgentFilePath(const ::Ice::Current &c=Ice::emptyCurrent) const override
Definition: AgentInstance.cpp:121
Entity.h
memoryx::AgentInstance::setPose
void setPose(const armarx::FramedPoseBasePtr &newPose)
Definition: AgentInstance.cpp:99
IceInternal::ProxyHandle<::IceProxy::armarx::SharedRobotInterface >
memoryx::AgentInstance::AgentInstance
AgentInstance()
Definition: AgentInstance.cpp:27
memoryx::AgentInstance::setOrientation
void setOrientation(const armarx::FramedOrientationBasePtr &orientation, const ::Ice::Current &=Ice::emptyCurrent) override
Definition: AgentInstance.cpp:85
armarx::aron::type::ObjectPtr
std::shared_ptr< Object > ObjectPtr
Definition: Object.h:36
memoryx::AgentInstance
Definition: AgentInstance.h:45
memoryx::AgentInstance::setStringifiedSharedRobotInterfaceProxy
void setStringifiedSharedRobotInterfaceProxy(const std::string &stringifiedSharedRobotInterfaceProxy, const ::Ice::Current &c=Ice::emptyCurrent) override
Definition: AgentInstance.cpp:113
memoryx::Entity
Definition: Entity.h:245
memoryx::AgentInstance::ice_clone
Ice::ObjectPtr ice_clone() const override
Definition: AgentInstance.cpp:149