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 
26 #include <MemoryX/interface/core/EntityBase.h>
27 #include <MemoryX/interface/memorytypes/MemoryEntities.h>
29 #include <RobotAPI/interface/core/RobotState.h>
30 
31 namespace memoryx
32 {
33 
34  class AgentInstance;
35  /**
36  * Typedef of AgentEntityPtr as IceInternal::Handle<AgentEntity> for convenience.
37  */
39 
40  /*!
41  * 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
42  * of that agent, allowing querying of the agents joint values, and the path to the agents XML data file.
43  */
44  class AgentInstance :
45  public AgentInstanceBase,
46  public Entity
47  {
48  public:
49 
50  /*!
51  * Default AgentInstance constructor.
52  */
53  AgentInstance();
55  /*!
56  * Creates an AgentInstance with the given name, and optionally, ID.
57  */
58  AgentInstance(const std::string& name, const std::string& id = "");
59 
60  /*!
61  * Gets a pointer to the agents position attribute.
62  */
63  EntityAttributeBasePtr getPositionAttribute() const;
64  /*!
65  * Gets the agents framed position.
66  */
68  /*!
69  * Sets the agents framed position.
70  * \param position Agents framed position.
71  */
72  void setPosition(const armarx::FramedPositionBasePtr& position, const ::Ice::Current& = Ice::emptyCurrent) override;
73 
74  /*!
75  * Gets a pointer to the agents orientation attribute.
76  */
77  EntityAttributeBasePtr getOrientationAttribute() const;
78  /*!
79  * Gets the agents framed orientation.
80  */
82  /*!
83  * Sets the agents framed orientation.
84  * \param orientation Agents framed orientation.
85  */
86  void setOrientation(const armarx::FramedOrientationBasePtr& orientation, 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  */
101  std::string getStringifiedSharedRobotInterfaceProxy(const ::Ice::Current& c = Ice::emptyCurrent) const override;
102  /*!
103  * Sets the agents SharedRobotInterfacePrx in string format. A proxy can be converted to string format using the ICE communicator.
104  */
105  void setStringifiedSharedRobotInterfaceProxy(const std::string& stringifiedSharedRobotInterfaceProxy, const ::Ice::Current& c = Ice::emptyCurrent) override;
106 
107  /*!
108  * Gets the path of the agents XML data file.
109  */
110  std::string getAgentFilePath(const ::Ice::Current& c = Ice::emptyCurrent) const override;
111  /*!
112  * Sets the path of the agents XML data file.
113  * \param agentFilePath Path of the XML data file.
114  */
115  void setAgentFilePath(const std::string& agentFilePath, const ::Ice::Current& c = Ice::emptyCurrent) override;
116 
117  armarx::SharedRobotInterfacePrx getSharedRobot(const Ice::Current& c = Ice::emptyCurrent) const override;
118 
119  /**
120  * @brief set the proxy to a SharedRobot for this agent. This entity takes the name from the robot in
121  * the given proxy
122  * @param robot
123  */
124  void setSharedRobot(const armarx::SharedRobotInterfacePrx& robot, const Ice::Current& c = Ice::emptyCurrent) override;
125 
126 
127  /* Cloning. */
128  Ice::ObjectPtr ice_clone() const override;
129  AgentInstancePtr clone(const Ice::Current& c = Ice::emptyCurrent) const;
130 
131  protected:
132 
133  /* Ice interface implementation on Base data types. Replaces in C++ by derived instance getters, setters. */
134  armarx::FramedPositionBasePtr getPositionBase(const ::Ice::Current& = Ice::emptyCurrent) const override;
135  armarx::FramedOrientationBasePtr getOrientationBase(const ::Ice::Current& = Ice::emptyCurrent) const override;
136  armarx::FramedPoseBasePtr getPoseBase(const ::Ice::Current& = Ice::emptyCurrent) const override;
137 
138 
139  public:
140 
141  /* Streaming operator. */
142  friend std::ostream& operator<<(std::ostream& stream, const AgentInstance& rhs)
143  {
144  rhs.output(stream);
145  return stream;
146  }
147  friend std::ostream& operator<<(std::ostream& stream, const AgentInstancePtr& rhs)
148  {
149  rhs->output(stream);
150  return stream;
151  }
152  friend std::ostream& operator<<(std::ostream& stream, const AgentInstanceBasePtr& rhs)
153  {
154  stream << AgentInstancePtr::dynamicCast(rhs);
155  return stream;
156  }
157 
158  };
159 
160 }
161 
memoryx::AgentInstance::getPositionAttribute
EntityAttributeBasePtr getPositionAttribute() const
Definition: AgentInstance.cpp:54
memoryx::AgentInstance::operator<<
friend std::ostream & operator<<(std::ostream &stream, const AgentInstanceBasePtr &rhs)
Definition: AgentInstance.h:152
memoryx::AgentInstance::getOrientation
armarx::FramedOrientationPtr getOrientation() const
Definition: AgentInstance.cpp:74
memoryx::AgentInstance::getPoseBase
armarx::FramedPoseBasePtr getPoseBase(const ::Ice::Current &=Ice::emptyCurrent) const override
Definition: AgentInstance.cpp:160
memoryx::AgentInstance::getStringifiedSharedRobotInterfaceProxy
std::string getStringifiedSharedRobotInterfaceProxy(const ::Ice::Current &c=Ice::emptyCurrent) const override
Definition: AgentInstance.cpp:97
memoryx::AgentInstance::getPosition
armarx::FramedPositionPtr getPosition() const
Definition: AgentInstance.cpp:59
memoryx
VirtualRobot headers.
Definition: CommonPlacesTester.cpp:48
c
constexpr T c
Definition: UnscentedKalmanFilterTest.cpp:43
memoryx::AgentInstance::operator<<
friend std::ostream & operator<<(std::ostream &stream, const AgentInstancePtr &rhs)
Definition: AgentInstance.h:147
memoryx::AgentInstance::operator<<
friend std::ostream & operator<<(std::ostream &stream, const AgentInstance &rhs)
Definition: AgentInstance.h:142
memoryx::AgentInstance::getPose
armarx::FramedPosePtr getPose() const
Definition: AgentInstance.cpp:84
memoryx::Entity::output
void output(std::ostream &stream) const
Definition: Entity.cpp:409
IceInternal::Handle< AgentInstance >
memoryx::AgentInstance::setAgentFilePath
void setAgentFilePath(const std::string &agentFilePath, const ::Ice::Current &c=Ice::emptyCurrent) override
Definition: AgentInstance.cpp:112
FramedPose.h
memoryx::AgentInstance::clone
AgentInstancePtr clone(const Ice::Current &c=Ice::emptyCurrent) const
Definition: AgentInstance.cpp:135
memoryx::AgentInstance::getOrientationAttribute
EntityAttributeBasePtr getOrientationAttribute() const
Definition: AgentInstance.cpp:69
boost::source
Vertex source(const detail::edge_base< Directed, Vertex > &e, const PCG &)
Definition: point_cloud_graph.h:681
memoryx::AgentInstance::getSharedRobot
armarx::SharedRobotInterfacePrx getSharedRobot(const Ice::Current &c=Ice::emptyCurrent) const override
Definition: AgentInstance.cpp:117
memoryx::AgentInstance::getOrientationBase
armarx::FramedOrientationBasePtr getOrientationBase(const ::Ice::Current &=Ice::emptyCurrent) const override
Definition: AgentInstance.cpp:155
memoryx::AgentInstance::getPositionBase
armarx::FramedPositionBasePtr getPositionBase(const ::Ice::Current &=Ice::emptyCurrent) const override
Definition: AgentInstance.cpp:150
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:122
memoryx::AgentInstance::setPosition
void setPosition(const armarx::FramedPositionBasePtr &position, const ::Ice::Current &=Ice::emptyCurrent) override
Definition: AgentInstance.cpp:64
memoryx::AgentInstance::getAgentFilePath
std::string getAgentFilePath(const ::Ice::Current &c=Ice::emptyCurrent) const override
Definition: AgentInstance.cpp:107
Entity.h
memoryx::AgentInstance::setPose
void setPose(const armarx::FramedPoseBasePtr &newPose)
Definition: AgentInstance.cpp:90
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:79
armarx::aron::type::ObjectPtr
std::shared_ptr< Object > ObjectPtr
Definition: Object.h:36
memoryx::AgentInstance
Definition: AgentInstance.h:44
memoryx::AgentInstance::setStringifiedSharedRobotInterfaceProxy
void setStringifiedSharedRobotInterfaceProxy(const std::string &stringifiedSharedRobotInterfaceProxy, const ::Ice::Current &c=Ice::emptyCurrent) override
Definition: AgentInstance.cpp:102
memoryx::Entity
Definition: Entity.h:246
memoryx::AgentInstance::ice_clone
Ice::ObjectPtr ice_clone() const override
Definition: AgentInstance.cpp:130