[Orxonox-commit 6201] r10859 - in code/branches/campaignHS15: data/levels src/orxonox/controllers

gania at orxonox.net gania at orxonox.net
Wed Nov 25 18:46:21 CET 2015


Author: gania
Date: 2015-11-25 18:46:20 +0100 (Wed, 25 Nov 2015)
New Revision: 10859

Modified:
   code/branches/campaignHS15/data/levels/AITest.oxw
   code/branches/campaignHS15/src/orxonox/controllers/CommonController.cc
   code/branches/campaignHS15/src/orxonox/controllers/CommonController.h
   code/branches/campaignHS15/src/orxonox/controllers/DivisionController.cc
   code/branches/campaignHS15/src/orxonox/controllers/LeaderController.cc
   code/branches/campaignHS15/src/orxonox/controllers/SectionController.cc
   code/branches/campaignHS15/src/orxonox/controllers/WingmanController.cc
Log:
almost all works now, check AITest.oxw

Modified: code/branches/campaignHS15/data/levels/AITest.oxw
===================================================================
--- code/branches/campaignHS15/data/levels/AITest.oxw	2015-11-25 13:53:58 UTC (rev 10858)
+++ code/branches/campaignHS15/data/levels/AITest.oxw	2015-11-25 17:46:20 UTC (rev 10859)
@@ -33,34 +33,14 @@
     <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"/>
     <TeamSpawnPoint team=0 position="-1000,-1000,-1000" lookat="1,1,-1" spawnclass=SpaceShip pawndesign=spaceshipassff />
     
-<!-- 
-    <?lua
-      for i = 0, 5, 1 do
-    ?>
+<!-- HERE STARTS DEMO FOR THE "WAYPOINTS" -->
+    <!--   
+    <Model mesh="cube.mesh" scale=8 position="  0,2000,-600" />
+    <Model mesh="cube.mesh" scale=8 position="  0,2000,-700" />
+    <Model mesh="cube.mesh" scale=8 position="100,2000,-700" />
+    <Model mesh="cube.mesh" scale=8 position="100,2000,-600" />
+    <Model mesh="cube.mesh" scale=8 position="0,0,0" />
 
-    
-    <SpaceShip position="<?lua print(-1600+i*200) ?>,<?lua print(-3000-i*500) ?>, -1500 ?>" lookat="0,0,0">
-      <templates>
-        <Template link=spaceshipassff />
-      </templates>
-      <controller>
-        <AIController accuracy=10 team=2>
-        </AIController>
-      </controller>
-    </SpaceShip>
-    <?lua end ?> -->
- 
-<!--                 <ActionPoint position="12,34,56" action="FIGHT" enemy="ss" />
- -->
-<!--     <SpaceShip position="2000, 1500, -1000" lookat="0,0,0" team=0 name="ss1">
-      <templates>
-        <Template link=spaceshipassff />
-      </templates>
-      <controller>
-        <DivisionController formationMode="wall" action="PROTECT" protect="FUCK" team=0>
-        </DivisionController>
-      </controller>
-    </SpaceShip> -->
     <SpaceShip position="-1500, 1500, -1000" lookat="0,0,0" team=0 name="ss1">
       <templates>
         <Template link=spaceshipassff />
@@ -68,13 +48,21 @@
       <controller>
         <DivisionController team=0 formationMode="finger4">
           <actionpoints>
-            <Actionpoint position="-1000,1000,-1000" action="FLY" loopStart=true />
-            <Actionpoint position="-1250,1250,-500" action="FLY" />
-            <Actionpoint position="-1500,1500,-1000" action="FLY" loopEnd=true />
+            <Actionpoint position="  0,2000,-600" action="FLY" loopStart=true/>
+            <Actionpoint position="  0,2000,-700" action="FLY"  />
+            <Actionpoint position="100,2000,-700" action="FLY" />
+            <Actionpoint position="100,2000,-600" action="FLY" loopEnd=true />
           </actionpoints>
         </DivisionController>
       </controller>
