Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 17, 2010, 4:36:18 PM (15 years ago)
Author:
gasserlu
Message:

drone follows in realistic matter

Location:
code/branches/ai/src/orxonox/controllers
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • code/branches/ai/src/orxonox/controllers/ArtificialController.cc

    r6891 r6918  
    3636#include "gametypes/TeamDeathmatch.h"
    3737#include "controllers/WaypointPatrolController.h"
     38#include "controllers/DroneController.h"
    3839#include "util/Math.h"
    3940
     
    348349    void ArtificialController::searchNewTarget()
    349350    {
     351COUT(0) << "search new target - start" << std::endl;
    350352        if (!this->getControllableEntity())
    351353            return;
     
    372374            }
    373375        }
     376COUT(0) << "search new target - end: " << this->target_ << std::endl;
    374377    }
    375378
  • code/branches/ai/src/orxonox/controllers/CMakeLists.txt

    r6854 r6918  
    88  WaypointController.cc
    99  WaypointPatrolController.cc
    10   DroneController.cc 
     10  DroneController.cc
    1111)
  • code/branches/ai/src/orxonox/controllers/DroneController.cc

    r6891 r6918  
    4747    DroneController::DroneController(BaseObject* creator) : ArtificialController(creator)
    4848    {
    49         // - do any kind of initialisation
    50 
    51         // this checks that our creator really is a drone
    52         // and saves the pointer to the drone for the controlling commands
    53 
    54    
    5549        RegisterObject(DroneController);
    5650
     
    8680
    8781        const Vector3& locOwnerDir = getDrone()->getOrientation().UnitInverse()*(ownerPosition-dronePosition); //Vector from Drone To Owner out of drones local coordinate system
    88 
    89         int distance = sqrt( (ownerPosition.x-dronePosition.x)*(ownerPosition.x-dronePosition.x)
    90                            + (ownerPosition.y-dronePosition.y)*(ownerPosition.y-dronePosition.y)
    91                            + (ownerPosition.z-dronePosition.z)*(ownerPosition.z-dronePosition.z)); //distance to Owner
    92 
    93         if (distance > 500) { //TODO: variable implementation of maxdistance
    94             drone_->moveUpDown(locOwnerDir.y);
    95             drone_->moveFrontBack(-locOwnerDir.z);
    96             drone_->moveRightLeft(locOwnerDir.x);
    97         }
    98 
    99 
     82/*
     83        int distance_square  = (ownerPosition.x-dronePosition.x)*(ownerPosition.x-dronePosition.x)
     84                             + (ownerPosition.y-dronePosition.y)*(ownerPosition.y-dronePosition.y)
     85                             + (ownerPosition.z-dronePosition.z)*(ownerPosition.z-dronePosition.z); //distance to Owner squared
     86*/
    10087        random = rnd(maxrand);
    10188        if ( random < 30 && (!this->target_))
    10289            this->searchNewTarget();
    103 
    104 
    105         this->aimAtTarget();
    106         drone_->fire(0);
     90/*
     91        //face target
     92        drone_->rotateYaw(-targetPosition_.x);
     93        drone_->rotatePitch(targetPosition_.y);
     94  */     
     95        if (this->target_)
     96        {
     97            this->aimAtTarget();
     98            drone_->fire(0);
     99        }
    107100         
    108101
    109102
    110 
    111         //COUT(0) << "Drone: " << dronePosition << endl;
    112         //COUT(0) << "Distance: " << distance << endl;
     103/*
     104        COUT(0) << "Drone: " << dronePosition << endl;
     105        COUT(0) << "Distance: " << distance << endl;
    113106        COUT(0) << "locDrone: " << locOwnerDir << endl;
    114107        COUT(0) << "target: " << targetPosition_ << endl;
    115108        COUT(0) << "Owner: " << ownerPosition << endl;
    116109        COUT(0) << "Rand: " << random << endl;
    117 
     110*/
    118111/*
    119112        // search enemy
     
    171164        Drone *myDrone = static_cast<Drone*>(this->getControllableEntity());
    172165
    173         if(myDrone != NULL) {
    174 
    175         setTargetPosition(this->getControllableEntity()->getPosition());
     166        if ((this->getDrone()->getWorldPosition() - this->getOwner()->getWorldPosition()).squaredLength()  > 150*150) { //TODO: variable implementation of maxdistance
     167            this->moveToPosition(this->getOwner()->getWorldPosition());
    176168
    177169        }
  • code/branches/ai/src/orxonox/controllers/DroneController.h

    r6891 r6918  
    4747        Oli Scheuss
    4848    */
    49     class _OrxonoxExport DroneController : public ArtificialController
     49    class _OrxonoxExport DroneController : public ArtificialController, public Tickable
    5050    {
    5151        public:
Note: See TracChangeset for help on using the changeset viewer.