[Orxonox-commit 6071] r10729 - in code/branches/AI_HS15: data/levels src/orxonox/controllers

gania at orxonox.net gania at orxonox.net
Sat Oct 31 12:20:00 CET 2015


Author: gania
Date: 2015-10-31 12:20:00 +0100 (Sat, 31 Oct 2015)
New Revision: 10729

Modified:
   code/branches/AI_HS15/data/levels/AITest.oxw
   code/branches/AI_HS15/src/orxonox/controllers/CommonController.cc
   code/branches/AI_HS15/src/orxonox/controllers/CommonController.h
   code/branches/AI_HS15/src/orxonox/controllers/DivisionController.cc
   code/branches/AI_HS15/src/orxonox/controllers/DivisionController.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.cc
   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:
move functions were added, everyone stays in formations

Modified: code/branches/AI_HS15/data/levels/AITest.oxw
===================================================================
--- code/branches/AI_HS15/data/levels/AITest.oxw	2015-10-31 10:33:08 UTC (rev 10728)
+++ code/branches/AI_HS15/data/levels/AITest.oxw	2015-10-31 11:20:00 UTC (rev 10729)
@@ -31,7 +31,7 @@
   >
 
     <Light type=directional position="0,0,0" direction="0.253, 0.593, -0.765" diffuse="1.0, 0.9, 0.9, 1.0" specular="1.0, 0.9, 0.9, 1.0"/>
-    <SpawnPoint team=0 position="1000,1000,-1000" lookat="0,0,0" spawnclass=SpaceShip pawndesign=spaceshipassff />
+    <SpawnPoint team=0 position="1000,1000,-1000" lookat="1,1,-1" spawnclass=SpaceShip pawndesign=spaceshipassff />
     <!-->
 
     <?lua
@@ -79,7 +79,7 @@
         </DivisionController>
       </controller>
     </SpaceShip>
-    <SpaceShip position="1000, 1000, -1300 ?>" lookat="0,0,0">
+    <SpaceShip position="1000, 1500, -1300 ?>" lookat="0,0,0">
       <templates>
         <Template link=spaceshipassff />
       </templates>
@@ -88,7 +88,7 @@
         </WingmanController>
       </controller>
     </SpaceShip>
-    <SpaceShip position="1000, 1000, -1700 ?>" lookat="0,0,0">
+    <SpaceShip position="1000, 1500, -1700 ?>" lookat="0,0,0">
       <templates>
         <Template link=spaceshipassff />
       </templates>