-    </SpaceShip>
+    </SpaceShip> 
+    -->
+<!-- HERE ENDS DEMO FOR THE "WAYPOINTS" -->
+
+<!-- HERE STARTS DEMO FOR THE ACTIONPOINTS -->
+       
+    <Model mesh="cube.mesh" scale=8 position="0,0,0" />
+
     <SpaceShip position="-2000, 1500, -1000" lookat="0,0,0" team=0 name="ss2">
       <templates>
         <Template link=spaceshipassff />
@@ -83,7 +71,7 @@
         <DivisionController team=0 formationMode="finger4">
           <actionpoints>
             <Actionpoint position="0,0,0" action="FLY" />
-            <Actionpoint position="-1000,750,-500" action="ATTACK" enemy="ss3" />
+            <Actionpoint position="-1000,750,-500" action="ATTACK" attack="ss3" />
             <Actionpoint position="-1000,750,-500" action="PROTECt" protect="fuck" />
           </actionpoints>
         </DivisionController>
@@ -98,12 +86,30 @@
         </SectionController>
       </controller>
     </SpaceShip>
+    <SpaceShip position="-2000, 2100, -1000" lookat="0,0,0" team=0>
+      <templates>
+        <Template link=spaceshipassff />
+      </templates>
+      <controller>
+        <WingmanController team=0>
+        </WingmanController>
+      </controller>
+    </SpaceShip>
+    <SpaceShip position="-2000, 2400, -1000" lookat="0,0,0" team=0>
+      <templates>
+        <Template link=spaceshipassff />
+      </templates>
+      <controller>
+        <WingmanController team=0>
+        </WingmanController>
+      </controller>
+    </SpaceShip>
     <SpaceShip position="0, 0, 0" lookat="0,0,0" team=2 name="ss4">
       <templates>
         <Template link=spaceshipassff />
       </templates>
     </SpaceShip>
-    <SpaceShip position="1000, 300, 200" lookat="0,0,0" team=2 name="ss3">
+    <SpaceShip position="3000, 1000, 2000" lookat="0,0,0" team=2 name="ss3">
       <templates>
         <Template link=spaceshipassff />
       </templates>
@@ -113,16 +119,41 @@
         <Template link=spaceshipassff />
       </templates>
     </SpaceShip> 
-   <!--  <SpaceShip position="4000 ,1500, -1600 " lookat="0,0,0" team=0>
+   
+<!-- HERE ENDS DEMO FOR THE ACTIONPOINTS -->
+<!-- HERE STARTS DEMO FOR FIGHTING -->
+   <!--  
+    <SpaceShip position="-2000, 1500, -1000" lookat="0,0,0" team=0 name="ss2">
       <templates>
         <Template link=spaceshipassff />
       </templates>
       <controller>
+        <DivisionController team=0 formationMode="finger4">
+          <actionpoints>
+            <Actionpoint position="0,0,0" action="ATTACK" attack="ss3" />
+          </actionpoints>
+        </DivisionController>
+      </controller>
+    </SpaceShip>
+    <SpaceShip position="-2000, 1900, -1000" lookat="0,0,0" team=0>
+      <templates>
+        <Template link=spaceshipassff />
+      </templates>
+      <controller>
+        <SectionController team=0>
+        </SectionController>
+      </controller>
+    </SpaceShip>
+    <SpaceShip position="-2000, 2100, -1000" lookat="0,0,0" team=0>
+      <templates>
+        <Template link=spaceshipassff />
+      </templates>
+      <controller>
         <WingmanController team=0>
         </WingmanController>
       </controller>
     </SpaceShip>
-    <SpaceShip position="4000, 1500, -2200" lookat="0,0,0" team=0>
+    <SpaceShip position="-2000, 2400, -1000" lookat="0,0,0" team=0>
       <templates>
         <Template link=spaceshipassff />
       </templates>
