[Orxonox-commit 6139] r10797 - code/branches/AI_HS15/src/orxonox/controllers

gania at orxonox.net gania at orxonox.net
Thu Nov 12 11:27:41 CET 2015


Author: gania
Date: 2015-11-12 11:27:41 +0100 (Thu, 12 Nov 2015)
New Revision: 10797

Modified:
   code/branches/AI_HS15/src/orxonox/controllers/CommonController.cc
   code/branches/AI_HS15/src/orxonox/controllers/DivisionController.cc
Log:
low on battery

Modified: code/branches/AI_HS15/src/orxonox/controllers/CommonController.cc
===================================================================
--- code/branches/AI_HS15/src/orxonox/controllers/CommonController.cc	2015-11-12 08:30:14 UTC (rev 10796)
+++ code/branches/AI_HS15/src/orxonox/controllers/CommonController.cc	2015-11-12 10:27:41 UTC (rev 10797)
@@ -116,6 +116,76 @@
 
         }
     }
+    void CommonController::maneuver()
+    {
+
+        if (this->target_ && this->bHasPositionOfTarget_ && this->getControllableEntity())
+        {
+            Vector3 diffVector = this->positionOfTarget_ - this->getControllableEntity()->getWorldPosition();
+            float diffLength = diffVector.length();
+            Vector3 diffUnit = diffVector/diffLength;
+
+            Vector3 myForwardVector = this->getControllableEntity()->getOrientation() * WorldEntity::FRONT;
+            float myDotProduct = diffVector.dotProduct(myForwardVector);
+
+            Vector3 opponentForwardVector = this->target_->getOrientation() * WorldEntity::FRONT;
+            float opponentDotProduct = diffVector.dotProduct(opponentForwardVector);            
+
+            float myAngle = math::arccos ( myForwardVector.dotProduct(diffVector)/(diffLength) );
+            float targetAngle = math::arccos ( opponentForwardVector.dotProduct(-diffVector)/(diffLength) );
+            
+            bool bThisIsLookingAtTarget = (myAngle/(diffLength*diffLength) < math::pi/8000000.0f);
+            bool bTargetIsLookingAtThis = (targetAngle/(diffLength*diffLength) < math::pi/8000000.0f);
+            
+            float angleDiff = targetAngle - myAngle;
+            //I am looking when my angle < pi/6
+            //if his angle is bigger than mine
+            if ( angleDiff > 0 )
+            {
+                //if diff is insignificant
+                if ( bThisIsLookingAtTarget && bTargetIsLookingAtThis )
+                {
+                    //if this can make target overshoot
+                    if ( diffLength < 200 )
+                    {
+                        Vector3* target = new Vector3 ( 0, -200, -200 );
+                        moveToPoint( 
+                            *target, 
+                            randomInRange(45, 180) 
+                            );
+                    }
+                    //do scissors
+                    else
+                    {
+                        Vector3 target = (diffUnit) * 150.0f
+                        Vector3* randVector = new Vector3( 
+                            randomInRange(-300, 300), 
+                            randomInRange(-300, 300), 
+                            randomInRange(-300, 300)  
+                        );
+                        Vector3 projection = randVector.dotProduct(diffUnit) * diffUnit;
+                        *randVector -= projection;
+                        target += randVector;
+                        moveToPoint( 
+                            *target, 
+                            randomInRange(45, 180) 
+                            );
+                    }
+                }
+                //this has advantage
+                else
+                {
+
+                }
+            }
+           
+        }
+        if (this->getControllableEntity() && !this->target_)
+        {
+            this->maneuverType_ = ManeuverType::NONE;
+        }
+        orxout (internal_error) << "ManeuverType = " << this->maneuverType_ << endl;
+    }
     void CommonController::chooseManeuverType()
     {
 

Modified: code/branches/AI_HS15/src/orxonox/controllers/DivisionController.cc
===================================================================
--- code/branches/AI_HS15/src/orxonox/controllers/DivisionController.cc	2015-11-12 08:30:14 UTC (rev 10796)
+++ code/branches/AI_HS15/src/orxonox/controllers/DivisionController.cc	2015-11-12 10:27:41 UTC (rev 10797)
@@ -170,10 +170,10 @@
             executingMoveToPoint_ = true;
         }
         */
-        if (this->myFollower_ && this->target_)
-            this->myFollower_->setTarget(this->target_);
-        if (this->target_ && this->myWingman_)
-            this->myWingman_->setTarget(this->target_);
+        // if (this->myFollower_ && this->target_)
+        //     this->myFollower_->setTarget(this->target_);
+        // if (this->target_ && this->myWingman_)
+        //     this->myWingman_->setTarget(this->target_);
     /*            
         for (ObjectList<Controller>::iterator it = ObjectList<Controller>::begin(); it; ++it)
         {




More information about the Orxonox-commit mailing list