[Orxonox-commit 6022] r10681 - code/branches/AI_HS15/src/orxonox/controllers

gania at orxonox.net gania at orxonox.net
Fri Oct 23 07:44:21 CEST 2015


Author: gania
Date: 2015-10-23 07:44:20 +0200 (Fri, 23 Oct 2015)
New Revision: 10681

Modified:
   code/branches/AI_HS15/src/orxonox/controllers/DivisionController.h
   code/branches/AI_HS15/src/orxonox/controllers/FleetController.h
   code/branches/AI_HS15/src/orxonox/controllers/LeaderController.cc
   code/branches/AI_HS15/src/orxonox/controllers/LeaderController.h
   code/branches/AI_HS15/src/orxonox/controllers/SectionController.h
   code/branches/AI_HS15/src/orxonox/controllers/WingmanController.cc
   code/branches/AI_HS15/src/orxonox/controllers/WingmanController.h
Log:
refactoring in process

Modified: code/branches/AI_HS15/src/orxonox/controllers/DivisionController.h
===================================================================
--- code/branches/AI_HS15/src/orxonox/controllers/DivisionController.h	2015-10-21 14:48:52 UTC (rev 10680)
+++ code/branches/AI_HS15/src/orxonox/controllers/DivisionController.h	2015-10-23 05:44:20 UTC (rev 10681)
@@ -37,17 +37,85 @@
     class _OrxonoxExport DivisionController : public FleetController
     {
         public:
-        DivisionController(Context* context);
-        virtual ~DivisionController();
+        	DivisionController(Context* context);
+        	virtual ~DivisionController();
 
-        //virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
+        	//virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
 
+        	//Using british military aircraft formations
+        	enum FormationMode {VEE,FINGER4,DIAMOND, WALL};
+        	void setFormationMode(FormationMode val);
+     		inline FormationMode getFormationMode() const
+           		{ return this->formationMode_; }
+			
+			virtual void doFire();
 
+			//WAYPOINT FUNCTIONS`
+            void addWaypoint(WorldEntity* waypoint);
+            WorldEntity* getWaypoint(unsigned int index) const;
 
+            inline void setAccuracy(float accuracy)
+                { this->squaredaccuracy_ = accuracy*accuracy; }
+            inline float getAccuracy() const
+                { return sqrt(this->squaredaccuracy_); }
+            void updatePointsOfInterest(std::string name, float distance);
+            void manageWaypoints();
 
         protected:
 
-    
+	     	//Target enemy, set by fleet controller.
+	        WeakPtr<Pawn> target_;
+	        bool bHasTargetPosition_;
+			Vector3 targetPosition_;
+			bool bHasTargetOrientation_;
+			Quaternion targetOrientation_;
+			void setTargetPosition(const Vector3& target);
+			void searchRandomTargetPosition();
+
+			void setTargetOrientation(const Quaternion& orient);
+			void setTargetOrientation(Pawn* target);
+
+			virtual void positionReached() {}
+
+			static bool sameTeam(ControllableEntity* entity1, ControllableEntity* entity2, Gametype* gametype); // hack
+
+
+			void setTarget(Pawn* target);
+
+			void searchNewTarget();
+		    void forgetTarget();
+
+			void targetDied();
+			bool bShooting_;
+			void aimAtTarget();
+
+            bool isCloseAtTarget(float distance) const;
+            bool isLookingAtTarget(float angle) const;
+
+	        //Has nothing to do with desiredRelativePosition_,
+	        //is set by fleet controller.
+	        Vector3* desiredAbsolutePosition_;
+
+    		enum Maneuver {NONE, SPIN, TURN180};
+    		Maneuver maneuver_;
+
+    		void moveToPosition(const Vector3& target);
+		    void moveToTargetPosition();
+		    void absoluteMoveToPosition(const Vector3& target);
+		    void copyOrientation(const Quaternion& orient);
+		    void copyTargetOrientation();
+
+			void turn180Init();
+		    void spinInit();
+		    void spin();
+      		void turn180();
+
+	        //WAYPOINT DATA
+	        std::vector<WeakPtr<WorldEntity> > waypoints_;
+	        size_t currentWaypoint_;
+	        float squaredaccuracy_;
+	        WorldEntity* defaultWaypoint_;
+	    
         private:
     };
 }

