Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7029 for code


Ignore:
Timestamp:
May 30, 2010, 11:54:45 PM (15 years ago)
Author:
solex
Message:

minor changes to ai controllers

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

Legend:

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

    r6997 r7029  
    230230            if (this->specificMasterAction_ == SPIN)
    231231                    this->spin();
     232            if (this->specificMasterAction_ == FOLLOWHUMAN)
     233                    this->follow();
    232234        }
    233235
  • code/branches/ai/src/orxonox/controllers/ArtificialController.cc

    r6997 r7029  
    9191
    9292        XMLPortParam(ArtificialController, "team", setTeam, getTeam, xmlelement, mode).defaultValues(-1);
    93         XMLPortParam(ArtificialController, "formation", setFormationFlight, getFormationFlight, xmlelement, mode).defaultValues(true);
    94     }
    95 
    96 // Documentation only here to get a faster overview for creating a useful documentation, what you're reading here not intended for an actual documentation...
     93        XMLPortParam(ArtificialController, "formationflight", setFormationFlight, getFormationFlight, xmlelement, mode).defaultValues(true);
     94        XMLPortParam(ArtificialController, "formation_size", setFormationSize, getFormationSize, xmlelement, mode).defaultValues(STANDARD_MAX_FORMATION_SIZE);
     95    }
     96
     97// Documentation only here to get a faster overview for creating a useful documentation...
    9798
    9899    /**
     
    231232
    232233    /**
    233         @brief Gets called if ControllableEntity is changed. Resets the bot when it dies.
     234        @brief Gets called when ControllableEntity is being changed. Resets the bot when it dies.
    234235    */
    235236    void ArtificialController::changedControllableEntity()
     
    473474
    474475    /**
    475         @brief Master sets its slaves free for \var FREEDOM_COUNT seconds.
     476        @brief Master sets its slaves free for @var FREEDOM_COUNT seconds.
    476477    */
    477478    void ArtificialController::forceFreeSlaves()
     
    564565    void ArtificialController::spinInit()
    565566    {
    566          COUT(0) << "~spinInit" << std::endl;
     567        COUT(0) << "~spinInit" << std::endl;
    567568        if(this->state_ != MASTER) return;
    568569        this->specificMasterAction_ = SPIN;
     
    582583        @brief Master begins to follow a human player. Is a "specific master action".
    583584        @param humanController human to follow.
    584         @param alaways follows human forever if true - only inplemented for false yet.
    585     */
    586     void ArtificialController::followHuman(Pawn* human, bool always)
    587     {
    588         if (human == NULL)
    589         {
    590             this->specificMasterAction_ = NONE;
     585        @param alaways follows human forever if true, else it follows it for @var SECONDS_TO_FOLLOW_HUMAN seconds.
     586    */
     587    void ArtificialController::followHumanInit(Pawn* human, bool always)
     588    {
     589        COUT(0) << "~followInit" << std::endl;
     590        if (human == NULL || this->state_ != MASTER)
    591591            return;
    592         }
     592
     593        this->specificMasterAction_  =  FOLLOWHUMAN;
     594
     595        this->setTarget(human);
    593596        if (!always)
    594         {
    595             this->setTarget(human);
    596597            this->specificMasterActionHoldCount_ = SECONDS_TO_FOLLOW_HUMAN;
    597             this->specificMasterAction_  =  HOLD;
    598         }
    599 
    600     }
     598        else
     599            this->specificMasterActionHoldCount_ = INT_MAX; //for now...
     600
     601    }
     602
     603    /**
     604        @brief Follows target with adjusted speed. Called within tick.
     605    */
     606    void ArtificialController::follow()
     607    {
     608        this->moveToTargetPosition(); //standard position apprach for now.
     609    }
     610
    601611
    602612
  • code/branches/ai/src/orxonox/controllers/ArtificialController.h

    r6997 r7029  
    2323 *      Fabian 'x3n' Landau
    2424 *   Co-authors:
    25  *      ...
     25 *      Dominik Solenicki
    2626 *
    2727 */
     
    5858            inline bool getFormationFlight() const
    5959                { return this->formationFlight_; }
     60            inline void setFormationSize(int size)
     61                { this->maxFormationSize_ = size; }
     62            inline int getFormationSize() const
     63                { return this->maxFormationSize_; }
    6064            virtual void changedControllableEntity();
    6165
     
    105109            void spinInit();
    106110            void spin();
    107             void followHuman(Pawn* humanController, bool always);
     111            void followHumanInit(Pawn* human, bool always);
     112            void follow();
    108113
    109114            void setTargetPosition(const Vector3& target);
Note: See TracChangeset for help on using the changeset viewer.