@@ -131,63 +162,102 @@
         </WingmanController>
       </controller>
     </SpaceShip>
-    <SpaceShip position="4000, 1500, -2800 " lookat="0,0,0" team=0>
+
+    <SpaceShip position="2000, -1500, 1000" lookat="0,0,0" team=1 name="ss3">
       <templates>
         <Template link=spaceshipassff />
       </templates>
       <controller>
-        <SectionController team=0>
-        </SectionController>
+        <DivisionController team=1 formationMode="WALL">
+          <actionpoints>
+            <Actionpoint position="0,0,0" action="ATTACk" attack="ss2" />
+          </actionpoints>
+        </DivisionController>
       </controller>
     </SpaceShip>
-    <SpaceShip position="-4000, 1500, -2800 " lookat="0,0,0" team=0 name="FUCK">
+    <SpaceShip position="2000, -1900, 1000" lookat="0,0,0" team=1>
       <templates>
         <Template link=spaceshipassff />
       </templates>
       <controller>
-        <SectionController team=0>
+        <SectionController team=1>
         </SectionController>
       </controller>
-    </SpaceShip> -->
-    
-    <!-- <SpaceShip position="-4000, 1500, -5000" lookat="0,0,0">
+    </SpaceShip>
+    <SpaceShip position="2000, -2100, 1000" lookat="0,0,0" team=1>
       <templates>
         <Template link=spaceshipassff />
       </templates>
       <controller>
-        <DivisionController team=2 formationMode="wall" action="FIGHT">
-        </DivisionController>
+        <WingmanController team=1>
+        </WingmanController>
       </controller>
     </SpaceShip>
-    <SpaceShip position="-4000 , 1500, -5600" lookat="0,0,0">
+    <SpaceShip position="2000, -2400, 1000" lookat="0,0,0" team=1>
       <templates>
         <Template link=spaceshipassff />
       </templates>
       <controller>
-        <WingmanController team=2>
+        <WingmanController team=1>
         </WingmanController>
       </controller>
+    </SpaceShip> 
+     -->
+<!-- HERE ENDS DEMO FOR FIGHTING -->
+<!-- HERE STARTS DEMO FOR FORMATIONS -->
+    <!-- 
+    <Model mesh="cube.mesh" scale=8 position="   0,2000,    0" />
+    <Model mesh="cube.mesh" scale=8 position="   0,2000,-2000" />
+    <Model mesh="cube.mesh" scale=8 position="2000,2000,-2000" />
+    <Model mesh="cube.mesh" scale=8 position="2000,2000,    0" />
+
+    <SpaceShip position="-1500, 1500, -1000" lookat="0,0,0" team=0 name="ss1">
+      <templates>
+        <Template link=spaceshipassff />
+      </templates>
+      <controller>
+        <DivisionController team=0 formationMode="DIAMOND">
+          <actionpoints>
+            <Actionpoint position="   0,2000,    0" action="FLY" loopStart=true/>
+            <Actionpoint position="   0,2000,-2000" action="FLY"  />
+            <Actionpoint position="2000,2000,-2000" action="FLY" />
+            <Actionpoint position="2000,2000,    0" action="FLY" loopEnd=true />
+          </actionpoints>
+        </DivisionController>
+      </controller>
     </SpaceShip>
-    <SpaceShip position="-4000, 1500, -6200" lookat="0,0,0">
+
+    <SpaceShip position="-2000, 1900, -1000" lookat="0,0,0" team=0>
       <templates>
         <Template link=spaceshipassff />
       </templates>
       <controller>
-        <WingmanController team=2>
+        <SectionController team=0>
+        </SectionController>
+      </controller>
+    </SpaceShip>
+    <SpaceShip position="-2000, 2100, -1000" lookat="0,0,0" team=0>
+      <templates>
+        <Template link=spaceshipassff />
+      </templates>
+      <controller>
+        <WingmanController team=0>
         </WingmanController>
       </controller>
     </SpaceShip>