Modified: code/branches/AI_HS15/src/orxonox/controllers/CommonController.cc
===================================================================
--- code/branches/AI_HS15/src/orxonox/controllers/CommonController.cc	2015-10-31 10:33:08 UTC (rev 10728)
+++ code/branches/AI_HS15/src/orxonox/controllers/CommonController.cc	2015-10-31 11:20:00 UTC (rev 10729)
@@ -31,7 +31,11 @@
 {
 
     RegisterClass(CommonController);
+    static const float SPEED = 0.6f;
+    static const float ROTATEFACTOR = 0.2f;
 
+    /*static const float SPEED_FREE = 0.8f;
+    static const float ROTATEFACTOR_FREE = 0.8f;*/
     
     bool CommonController::setWingman (CommonController* wingman)
     {
@@ -50,46 +54,104 @@
     {
 
         RegisterObject(CommonController);
-        //this->actionTimer_.setTimer(ACTION_INTERVAL, true, createExecutor(createFunctor(&LeaderController::action, this)));
     }
 
 
     CommonController::~CommonController()
     {
     }
+    //copy the Roll orientation of given Quaternion.
+    void CommonController::copyOrientation(const Quaternion& orient)
+    {
+        //roll angle difference in radian
+        float diff=orient.getRoll(false).valueRadians()-(this->getControllableEntity()->getOrientation().getRoll(false).valueRadians());
+        while(diff>math::twoPi) diff-=math::twoPi;
+        while(diff<-math::twoPi) diff+=math::twoPi;
+        this->getControllableEntity()->rotateRoll(-diff);
 
+
+
+    }
+    void CommonController::setTargetPosition(const Vector3& target)
+    {
+        this->targetPosition_ = target;
+        this->bHasTargetPosition_ = true;
+    }
+
+    void CommonController::copyTargetOrientation()
+    {
+        if (bHasTargetOrientation_)
+        {   
+            copyOrientation(targetOrientation_);
+        }
+    }
+    void CommonController::setTargetOrientation(const Quaternion& orient)
+    {
+        this->targetOrientation_=orient;
+        this->bHasTargetOrientation_=true;
+    }
+    void CommonController::setTargetOrientation(ControllableEntity* target)
+    {
+        if (target)
+            setTargetOrientation(target->getOrientation());
+    }
+
+
     void CommonController::moveToPosition(const Vector3& target)
     {
         if (!this->getControllableEntity())
             return;
+        
+        //100 is (so far) the smallest tolerance (empirically found) that can be reached, 
+        //with smaller distance spaceships can't reach position and go circles around it instead
+        int tolerance = 100;
 
-        Vector2 coord = get2DViewCoordinates(this->getControllableEntity()->getPosition(), this->getControllableEntity()->getOrientation() * WorldEntity::FRONT, this->getControllableEntity()->getOrientation() * WorldEntity::UP, target);
+        ControllableEntity* entity = this->getControllableEntity();
+        Vector2 coord = get2DViewCoordinates
+            (entity->getPosition(), 
+            entity->getOrientation() * WorldEntity::FRONT, 
+            entity->getOrientation() * WorldEntity::UP, 
+            target);
+
         float distance = (target - this->getControllableEntity()->getPosition()).length();
+
+        //rotates should be in range [-1,+1], clamp cuts off all that is not
         float rotateX = clamp(coord.x * 10, -1.0f, 1.0f);
         float rotateY = clamp(coord.y * 10, -1.0f, 1.0f);
 
         
-        if (this->target_ || distance > 10)
+        if (distance > tolerance)
         {
-            this->getControllableEntity()->rotateYaw(-1.0f * 0.8f * rotateX);
-            this->getControllableEntity()->rotatePitch(0.8f * rotateY);
+            //Yaw and Pitch are enough to start facing the target
+            this->getControllableEntity()->rotateYaw(-2.0f * ROTATEFACTOR * rotateX);
+            this->getControllableEntity()->rotatePitch(2.0f * ROTATEFACTOR * rotateY);
+
+            //300 works, maybe less is better
+            if (distance < 300)
+            {
+                //Change roll when close. When Spaceship faces target, roll doesn't affect it's trajectory
+                //It's important that roll is not changed in the process of changing yaw and pitch
+                //Wingmen won't face same direction as Leaders, but when Leaders start moving
+                //Yaw and Pitch will adapt.
+                if (bHasTargetOrientation_)
+                {
+                    copyTargetOrientation();
+                }
+            }
+            this->getControllableEntity()->moveFrontBack(1.2f*SPEED);
         }
+        else
+        {      
+            bHasTargetPosition_ = false;
+            bHasTargetOrientation_ = false;
+        }
 
-        if (this->target_ && distance <  200 && this->getControllableEntity()->getVelocity().squaredLength() > this->target_->getVelocity().squaredLength())
-        {
-            this->getControllableEntity()->moveFrontBack(-0.05f); // They don't brake with full power to give the player a chance
-        } 
-        else if (distance > 100)
-            this->getControllableEntity()->moveFrontBack(0.8f);
-        
-
-
-        if (distance < 100)
-        {
-            this->positionReached();
-            bHasTargetOrientation_=false;
-        }
+      
     }
+    void CommonController::moveToTargetPosition()
+    {
+        this->moveToPosition(this->targetPosition_);
+    }
  
 
 }

Modified: code/branches/AI_HS15/src/orxonox/controllers/CommonController.h
===================================================================
--- code/branches/AI_HS15/src/orxonox/controllers/CommonController.h	2015-10-31 10:33:08 UTC (rev 10728)
+++ code/branches/AI_HS15/src/orxonox/controllers/CommonController.h	2015-10-31 11:20:00 UTC (rev 10729)
@@ -38,6 +38,8 @@
     class _OrxonoxExport CommonController : public Controller
     {
         public:
+            static const float ACTION_INTERVAL = 1.0f;
+
             enum FormationMode {VEE,FINGER4,DIAMOND, WALL};
             virtual void setFormationMode(FormationMode val)
                 { this->formationMode_ = val; }
@@ -49,35 +51,22 @@
             virtual bool isLeader();
             virtual bool setWingman(CommonController* wingman);
             virtual bool hasWingman();
-            Vector3* desiredRelativePosition_;
 
 
+            void setTargetOrientation(const Quaternion& orient);
+            void setTargetOrientation(ControllableEntity* target);
+            void setTargetPosition(const Vector3& target);
+
         protected:
             void moveToPosition(const Vector3& target);
             virtual void positionReached() {}
 
-        /*    void moveToTargetPosition();
-            void absoluteMoveToPosition(const Vector3& target);
+       
+            void moveToTargetPosition();
             void copyOrientation(const Quaternion& orient);
             void copyTargetOrientation();
 
-            void spin();
-            void turn180();
-            void follow();
-            void setTargetPosition(const Vector3& target);
 
-            void setTargetOrientation(const Quaternion& orient);
-            void setTargetOrientation(Pawn* target);
-
-
-
-            void setTarget(Pawn* target);
-
-            void searchNewTarget();
-            void forgetTarget();
-
-            void targetDied();
-*/
             bool bHasTargetPosition_;
             Vector3 targetPosition_;
             bool bHasTargetOrientation_;
@@ -90,11 +79,9 @@
 
 
 
-            //void defaultBehaviour(float maxrand); //<! Helper function for code reusage. Some concrete commands for a bot.    
          
         private:
             
-            //Timer actionTimer_; //<! Regularly calls action().
                
     };
 }

