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
32namespace 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 */
52 AgentInstance(const AgentInstance& source);
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
constexpr T c
armarx::FramedPoseBasePtr getPoseBase(const ::Ice::Current &=Ice::emptyCurrent) const override
std::string getAgentFilePath(const ::Ice::Current &c=Ice::emptyCurrent) const override
void setOrientation(const armarx::FramedOrientationBasePtr &orientation, const ::Ice::Current &=Ice::emptyCurrent) override
EntityAttributeBasePtr getOrientationAttribute() const
armarx::FramedPosePtr getPose() const
armarx::FramedOrientationPtr getOrientation() const
armarx::FramedPositionPtr getPosition() const
armarx::SharedRobotInterfacePrx getSharedRobot(const Ice::Current &c=Ice::emptyCurrent) const override
armarx::FramedPositionBasePtr getPositionBase(const ::Ice::Current &=Ice::emptyCurrent) const override
void setStringifiedSharedRobotInterfaceProxy(const std::string &stringifiedSharedRobotInterfaceProxy, const ::Ice::Current &c=Ice::emptyCurrent) override
void setPose(const armarx::FramedPoseBasePtr &newPose)
void setPosition(const armarx::FramedPositionBasePtr &position, const ::Ice::Current &=Ice::emptyCurrent) override
std::string getStringifiedSharedRobotInterfaceProxy(const ::Ice::Current &c=Ice::emptyCurrent) const override
void setAgentFilePath(const std::string &agentFilePath, const ::Ice::Current &c=Ice::emptyCurrent) override
armarx::FramedOrientationBasePtr getOrientationBase(const ::Ice::Current &=Ice::emptyCurrent) const override
AgentInstancePtr clone(const Ice::Current &c=Ice::emptyCurrent) const
Ice::ObjectPtr ice_clone() const override
void setSharedRobot(const armarx::SharedRobotInterfacePrx &robot, const Ice::Current &c=Ice::emptyCurrent) override
set the proxy to a SharedRobot for this agent.
EntityAttributeBasePtr getPositionAttribute() const
friend std::ostream & operator<<(std::ostream &stream, const AgentInstance &rhs)
Entity(const Entity &source)
Definition Entity.cpp:34
void output(std::ostream &stream) const
Definition Entity.cpp:436
IceInternal::Handle< FramedPosition > FramedPositionPtr
Definition FramedPose.h:149
::IceInternal::ProxyHandle<::IceProxy::armarx::SharedRobotInterface > SharedRobotInterfacePrx
Definition FramedPose.h:59
IceInternal::Handle< FramedOrientation > FramedOrientationPtr
Definition FramedPose.h:207
IceInternal::Handle< FramedPose > FramedPosePtr
Definition FramedPose.h:272
VirtualRobot headers.
IceInternal::Handle< AgentInstance > AgentInstancePtr
Typedef of AgentEntityPtr as IceInternal::Handle<AgentEntity> for convenience.