-    <SpaceShip position="-4000, 1500, -6800 " lookat="0,0,0">
+    <SpaceShip position="-2000, 2400, -1000" lookat="0,0,0" team=0>
       <templates>
         <Template link=spaceshipassff />
       </templates>
       <controller>
-        <SectionController team=2>
-        </SectionController>
+        <WingmanController team=0>
+        </WingmanController>
       </controller>
-    </SpaceShip> -->
-
+    </SpaceShip> 
+    -->
+<!-- HERE ENDS DEMO FOR FORMATIONS -->
     
+    
    
 
   </Scene>

Modified: code/branches/campaignHS15/src/orxonox/controllers/CommonController.cc
===================================================================
--- code/branches/campaignHS15/src/orxonox/controllers/CommonController.cc	2015-11-25 13:53:58 UTC (rev 10858)
+++ code/branches/campaignHS15/src/orxonox/controllers/CommonController.cc	2015-11-25 17:46:20 UTC (rev 10859)
@@ -62,7 +62,7 @@
     
     CommonController::CommonController( Context* context ): Controller( context )
     {
-        this->squaredaccuracy_ = 10000;
+        this->squaredaccuracy_ = 2500;
         this->bFirstTick_ = true;
         this->tolerance_ = 50;
         this->action_ = Action::NONE;
@@ -70,11 +70,13 @@
         this->attackRange_ = 2500;
         this->bInLoop_ = false;
         this->bLoop_ = false;
+        this->bEndLoop_ = false;
+        this->parsedActionpoints_.clear();
         RegisterObject( CommonController );
+
     }
     CommonController::~CommonController() 
     {
-       
     }
     void CommonController::tick(float dt)
     {
@@ -160,7 +162,7 @@
         std::string actionName;
         Vector3 position;
         std::string targetName;
-        bool inLoop;
+        bool inLoop = false;
         Point p;
         if (static_cast<Actionpoint*> (actionpoint))
         {
@@ -169,13 +171,17 @@
             targetName = ap->getName();
             position = ap->getWorldPosition();
 
-            if (!this->bInLoop_ && ap->getStartLoop())
+            if (this->bEndLoop_)
             {
+                this->bInLoop_ = false;
+            }
+            if (!this->bInLoop_ && ap->getLoopStart())
+            {
                 this->bInLoop_ = true;
             }
-            if (this->bInLoop_ && ap->getEndLoop())
+            if (this->bInLoop_ && ap->getLoopEnd())
             {
-                this->bInLoop_ = false;
+                this->bEndLoop_ = true;
             }
             inLoop = this->bInLoop_;
 
@@ -196,7 +202,6 @@
             else
                 ThrowException( ParseError, std::string( "Attempting to set an unknown Action: '" )+ actionName + "'." );
             p.action = value; p.name = targetName; p.position = position; p.inLoop = inLoop;
-            parsedActionpoints_.push_back(p);
         }
         else
         {
@@ -518,7 +523,7 @@
                         ( this->getControllableEntity() ->getOrientation() .getRoll( false ).valueRadians() );
         while( diff>math::twoPi )diff-=math::twoPi;
         while( diff<-math::twoPi )diff+=math::twoPi;
-        this->getControllableEntity() ->rotateRoll( diff*ROTATEFACTOR * dt );
+        this->getControllableEntity() ->rotateRoll( diff*0.2f*ROTATEFACTOR * dt );
     }
     void CommonController::copyTargetOrientation( float dt )
     {
@@ -974,6 +979,8 @@
     }
     void CommonController::nextActionpoint()
     {
+        if (!this || !this->getControllableEntity())
+            return;
         if (this->bLoop_)
         {
             if (!this->loopActionpoints_.empty())
@@ -1018,6 +1025,9 @@
     }
     void CommonController::action()
     {
+        if (!this || !this->getControllableEntity())
+            return;
+        orxout (internal_error) << "Size of actions is " << this->parsedActionpoints_.size() << endl;
         this->startAttackingEnemiesThatAreClose();
         //No action -> pop one from stack
         if (this->action_ == Action::NONE)
@@ -1125,8 +1135,8 @@
       this->loopActionpoints_ = loop;
       this->bLoop_ = b;
       this->setAction (Action::NONE);
-      this->setTarget(0);
-      this->setTargetPosition (this->getControllableEntity()->getWorldPosition());
+      // this->setTarget(0);
+      // this->setTargetPosition (this->getControllableEntity()->getWorldPosition());
       orxout(internal_error) << "Top action is " << this->parsedActionpoints_.back().action << endl;
     }
     void CommonController::boostControl()

Modified: code/branches/campaignHS15/src/orxonox/controllers/CommonController.h
===================================================================
--- code/branches/campaignHS15/src/orxonox/controllers/CommonController.h	2015-11-25 13:53:58 UTC (rev 10858)
+++ code/branches/campaignHS15/src/orxonox/controllers/CommonController.h	2015-11-25 17:46:20 UTC (rev 10859)
@@ -137,7 +137,8 @@
              
                 virtual void stayNearProtect();
                 virtual void action(); //<! action() is called in regular intervals managing the bot's behaviour.
-            
+                 virtual void takeActionpoints (std::vector<Point > vector, std::vector<Point > loop, bool b);
+   
         protected:
             //----[Flying methods]----
                 void stopMoving();
@@ -226,9 +227,9 @@
                 int tolerance_; 
                 bool bFirstTick_; 
                 bool bInLoop_;
-                bool bLoop_;                   
+                bool bLoop_;   
+                bool bEndLoop_;                
             //----[/"Private" variables]----    
-        virtual void takeActionpoints (std::vector<Point > vector, std::vector<Point > loop, bool b);
            
     };
 }