Modified: code/branches/AI_HS15/src/orxonox/controllers/DivisionController.cc
===================================================================
--- code/branches/AI_HS15/src/orxonox/controllers/DivisionController.cc	2015-10-31 10:33:08 UTC (rev 10728)
+++ code/branches/AI_HS15/src/orxonox/controllers/DivisionController.cc	2015-10-31 11:20:00 UTC (rev 10729)
@@ -33,7 +33,6 @@
 {
 
     RegisterClass(DivisionController);
-    static const float ACTION_INTERVAL = 1.0f;
 
     DivisionController::DivisionController(Context* context) : LeaderController(context)
     {
@@ -44,6 +43,9 @@
         this->myFollower_ = 0;
         this->myWingman_ = 0;
         this->actionTimer_.setTimer(ACTION_INTERVAL, true, createExecutor(createFunctor(&DivisionController::action, this)));
+       
+        /*Vector3* pos = new Vector3(500,500,-500);
+        this->setTargetPosition(*pos);*/
 
     }
 
@@ -53,13 +55,18 @@
     } 
     void DivisionController::tick(float dt)
     {
+        if (this->bHasTargetPosition_)
+        {
+            this->moveToTargetPosition();
+        }
+
         SUPER(DivisionController, tick, dt);
 
     }
     void DivisionController::action()
     {
-/*        setDesiredPositionOfFollower();
-        setDesiredPositionOfWingman();*/
+        setTargetPositionOfFollower();
+        setTargetPositionOfWingman();
     }
 
     bool DivisionController::setFollower(LeaderController* myFollower)
@@ -75,15 +82,15 @@
         }
     }
 
