[Orxonox-commit 2314] r7029 - code/branches/ai/src/orxonox/controllers
solex at orxonox.net
solex at orxonox.net
Sun May 30 23:54:46 CEST 2010
Author: solex
Date: 2010-05-30 23:54:45 +0200 (Sun, 30 May 2010)
New Revision: 7029
Modified:
code/branches/ai/src/orxonox/controllers/AIController.cc
code/branches/ai/src/orxonox/controllers/ArtificialController.cc
code/branches/ai/src/orxonox/controllers/ArtificialController.h
Log:
minor changes to ai controllers
Modified: code/branches/ai/src/orxonox/controllers/AIController.cc
===================================================================
--- code/branches/ai/src/orxonox/controllers/AIController.cc 2010-05-30 20:21:41 UTC (rev 7028)
+++ code/branches/ai/src/orxonox/controllers/AIController.cc 2010-05-30 21:54:45 UTC (rev 7029)
@@ -229,6 +229,8 @@
if (this->specificMasterAction_ == SPIN)
this->spin();
+ if (this->specificMasterAction_ == FOLLOWHUMAN)
+ this->follow();
}
if (this->state_ == SLAVE)
Modified: code/branches/ai/src/orxonox/controllers/ArtificialController.cc
===================================================================
--- code/branches/ai/src/orxonox/controllers/ArtificialController.cc 2010-05-30 20:21:41 UTC (rev 7028)
+++ code/branches/ai/src/orxonox/controllers/ArtificialController.cc 2010-05-30 21:54:45 UTC (rev 7029)
@@ -90,10 +90,11 @@
SUPER(ArtificialController, XMLPort, xmlelement, mode);
XMLPortParam(ArtificialController, "team", setTeam, getTeam, xmlelement, mode).defaultValues(-1);
- XMLPortParam(ArtificialController, "formation", setFormationFlight, getFormationFlight, xmlelement, mode).defaultValues(true);
+ XMLPortParam(ArtificialController, "formationflight", setFormationFlight, getFormationFlight, xmlelement, mode).defaultValues(true);
+ XMLPortParam(ArtificialController, "formation_size", setFormationSize, getFormationSize, xmlelement, mode).defaultValues(STANDARD_MAX_FORMATION_SIZE);
}
-// Documentation only here to get a faster overview for creating a useful documentation, what you're reading here not intended for an actual documentation...
+// Documentation only here to get a faster overview for creating a useful documentation...
/**
@brief Activates / deactivates formationflight behaviour
@@ -230,7 +231,7 @@
}
/**
- @brief Gets called if ControllableEntity is changed. Resets the bot when it dies.
+ @brief Gets called when ControllableEntity is being changed. Resets the bot when it dies.
*/
void ArtificialController::changedControllableEntity()
{
@@ -472,7 +473,7 @@
}
/**
- @brief Master sets its slaves free for \var FREEDOM_COUNT seconds.
+ @brief Master sets its slaves free for @var FREEDOM_COUNT seconds.
*/
void ArtificialController::forceFreeSlaves()
{
@@ -563,7 +564,7 @@
*/
void ArtificialController::spinInit()
{
- COUT(0) << "~spinInit" << std::endl;
+ COUT(0) << "~spinInit" << std::endl;
if(this->state_ != MASTER) return;
this->specificMasterAction_ = SPIN;
this->specificMasterActionHoldCount_ = 10;
@@ -581,25 +582,34 @@
/**
@brief Master begins to follow a human player. Is a "specific master action".
@param humanController human to follow.
- @param alaways follows human forever if true - only inplemented for false yet.
+ @param alaways follows human forever if true, else it follows it for @var SECONDS_TO_FOLLOW_HUMAN seconds.
*/
- void ArtificialController::followHuman(Pawn* human, bool always)
+ void ArtificialController::followHumanInit(Pawn* human, bool always)
{
- if (human == NULL)
- {
- this->specificMasterAction_ = NONE;
+ COUT(0) << "~followInit" << std::endl;
+ if (human == NULL || this->state_ != MASTER)
return;
- }
+
+ this->specificMasterAction_ = FOLLOWHUMAN;
+
+ this->setTarget(human);
if (!always)
- {
- this->setTarget(human);
this->specificMasterActionHoldCount_ = SECONDS_TO_FOLLOW_HUMAN;
- this->specificMasterAction_ = HOLD;
- }
+ else
+ this->specificMasterActionHoldCount_ = INT_MAX; //for now...
}
+ /**
+ @brief Follows target with adjusted speed. Called within tick.
+ */
+ void ArtificialController::follow()
+ {
+ this->moveToTargetPosition(); //standard position apprach for now.
+ }
+
+
void ArtificialController::setTargetPosition(const Vector3& target)
{
this->targetPosition_ = target;
Modified: code/branches/ai/src/orxonox/controllers/ArtificialController.h
===================================================================
--- code/branches/ai/src/orxonox/controllers/ArtificialController.h 2010-05-30 20:21:41 UTC (rev 7028)
+++ code/branches/ai/src/orxonox/controllers/ArtificialController.h 2010-05-30 21:54:45 UTC (rev 7029)
@@ -22,7 +22,7 @@
* Author:
* Fabian 'x3n' Landau
* Co-authors:
- * ...
+ * Dominik Solenicki
*
*/
@@ -57,6 +57,10 @@
{ this->formationFlight_ = formation; }
inline bool getFormationFlight() const
{ return this->formationFlight_; }
+ inline void setFormationSize(int size)
+ { this->maxFormationSize_ = size; }
+ inline int getFormationSize() const
+ { return this->maxFormationSize_; }
virtual void changedControllableEntity();
static void formationflight(bool form);
@@ -104,7 +108,8 @@
void turn180();
void spinInit();
void spin();
- void followHuman(Pawn* humanController, bool always);
+ void followHumanInit(Pawn* human, bool always);
+ void follow();
void setTargetPosition(const Vector3& target);
void searchRandomTargetPosition();
More information about the Orxonox-commit
mailing list