Modified: code/branches/campaignHS15/src/orxonox/controllers/DivisionController.cc
===================================================================
--- code/branches/campaignHS15/src/orxonox/controllers/DivisionController.cc	2015-11-25 13:53:58 UTC (rev 10858)
+++ code/branches/campaignHS15/src/orxonox/controllers/DivisionController.cc	2015-11-25 17:46:20 UTC (rev 10859)
@@ -49,18 +49,21 @@
 
     DivisionController::~DivisionController()
     {
-        if (this->myFollower_)
-        {
-            this->myFollower_->takeActionpoints(this->parsedActionpoints_, this->loopActionpoints_, this->bLoop_);
-            if (this->myWingman_)
-            {
-                this->myWingman_->setAction(Action::FIGHTALL);
-            }
-        }
-        else if (this->myWingman_)
-        {
-            this->myWingman_->takeActionpoints(this->parsedActionpoints_, this->loopActionpoints_, this->bLoop_);
-        }
+        // if (!(this->parsedActionpoints_.empty() && this->loopActionpoints_.empty()))
+        // {
+        //     if (this->myFollower_)
+        //     {
+        //         this->myFollower_->takeActionpoints(this->parsedActionpoints_, this->loopActionpoints_, this->bLoop_);
+        //         if (this->myWingman_)
+        //         {
+        //             this->myWingman_->setAction(Action::FIGHTALL);
+        //         }
+        //     }
+        //     else if (this->myWingman_)
+        //     {
+        //         this->myWingman_->takeActionpoints(this->parsedActionpoints_, this->loopActionpoints_, this->bLoop_);
+        //     }    
+        // }
         for (size_t i = 0; i < this->actionpoints_.size(); ++i)
         {
             if(this->actionpoints_[i])
@@ -84,7 +87,10 @@
     }
     void DivisionController::action()
     {   
+        if (!this || !this->getControllableEntity())
+            return;
         CommonController::action();
+        
     }
     void DivisionController::stayNearProtect()
     {

Modified: code/branches/campaignHS15/src/orxonox/controllers/LeaderController.cc
===================================================================
--- code/branches/campaignHS15/src/orxonox/controllers/LeaderController.cc	2015-11-25 13:53:58 UTC (rev 10858)
+++ code/branches/campaignHS15/src/orxonox/controllers/LeaderController.cc	2015-11-25 17:46:20 UTC (rev 10859)
@@ -51,6 +51,6 @@
     {
     }
     
+    
 
-
 }

Modified: code/branches/campaignHS15/src/orxonox/controllers/SectionController.cc
===================================================================
--- code/branches/campaignHS15/src/orxonox/controllers/SectionController.cc	2015-11-25 13:53:58 UTC (rev 10858)
+++ code/branches/campaignHS15/src/orxonox/controllers/SectionController.cc	2015-11-25 17:46:20 UTC (rev 10859)
@@ -50,10 +50,10 @@
    
     SectionController::~SectionController()
     {
-        if (this->myWingman_)
-        {
-            this->myWingman_->takeActionpoints(this->parsedActionpoints_, this->loopActionpoints_, this->bLoop_);
-        }
+        // if (this->myWingman_)
+        // {
+        //     this->myWingman_->takeActionpoints(this->parsedActionpoints_, this->loopActionpoints_, this->bLoop_);
+        // }
        for (size_t i = 0; i < this->actionpoints_.size(); ++i)
         {
             if(this->actionpoints_[i])
@@ -81,6 +81,8 @@
 
     void SectionController::action()
     {
+        if (!this || !this->getControllableEntity())
+            return;
 
         //----If no leader, find one----  
         if (!myDivisionLeader_)

Modified: code/branches/campaignHS15/src/orxonox/controllers/WingmanController.cc
===================================================================
--- code/branches/campaignHS15/src/orxonox/controllers/WingmanController.cc	2015-11-25 13:53:58 UTC (rev 10858)
+++ code/branches/campaignHS15/src/orxonox/controllers/WingmanController.cc	2015-11-25 17:46:20 UTC (rev 10859)
@@ -129,6 +129,7 @@
                     {
                         return;
                     }
+                    
                     ControllableEntity* leaderEntity = this->myLeader_->getControllableEntity();
                     Quaternion orient = leaderEntity->getWorldOrientation();
                     Vector3 leaderPosition = leaderEntity->getWorldPosition();
@@ -175,37 +176,38 @@
             switch (this->formationMode_){
                 case FormationMode::WALL:
                 {
-                    targetRelativePositionOfWingman = new Vector3 (400, 0, 0);  
+                    targetRelativePosition = new Vector3 (400, 0, 0);  
                     break;
                 }
                 case FormationMode::FINGER4: 
                 {
-                    targetRelativePositionOfWingman = new Vector3 (400, 0, 200);  
+                    targetRelativePosition = new Vector3 (400, 0, 200);  
                     break;
                 }
                 case FormationMode::DIAMOND: 
                 {
-                    targetRelativePositionOfWingman = new Vector3 (400, 0, 200);                  
+                    targetRelativePosition = new Vector3 (400, 0, 200);                  
                     break;
                 }
             }
         }
         else
         {
+
             switch (this->formationMode_){
                 case FormationMode::WALL:
                 {
-                    targetRelativePositionOfWingman = new Vector3 (-400, 0, 0);  
+                    targetRelativePosition = new Vector3 (-400, 0, 0);  
                     break;
                 }
                 case FormationMode::FINGER4: 
                 {
-                    targetRelativePositionOfWingman = new Vector3 (-400, 0, 200);  
+                    targetRelativePosition = new Vector3 (-400, 0, 200);  
                     break;
                 }
                 case FormationMode::DIAMOND: 
                 {
-                    targetRelativePositionOfWingman = new Vector3 (400, -200, 0);                  
+                    targetRelativePosition = new Vector3 (400, -200, 0);                  
                     break;
                 }
             }




More information about the Orxonox-commit mailing list