-   /* void DivisionController::setDesiredPositionOfWingman()
+    void DivisionController::setTargetPositionOfWingman()
     {
         if (!this->myWingman_)
             return;
-
+        Vector3* targetRelativePositionOfWingman;
         switch (this->formationMode_){
             case WALL:
             {
-                myWingman_->desiredRelativePosition_ = new Vector3 (200, 0, 0);   
+                targetRelativePositionOfWingman = new Vector3 (400, 0, 0);  
                 break;
             }
             case FINGER4: 
@@ -99,17 +106,24 @@
                 break;
             }
         }
+        Quaternion orient = this->getControllableEntity()->getWorldOrientation();
+        
+        Vector3 targetAbsolutePositionOfWingman = ((this->getControllableEntity()->getWorldPosition()) + 
+        (this->getControllableEntity()->getWorldOrientation()* (*targetRelativePositionOfWingman)));
+        
+        myWingman_->setTargetOrientation(orient);
+        myWingman_->setTargetPosition(targetAbsolutePositionOfWingman);
        
     }
-    void DivisionController::setDesiredPositionOfFollower()
+    void DivisionController::setTargetPositionOfFollower()
     {
         if (!this->myFollower_)
             return;
-
+        Vector3* targetRelativePositionOfFollower;
         switch (this->formationMode_){
             case WALL:
             {
-                myWingman_->desiredRelativePosition_ = new Vector3 (-200, 0, 0);   
+                targetRelativePositionOfFollower = new Vector3 (-400, 0, 0);   
                 break;
             }
             case FINGER4: 
@@ -125,8 +139,15 @@
                 break;
             }
         }
+        Quaternion orient = this->getControllableEntity()->getWorldOrientation();
+        
+        Vector3 targetAbsolutePositionOfFollower = ((this->getControllableEntity()->getWorldPosition()) + 
+        (this->getControllableEntity()->getWorldOrientation()* (*targetRelativePositionOfFollower)));
+        
+        myFollower_->setTargetOrientation(orient);
+        myFollower_->setTargetPosition(targetAbsolutePositionOfFollower);
        
-    }*/
+    }
     void DivisionController::XMLPort(Element& xmlelement, XMLPort::Mode mode)
     {
         SUPER(DivisionController, XMLPort, xmlelement, mode);

Modified: code/branches/AI_HS15/src/orxonox/controllers/DivisionController.h
===================================================================
--- code/branches/AI_HS15/src/orxonox/controllers/DivisionController.h	2015-10-31 10:33:08 UTC (rev 10728)
+++ code/branches/AI_HS15/src/orxonox/controllers/DivisionController.h	2015-10-31 11:20:00 UTC (rev 10729)
@@ -50,8 +50,9 @@
         	
      		
 			virtual bool setFollower(LeaderController* myFollower);
-			virtual bool setWingman(CommonController* wingman)
+			virtual bool setWingman(CommonController* cwingman)
             {
+                WeakPtr<WingmanController> wingman = orxonox_cast<WingmanController*>(cwingman);
                 if (!this->myWingman_)
                 {
                     this->myWingman_ = wingman;
@@ -82,16 +83,9 @@
 
 
         protected:
-            void setDesiredPositionOfWingman();
-            void setDesiredPositionOfFollower();
+            void setTargetPositionOfWingman();
+            void setTargetPositionOfFollower();
             virtual void action(); //<! action() is called in regular intervals managing the bot's behaviour ~ setting targets.
-
-	     	//Target enemy, set by fleet controller.
-	        
-			
-			
-	        
-
 	    
         private:
             Timer actionTimer_; //<! Regularly calls action().

Modified: code/branches/AI_HS15/src/orxonox/controllers/LeaderController.cc
===================================================================
--- code/branches/AI_HS15/src/orxonox/controllers/LeaderController.cc	2015-10-31 10:33:08 UTC (rev 10728)
+++ code/branches/AI_HS15/src/orxonox/controllers/LeaderController.cc	2015-10-31 11:20:00 UTC (rev 10729)
@@ -46,19 +46,12 @@
 
         RegisterObject(LeaderController);
 
-        //this->actionTimer_.setTimer(ACTION_INTERVAL, true, createExecutor(createFunctor(&LeaderController::action, this)));
     }
 
-
+   
     LeaderController::~LeaderController()
     {
     }
 
-    
-//**********************************************NEW
-   /* 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-31 10:33:08 UTC (rev 10728)
+++ code/branches/AI_HS15/src/orxonox/controllers/LeaderController.h	2015-10-31 11:20:00 UTC (rev 10729)
@@ -41,7 +41,6 @@
     class _OrxonoxExport LeaderController : public CommonController
     {
         public:
-               static const int RADIUS_TO_SEARCH_FOR_LEADER = 3000;
 
             LeaderController(Context* context);
             virtual ~LeaderController();
@@ -62,24 +61,16 @@
             {
                 return true;
             };
-            WeakPtr<CommonController> myWingman_;
+            WeakPtr<WingmanController> myWingman_;
 
             WeakPtr<LeaderController> myFollower_;
             WeakPtr<LeaderController> myDivisionLeader_;
 
 
         protected:
-           
-
-
-            //void defaultBehaviour(float maxrand); //<! Helper function for code reusage. Some concrete commands for a bot.    
          
         private:
             
-            
-            
-            //Timer actionTimer_; //<! Regularly calls action().
-               
     };
 }
 

Modified: code/branches/AI_HS15/src/orxonox/controllers/SectionController.cc
===================================================================
--- code/branches/AI_HS15/src/orxonox/controllers/SectionController.cc	2015-10-31 10:33:08 UTC (rev 10728)
+++ code/branches/AI_HS15/src/orxonox/controllers/SectionController.cc	2015-10-31 11:20:00 UTC (rev 10729)
@@ -32,18 +32,16 @@
 {
 
     RegisterClass(SectionController);
-    static const float ACTION_INTERVAL = 1.0f;
 
     SectionController::SectionController(Context* context) : LeaderController(context)
     {
         RegisterObject(SectionController);
-                this->setFormationMode(WALL);
+        this->setFormationMode(WALL);
 
         bIsDivisionLeader_ = false;
         this->actionTimer_.setTimer(ACTION_INTERVAL, true, createExecutor(createFunctor(&SectionController::action, this)));
         this->myWingman_ = 0;
         this->myDivisionLeader_ = 0;
-        this->desiredRelativePosition_ = 0;
 
         orxout(internal_error) << this << "Was created" << endl;
 
@@ -53,15 +51,15 @@
     {
        
     }
-    /*void SectionController::setDesiredPositionOfWingman()
+    void SectionController::setTargetPositionOfWingman()
     {
         if (!this->myWingman_)
             return;
-
+        Vector3* targetRelativePositionOfWingman;
         switch (this->formationMode_){
             case WALL:
             {
-                myWingman_->desiredRelativePosition_ = new Vector3 (-200, 0, 0);   
+                targetRelativePositionOfWingman = new Vector3 (-400, 0, 0);  
                 break;
             }
             case FINGER4: 
@@ -77,9 +75,16 @@
                 break;
             }
         }
+        Quaternion orient = this->getControllableEntity()->getWorldOrientation();
+        
+        Vector3 targetAbsolutePositionOfWingman = ((this->getControllableEntity()->getWorldPosition()) + 
+        (this->getControllableEntity()->getWorldOrientation()* (*targetRelativePositionOfWingman)));
+        
+        myWingman_->setTargetOrientation(orient);
+        myWingman_->setTargetPosition(targetAbsolutePositionOfWingman);
        
     }
-*/
+
     LeaderController* SectionController::findNewDivisionLeader()
     {
 
@@ -103,9 +108,6 @@
                 continue;
 
 
-            
-           
-
             float distance = ((it)->getControllableEntity()->getPosition() - this->getControllableEntity()->getPosition()).length();
             
             if (distance < minDistance && !(it->hasFollower()))
@@ -113,13 +115,7 @@
                 closestLeader = *it;
                 minDistance = distance;
             }
-           /* // is pawn in range?
-            if (distance < RADIUS_TO_SEARCH_FOR_LEADER)
-            {
-
-                if ((it)->setFollower(this))
-                    return (*it);
-            }*/
+          
         }
         if (closestLeader)
         {
@@ -141,8 +137,9 @@
                 orxout(internal_error) << "new DivisionLeader set" << endl;
 
         }
-/*        setDesiredPositionOfWingman();
-*/    }
+        setTargetPositionOfWingman();
+
+    }
     /*
     Wingmen and Leaders attack target_, which is a member variable of their classes.
     Wingmen's target_ is set to sectionTarget_, which is a member variable of SectionController class, unless
@@ -157,36 +154,17 @@
     but the other section, that is not a leading section, can attack any target that is near divisonTarget_
 
     */