Modified: code/branches/AI_HS15/src/orxonox/controllers/FleetController.h
===================================================================
--- code/branches/AI_HS15/src/orxonox/controllers/FleetController.h	2015-10-21 14:48:52 UTC (rev 10680)
+++ code/branches/AI_HS15/src/orxonox/controllers/FleetController.h	2015-10-23 05:44:20 UTC (rev 10681)
@@ -66,38 +66,38 @@
     class _OrxonoxExport FleetController : public Controller
     {
         public:
-        FleetController(Context* context);
-        virtual ~FleetController();
+          FleetController(Context* context);
+          virtual ~FleetController();
 
 
-        virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
+          virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
 
-        //gameGoal_ is to be set in XML
-        //DOMINATE is default, makes AI want to be the only team alive
-        //MOVE makes a fleet move to a set absolute position (set in variable goalPosition_)
-        //DESTROY makes a fleet destroy a target (set in variable goalTarget_)
-        //PROTECT makes a fleet protect a target (set in variable goalProtect_)
-        enum GameGoal {DOMINATE, MOVE, DESTROY, PROTECT};
-        
-        /*void setGameGoal(GameGoal gameGoal)
-           { this->gameGoal_ = gameGoal; }
-        GameGoal getGameGoal() const
-           { return this->gameGoal_; }
-        
-        void setGoalPosition(Vector3* goalPosition)
-           { this->goalPosition_ = goalPosition; }
-        Vector3* getGoalPosition() const
-           { return this->goalPosition_; }
-        
-        void setGoalTarget(Pawn* goalTarget)
-           { this->goalTarget_ = goalTarget; }
-        Pawn* getGoalTarget() const
-           { return this->goalTarget_; }
-        
-        void setGoalProtect(Pawn* goalProtect)
-           { this->goalProtect_ = goalProtect; }
-        Pawn* getGoalProtect() const
-           { return this->goalProtect_; }*/
+          //gameGoal_ is to be set in XML
+          //DOMINATE is default, makes AI want to be the only team alive
+          //MOVE makes a fleet move to a set absolute position (set in variable goalPosition_)
+          //DESTROY makes a fleet destroy a target (set in variable goalTarget_)
+          //PROTECT makes a fleet protect a target (set in variable goalProtect_)
+          enum GameGoal {DOMINATE, MOVE, DESTROY, PROTECT};
+          
+          /*void setGameGoal(GameGoal gameGoal)
+             { this->gameGoal_ = gameGoal; }
+          GameGoal getGameGoal() const
+             { return this->gameGoal_; }
+          
+          void setGoalPosition(Vector3* goalPosition)
+             { this->goalPosition_ = goalPosition; }
+          Vector3* getGoalPosition() const
+             { return this->goalPosition_; }
+          
+          void setGoalTarget(Pawn* goalTarget)
+             { this->goalTarget_ = goalTarget; }
+          Pawn* getGoalTarget() const
+             { return this->goalTarget_; }
+          
+          void setGoalProtect(Pawn* goalProtect)
+             { this->goalProtect_ = goalProtect; }
+          Pawn* getGoalProtect() const
+             { return this->goalProtect_; }*/
 
 
 

Modified: code/branches/AI_HS15/src/orxonox/controllers/LeaderController.cc
===================================================================
--- code/branches/AI_HS15/src/orxonox/controllers/LeaderController.cc	2015-10-21 14:48:52 UTC (rev 10680)
+++ code/branches/AI_HS15/src/orxonox/controllers/LeaderController.cc	2015-10-23 05:44:20 UTC (rev 10681)
@@ -58,9 +58,9 @@
         SUPER(LeaderController, tick, dt);
     }
 //**********************************************NEW
-    void LeaderController::defaultBehaviour(float maxrand)
+   /* void LeaderController::defaultBehaviour(float maxrand)
     {  
        
-    }
+    }*/
 
 }

