Tekkotsu Homepage | Demos | Overview | Downloads | Dev. Resources | Reference | Credits |
KoduAgent.hGo to the documentation of this file.00001 #ifndef KODU_AGENT_H_ 00002 #define KODU_AGENT_H_ 00003 00004 // INCLUDES 00005 // c++ 00006 #include <cmath> 00007 #include <iostream> 00008 #include <queue> 00009 #include <string> 00010 #include <vector> 00011 00012 // tekkotsu 00013 #include "DualCoding/Point.h" 00014 #include "DualCoding/ShapeRoot.h" 00015 using namespace DualCoding; 00016 00017 // tekkodu 00018 #include "Kodu/General/GeneralMacros.h" 00019 #include "Kodu/Keepers/ScoreKeeper.h" 00020 #include "Kodu/Primitives/KoduActionMotion.h" 00021 00022 namespace Kodu { 00023 00024 // forward declarations 00025 class KoduPage; // KoduPage.h 00026 class PerceptualTaskBase; // PerceptualTaskBase.h 00027 00028 class KoduAgent { 00029 public: 00030 //! Constructor 00031 KoduAgent(); 00032 00033 //! Destructor 00034 ~KoduAgent(); 00035 00036 //! Assignment operator 00037 KoduAgent& operator=(const KoduAgent&); 00038 00039 /// ================================ Gazing functions ================================ /// 00040 //! Returns the gaze points 00041 const std::vector<Point>& getGazePoints() const; 00042 00043 /// ================================ Grasper functions ================================ /// 00044 //! States if the agent is attempting to grab an object 00045 bool isExecutingManipAction() const; 00046 00047 //! States whether or not the agent is (supposed to be) holding something 00048 bool isHoldingAnObject() const; 00049 00050 //! Signals the robot has completed the manipulation task (sets a particular set of flags) 00051 void manipulationComplete(); 00052 00053 //! Sets the "(agent) is attempting grab" flag 00054 void setIsExecutingManipActionFlag(bool bval = true); 00055 00056 //! Sets the "target object is in gripper" flag 00057 void setTargetInGripperFlag(bool bval = true); 00058 00059 //! Signals that the agent wants to drop something 00060 void setWantsToDropObjectFlag(bool bval = true); 00061 00062 //! Signals that the agent wants to grab something 00063 void setWantsToGrabObjectFlag(bool bval = true); 00064 00065 //! Signals the robot wants to drop an object (sets a particular set of flags) 00066 void signalDropActionStart(); 00067 00068 //! Signals the robot wants to grab an object (sets a particular set of flags) 00069 void signalGrabActionStart(); 00070 00071 //! States whether or not the agent wants to drop an object 00072 bool wantsToDropObject() const; 00073 00074 //! States whether or not the agent has an object it wants to grab 00075 bool wantsToGrabObject() const; 00076 00077 /// ================================ Give functions ================================== /// 00078 //! Signals that the agent wants to give something 00079 void setWantsToGiveObjectFlag(bool bval = true); 00080 00081 //! Signals the robot wants to give an objec to another robot (sets flags) 00082 void signalGiveActionStart(); 00083 00084 //! Signals whether the agent is currently receiving 00085 void setIsReceiving(bool bval = true); 00086 00087 //! States whether or not the agent wants to give an object to another agent 00088 bool wantsToGiveObject() const; 00089 00090 /// ================================ Motion functions ================================ /// 00091 //! Checks if the robot's body is moving (during motion action the body may stop) 00092 bool bodyIsInMotion() const; 00093 00094 //! Checks if the agent is walking (returns value of "agent is walking" flag) 00095 bool isExecutingMotionAction() const; 00096 00097 //! Checks if the agent needs to localize 00098 bool needsToLocalize() const; 00099 00100 //! Signals the robot has completed a motion command 00101 void motionComplete(); 00102 00103 //! Signals the robot is executing a motion command 00104 void signalMotionActionStart(); 00105 00106 //! Sets the 'agent is executing motion command' flag (default value = true) 00107 void setIsExecutingMotionActionFlag(bool bval = true); 00108 00109 //! Sets the current motion command 00110 void setMotionCommand(const MotionCommand&); 00111 00112 /// ================================ Page functions ================================ /// 00113 //! Returns the page currently being evaluated (determined by current page index variable) 00114 KoduPage* getCurrentPage() const; 00115 00116 //! Returns the specified page (using it's page number) 00117 KoduPage* getPage(unsigned int pageNumber) const; 00118 00119 //! Returns the specified page (using it's location in the vector--(PAGE# - 1)) 00120 KoduPage* getPageInPos(unsigned int pageIndex) const; 00121 00122 //! Checks if the agent wants to switch pages 00123 bool hasNewPageNumber() const; 00124 00125 /// ================================ Scoring functions ================================ /// 00126 //! Checks if the agent has a string to speak 00127 bool hasNewScoreChanges() const; 00128 00129 /// ================================ Speech functions ================================ /// 00130 //! Checks if the agent has a string to speak 00131 bool hasTextToSay() const; 00132 00133 /// ================================ Sound functions ================================ /// 00134 //! Checks if the agent has sounds to play 00135 bool hasSoundsToPlay() const; 00136 00137 private: 00138 /// ================================ Gaze functions ================================ /// 00139 //! Generates the agent's gaze points (the points in space to search for objects) 00140 void generateGazePoints(); 00141 00142 // Disallows the copy constructor 00143 DISALLOW_COPY(KoduAgent); 00144 00145 public: //// ================= The Public Agent Variables ================= //// 00146 // === Grasp variables === // 00147 ShapeRoot gripperObject; //!< The object the agent is holding/will be holding 00148 bool agentIsExecutingManipAction; //!< (flag) States if the agent is attempting to grab an object 00149 bool agentWantsToDropObject; //!< (flag) States if the agent wants to drop an object 00150 bool agentWantsToGrabObject; //!< (flag) States if the agent wants to grab an object 00151 bool targetObjectIsInGripper; //!< (flag) States if the target object is in the gripper 00152 00153 // === Motion variables === // 00154 //! The mininum travelling distance (including turns) to consider performing localization 00155 static const float kLocalizationDistanceThreshold; 00156 bool agentIsExecutingMotionAction; 00157 MotionCommand currMotionCmd; //!< The current motion command 00158 float distanceTravelled; //!< The accumulated distance the robot has travelled 00159 00160 // === Give variables === // 00161 bool agentWantsToGiveObject; //!< (flag) States if the agent wants to give an object 00162 Shape<AgentData> giveTargetObject; 00163 bool agentIsReceiving; 00164 int agentReceivingFrom; 00165 bool gotGiveReady; 00166 bool gotGiveInformation; 00167 float giveAngleToTurn; 00168 std::string giveObjType; 00169 00170 // === Page variables === // 00171 std::vector<KoduPage*> pages; //!< The vector of pages containing kode 00172 unsigned int currPageIndex; //!< The page (index) currently being executed 00173 unsigned int newReqdPage; //!< Stores the page number the agent wants to switch to 00174 00175 // === Perceptual Tasks container === // 00176 std::queue<PerceptualTaskBase*> ptasks; //!< A queue containing all the perceptual tasks 00177 00178 // === Score variables === // 00179 std::queue<ScoreChange> scoreQueue; //!< The queue of score operations and their value 00180 00181 // === Speech variables === // 00182 std::string stringToSpeak; //!< The string the agent wants to speak 00183 00184 // === Sound variables === // 00185 std::queue<std::string> playQueue; //!< The queue of sound files the agent wants to play 00186 00187 private: //// ================= The Private Agent Variables ================= //// 00188 // === Gaze points variables === // 00189 //! egocentric (relative to the robot's body) points to look at 00190 std::vector<Point> agentGazePoints; 00191 }; 00192 } 00193 00194 #endif // end of KODU_AGENT_H_ |
Tekkotsu v5.1CVS |
Generated Mon May 9 04:58:43 2016 by Doxygen 1.6.3 |