-   /* void SectionController::keepDivisionTick()
-    {
-
-
-        if (this->myDivisionLeader_ && this->myDivisionLeader_->getControllableEntity() && desiredRelativePosition_)
-        {
-
-            Vector3 desiredAbsolutePosition = ((this->myDivisionLeader_->getControllableEntity()->getWorldPosition()) + 
-                (this->myDivisionLeader_->getControllableEntity()->getWorldOrientation()* (*desiredRelativePosition_)));
-            this->moveToPosition (desiredAbsolutePosition);
-        }
-    }*/
+    
     void SectionController::tick(float dt)
     {
-        
-
-       /* 
         if (!this->isActive())
             return;
         
-        //--------------------------Stay in division--------------------------
-        this->keepDivisionTick();
-        */
-        //If ordered to move -> move to a target Point
-        
-        //No orders -> Don't move, but shoot at whatever is close, unless Boss is shooting at it. 
-        //(Section shoots same target, Boss's section shoots another target) 
-        
+        if (this->bHasTargetPosition_)
+        {
+            this->moveToTargetPosition();
+        }
 
-        //orxout(internal_error) << "my Wingman is " << this->myWingman_ << endl;
         
         SUPER(SectionController, tick, dt);
     }

Modified: code/branches/AI_HS15/src/orxonox/controllers/SectionController.h
===================================================================
--- code/branches/AI_HS15/src/orxonox/controllers/SectionController.h	2015-10-31 10:33:08 UTC (rev 10728)
+++ code/branches/AI_HS15/src/orxonox/controllers/SectionController.h	2015-10-31 11:20:00 UTC (rev 10729)
@@ -41,8 +41,10 @@
         public:
             SectionController(Context* context);
             virtual ~SectionController();