Modified: code/branches/AI_HS15/src/orxonox/controllers/LeaderController.h
===================================================================
--- code/branches/AI_HS15/src/orxonox/controllers/LeaderController.h	2015-10-21 14:48:52 UTC (rev 10680)
+++ code/branches/AI_HS15/src/orxonox/controllers/LeaderController.h	2015-10-23 05:44:20 UTC (rev 10681)
@@ -37,20 +37,38 @@
     class _OrxonoxExport LeaderController : public SectionController, public Tickable
     {
         public:
-        LeaderController(Context* context);
-        virtual ~LeaderController();
+           
+            LeaderController(Context* context);
+            virtual ~LeaderController();
 
-        virtual void tick(float dt); //<! Carrying out the targets set in action().
+            virtual void tick(float dt); //<! Carrying out the targets set in action().
 
         protected:
-        virtual void action(); //<! action() is called in regular intervals managing the bot's behaviour ~ setting targets.
-        void defaultBehaviour(float maxrand); //<! Helper function for code reusage. Some concrete commands for a bot.
+           
+            virtual void action(); //<! action() is called in regular intervals managing the bot's behaviour ~ setting targets.
+            //void defaultBehaviour(float maxrand); //<! Helper function for code reusage. Some concrete commands for a bot.
 
+
+            
+                
+            enum Mode {KEEPFORMATION, ROCKET, KILLENEMY};
+            Mode mode_;
+
+            //WEAPONSYSTEM DATA
+            std::map<std::string, int> weaponModes_; //<! Links each "weapon" to it's weaponmode - managed by setupWeapons()
+            //std::vector<int> projectiles_; //<! Displays amount of projectiles of each weapon. - managed by setupWeapons()
+            float timeout_; //<! Timeout for rocket usage. (If a rocket misses, a bot should stop using it.)
+            void setupWeapons(); //<! Defines which weapons are available for a bot. Is recalled whenever a bot was killed.
+            bool bSetupWorked; //<! If false, setupWeapons() is called.
+            int getFiremode(std::string name);
+
+            void boostControl(); //<! Sets and resets the boost parameter of the spaceship. Bots alternate between boosting and saving boost.
+
         private:
-        static const float ACTION_INTERVAL;
+            static const float ACTION_INTERVAL;
 
-        Timer actionTimer_; //<! Regularly calls action().
-           
+            Timer actionTimer_; //<! Regularly calls action().
+               
     };
 }
 

Modified: code/branches/AI_HS15/src/orxonox/controllers/SectionController.h
===================================================================
--- code/branches/AI_HS15/src/orxonox/controllers/SectionController.h	2015-10-21 14:48:52 UTC (rev 10680)
+++ code/branches/AI_HS15/src/orxonox/controllers/SectionController.h	2015-10-23 05:44:20 UTC (rev 10681)
@@ -37,17 +37,27 @@
     class _OrxonoxExport SectionController : public DivisionController
     {
         public:
-        SectionController(Context* context);
-        virtual ~SectionController();
+            SectionController(Context* context);
+            virtual ~SectionController();
 
-        //virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
+            //virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
 
 
 
-
         protected:
+      
+            //A division is the biggest block of spaceships.
+            //In division one section is leading, the other one always stays on the same position
+            //relative to the Leader of the leading section.
+            //In section a Wingman always stays on same position relative to the Leader.
+            //That position is desiredRelativePosition_
+            Vector3* desiredRelativePosition_;
+            
 
-    
+
+            LeaderController* leader_;
+            WingmanController* wingman_;
+        
         private:
     };
 }

Modified: code/branches/AI_HS15/src/orxonox/controllers/WingmanController.cc
===================================================================
--- code/branches/AI_HS15/src/orxonox/controllers/WingmanController.cc	2015-10-21 14:48:52 UTC (rev 10680)
+++ code/branches/AI_HS15/src/orxonox/controllers/WingmanController.cc	2015-10-23 05:44:20 UTC (rev 10681)
@@ -64,9 +64,9 @@
         SUPER(WingmanController, tick, dt);
     }
 //**********************************************NEW
-    void WingmanController::defaultBehaviour(float maxrand)
+    /*void WingmanController::defaultBehaviour(float maxrand)
     {  
        
-    }
+    }*/
 
 }

Modified: code/branches/AI_HS15/src/orxonox/controllers/WingmanController.h
===================================================================
--- code/branches/AI_HS15/src/orxonox/controllers/WingmanController.h	2015-10-21 14:48:52 UTC (rev 10680)
+++ code/branches/AI_HS15/src/orxonox/controllers/WingmanController.h	2015-10-23 05:44:20 UTC (rev 10681)
@@ -30,12 +30,12 @@
 #define _WingmanController_H__
 
 
-#include "SectionController.h"
+#include "LeaderController.h"
 
 
 namespace orxonox
 {
-    class _OrxonoxExport WingmanController : public SectionController, public Tickable
+    class _OrxonoxExport WingmanController : public LeaderController
     {
         public:
             WingmanController(Context* context);
@@ -45,9 +45,10 @@
 
         protected:
             virtual void action(); //<! action() is called in regular intervals managing the bot's behaviour ~ setting targets.
-            void defaultBehaviour(float maxrand); //<! Helper function for code reusage. Some concrete commands for a bot.
+            //void defaultBehaviour(float maxrand); //<! Helper function for code reusage. Some concrete commands for a bot.
 
 
+                     
         private:
             static const float ACTION_INTERVAL;
 




More information about the Orxonox-commit mailing list