-            virtual bool setWingman(CommonController* wingman)
+            virtual bool setWingman(CommonController* cwingman)
             {
+                WeakPtr<WingmanController> wingman = orxonox_cast<WingmanController*>(cwingman);
+
                 if (!this->myWingman_)
                 {
                     this->myWingman_ = wingman;
@@ -54,6 +56,7 @@
                 }
             }
 
+
             virtual bool hasWingman()
             {
                 if (this->myWingman_)
@@ -68,8 +71,7 @@
             LeaderController* findNewDivisionLeader();
 
         protected:
-            void setDesiredPositionOfWingman();
-            void keepDivisionTick();
+            void setTargetPositionOfWingman();
             //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.

Modified: code/branches/AI_HS15/src/orxonox/controllers/WingmanController.cc
===================================================================
--- code/branches/AI_HS15/src/orxonox/controllers/WingmanController.cc	2015-10-31 10:33:08 UTC (rev 10728)
+++ code/branches/AI_HS15/src/orxonox/controllers/WingmanController.cc	2015-10-31 11:20:00 UTC (rev 10729)
@@ -33,14 +33,13 @@
 {
 
     RegisterClass(WingmanController);
-    static const int RADIUS_TO_SEARCH_FOR_LEADER = 7000;
-    static const float ACTION_INTERVAL = 1.0f;
+    
+
     WingmanController::WingmanController(Context* context) : CommonController(context)
     {
         RegisterObject(WingmanController);
         this->actionTimer_.setTimer(ACTION_INTERVAL, true, createExecutor(createFunctor(&WingmanController::action, this)));
         this->myLeader_ = 0;
-        this->desiredRelativePosition_ = 0;
     }
 
     WingmanController::~WingmanController()
@@ -87,7 +86,6 @@
     
     void WingmanController::action()
     {
-        //this->target_ = this->sectionTarget_;
         if (!this->myLeader_)
         {
             CommonController* newLeader = findNewLeader();
@@ -144,28 +142,20 @@
             }*/
 
      
-    /*void WingmanController::keepSectionTick()
-    {
-        if (this->myLeader_ && this->myLeader_->getControllableEntity())
-                            //orxout(internal_error) << "MOVING" << endl;
-
-        if (this->myLeader_ && this->myLeader_->getControllableEntity() && desiredRelativePosition_)
-        {
-            Vector3 desiredAbsolutePosition = ((this->myLeader_->getControllableEntity()->getWorldPosition()) + 
-                (this->myLeader_->getControllableEntity()->getWorldOrientation()* (*desiredRelativePosition_)));
-            this->moveToPosition (desiredAbsolutePosition);
-        }
-    }*/
+   
     void WingmanController::tick(float dt)
     {   
-       /* //-------------------------------------------------------
+        //-------------------------------------------------------
            
         
         if (!this->isActive())
             return;
         //--------------------------Stay in formation--------------------------
-        this->keepSectionTick();*/
-            
+        if (this->bHasTargetPosition_)
+        {
+            //targetPosition_ and targetOrientation_ are set by the Leader in its action()
+            this->moveToTargetPosition();
+        } 
         
         //--------------------------Attack same target as the Leader--------------------------
 
@@ -174,7 +164,7 @@
             this->aimAtTarget();
             this->doFire();
         }
-*/
+        */
         
         //orxout(internal_error) << "I am " << this << endl;
 
@@ -189,10 +179,6 @@
         //XMLPortParam(SectionController, "target_", setTarget, getTarget, xmlelement, mode).defaultValues(100.0f);
     }
 
-//**********************************************NEW
-    /*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-31 10:33:08 UTC (rev 10728)
+++ code/branches/AI_HS15/src/orxonox/controllers/WingmanController.h	2015-10-31 11:20:00 UTC (rev 10729)
@@ -59,15 +59,11 @@
             WeakPtr<CommonController> myLeader_;
 
             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.
 
 
                      
         private:
-            //const float ACTION_INTERVAL;
-            void keepSectionTick();
 
-            //LeaderController* leader_;
 
             Timer actionTimer_; //<! Regularly calls action().
            




More information about the Orxonox-commit mailing list