[Orxonox-commit 6198] r10856 - code/branches/campaignHS15/src/orxonox/controllers
gania at orxonox.net
gania at orxonox.net
Wed Nov 25 14:05:44 CET 2015
Author: gania
Date: 2015-11-25 14:05:43 +0100 (Wed, 25 Nov 2015)
New Revision: 10856
Modified:
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/DivisionController.h
code/branches/campaignHS15/src/orxonox/controllers/LeaderController.cc
code/branches/campaignHS15/src/orxonox/controllers/LeaderController.h
code/branches/campaignHS15/src/orxonox/controllers/SectionController.cc
code/branches/campaignHS15/src/orxonox/controllers/SectionController.h
code/branches/campaignHS15/src/orxonox/controllers/WingmanController.cc
code/branches/campaignHS15/src/orxonox/controllers/WingmanController.h
Log:
fixed loops
Modified: code/branches/campaignHS15/src/orxonox/controllers/CommonController.cc
===================================================================
--- code/branches/campaignHS15/src/orxonox/controllers/CommonController.cc 2015-11-25 12:51:10 UTC (rev 10855)
+++ code/branches/campaignHS15/src/orxonox/controllers/CommonController.cc 2015-11-25 13:05:43 UTC (rev 10856)
@@ -1119,4 +1119,28 @@
this->bShooting_ = this->canFire();
}
}
+ void CommonController::takeActionpoints (std::vector<Point > vector, std::vector<Point > loop, bool b)
+ {
+ this->parsedActionpoints_ = vector;
+ this->loopActionpoints_ = loop;
+ this->bLoop_ = b;
+ this->setAction (Action::NONE);
+ this->setTarget(0);
+ this->setTargetPosition (this->getControllableEntity()->getWorldPosition());
+ orxout(internal_error) << "Top action is " << this->parsedActionpoints_.back().action << endl;
+ }
+ void CommonController::boostControl()
+ {
+ SpaceShip* ship = orxonox_cast<SpaceShip*>(this->getControllableEntity());
+ if(ship == NULL) return;
+ if(ship->getBoostPower()*1.5f > ship->getInitialBoostPower() ) //upper limit ->boost
+ {
+
+ this->getControllableEntity()->boost(true);
+ }
+ else if(ship->getBoostPower()*4.0f < ship->getInitialBoostPower()) //lower limit ->do not boost
+ {
+ this->getControllableEntity()->boost(false);
+ }
+ }
}
Modified: code/branches/campaignHS15/src/orxonox/controllers/CommonController.h
===================================================================
--- code/branches/campaignHS15/src/orxonox/controllers/CommonController.h 2015-11-25 12:51:10 UTC (rev 10855)
+++ code/branches/campaignHS15/src/orxonox/controllers/CommonController.h 2015-11-25 13:05:43 UTC (rev 10856)
@@ -155,6 +155,7 @@
void setTargetPosition(const Vector3& target);
void setTargetOrientation(const Quaternion& orient);
void setTargetOrientation(ControllableEntity* target);
+ virtual void boostControl();
//----[/Flying methods]----
@@ -226,7 +227,9 @@
bool bFirstTick_;
bool bInLoop_;
bool bLoop_;
- //----[/"Private" variables]----
+ //----[/"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 12:51:10 UTC (rev 10855)
+++ code/branches/campaignHS15/src/orxonox/controllers/DivisionController.cc 2015-11-25 13:05:43 UTC (rev 10856)
@@ -51,8 +51,12 @@
{
if (this->myFollower_)
{
- this->myFollower_->takeActionpoints(this->parsedActionpoints_);
+ this->myFollower_->takeActionpoints(this->parsedActionpoints_, this->loopActionpoints_, this->bLoop_);
}
+ 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])
@@ -82,37 +86,6 @@
{
CommonController::stayNearProtect();
}
- void DivisionController::setTargetPositionOfWingman()
- {
- if (!this->myWingman_)
- return;
- Vector3* targetRelativePositionOfWingman;
- switch (this->formationMode_){
- case FormationMode::WALL:
- {
- targetRelativePositionOfWingman = new Vector3 (400, 0, 0);
- break;
- }
- case FormationMode::FINGER4:
- {
- targetRelativePositionOfWingman = new Vector3 (400, 0, 200);
- break;
- }
-
- case FormationMode::DIAMOND:
- {
- targetRelativePositionOfWingman = new Vector3 (400, 0, 200);
- break;
- }
- }
- Quaternion orient = this->getControllableEntity()->getWorldOrientation();
-
- Vector3 targetAbsolutePositionOfWingman = ((this->getControllableEntity()->getWorldPosition()) +
- (this->getControllableEntity()->getWorldOrientation()* (*targetRelativePositionOfWingman)));
-
- myWingman_->setAction( Action::FLY, targetAbsolutePositionOfWingman, orient);
-
- }
bool DivisionController::setWingman(CommonController* cwingman)
{
Modified: code/branches/campaignHS15/src/orxonox/controllers/DivisionController.h
===================================================================
--- code/branches/campaignHS15/src/orxonox/controllers/DivisionController.h 2015-11-25 12:51:10 UTC (rev 10855)
+++ code/branches/campaignHS15/src/orxonox/controllers/DivisionController.h 2015-11-25 13:05:43 UTC (rev 10856)
@@ -55,8 +55,6 @@
virtual bool setWingman(CommonController* cwingman);
virtual bool hasWingman();
virtual bool hasFollower();
-
- void setTargetPositionOfWingman();
//----[/own functions]----
virtual void stayNearProtect();
Modified: code/branches/campaignHS15/src/orxonox/controllers/LeaderController.cc
===================================================================
--- code/branches/campaignHS15/src/orxonox/controllers/LeaderController.cc 2015-11-25 12:51:10 UTC (rev 10855)
+++ code/branches/campaignHS15/src/orxonox/controllers/LeaderController.cc 2015-11-25 13:05:43 UTC (rev 10856)
@@ -50,14 +50,7 @@
LeaderController::~LeaderController()
{
}
- void LeaderController::takeActionpoints (std::vector<Point > vector)
- {
- this->parsedActionpoints_ = vector;
- this->setAction (Action::NONE);
- this->setTarget(0);
- this->setTargetPosition (this->getControllableEntity()->getWorldPosition());
- orxout(internal_error) << "Top action is " << this->parsedActionpoints_.back().action << endl;
- }
+
}
Modified: code/branches/campaignHS15/src/orxonox/controllers/LeaderController.h
===================================================================
--- code/branches/campaignHS15/src/orxonox/controllers/LeaderController.h 2015-11-25 12:51:10 UTC (rev 10855)
+++ code/branches/campaignHS15/src/orxonox/controllers/LeaderController.h 2015-11-25 13:05:43 UTC (rev 10856)
@@ -52,7 +52,6 @@
virtual bool hasFollower()
{ return true; }
//----[/pseudo virtual methods]----
- virtual void takeActionpoints (std::vector<Point > vector);
protected:
Modified: code/branches/campaignHS15/src/orxonox/controllers/SectionController.cc
===================================================================
--- code/branches/campaignHS15/src/orxonox/controllers/SectionController.cc 2015-11-25 12:51:10 UTC (rev 10855)
+++ code/branches/campaignHS15/src/orxonox/controllers/SectionController.cc 2015-11-25 13:05:43 UTC (rev 10856)
@@ -50,6 +50,10 @@
SectionController::~SectionController()
{
+ 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])
@@ -150,20 +154,7 @@
}
- void SectionController::boostControl()
- {
- SpaceShip* ship = orxonox_cast<SpaceShip*>(this->getControllableEntity());
- if(ship == NULL) return;
- if(ship->getBoostPower()*1.5f > ship->getInitialBoostPower() ) //upper limit ->boost
- {
-
- this->getControllableEntity()->boost(true);
- }
- else if(ship->getBoostPower()*4.0f < ship->getInitialBoostPower()) //lower limit ->do not boost
- {
- this->getControllableEntity()->boost(false);
- }
- }
+
//PRE: myDivisionLeader_ != 0 && myDivisionLeader_->action_ == Action::FIGHT
//POST: this->target_ is set unless division leader doesn't have one
void SectionController::chooseTarget()
@@ -249,38 +240,7 @@
return *targetRelativePosition;
}
- //----stay in formation----
- //gani-TODO: sum targetAbso... and this->predicted position
- void SectionController::setTargetPositionOfWingman()
- {
- if (!this->myWingman_)
- return;
- Vector3* targetRelativePositionOfWingman;
- switch (this->formationMode_){
- case FormationMode::WALL:
- {
- targetRelativePositionOfWingman = new Vector3 (-400, 0, 0);
- break;
- }
- case FormationMode::FINGER4:
- {
- targetRelativePositionOfWingman = new Vector3 (-400, 0, 200);
- break;
- }
- case FormationMode::DIAMOND:
- {
- targetRelativePositionOfWingman = new Vector3 (400, -200, 0);
- break;
- }
- }
- Quaternion orient = this->getControllableEntity()->getWorldOrientation();
-
- Vector3 targetAbsolutePositionOfWingman = ((this->getControllableEntity()->getWorldPosition()) +
- (this->getControllableEntity()->getWorldOrientation()* (*targetRelativePositionOfWingman)));
-
- myWingman_->setAction (Action::FLY, targetAbsolutePositionOfWingman, orient);
-
- }
+
LeaderController* SectionController::findNewDivisionLeader()
{
Modified: code/branches/campaignHS15/src/orxonox/controllers/SectionController.h
===================================================================
--- code/branches/campaignHS15/src/orxonox/controllers/SectionController.h 2015-11-25 12:51:10 UTC (rev 10855)
+++ code/branches/campaignHS15/src/orxonox/controllers/SectionController.h 2015-11-25 13:05:43 UTC (rev 10856)
@@ -51,7 +51,6 @@
//----[own functions]----
LeaderController* findNewDivisionLeader();
- void setTargetPositionOfWingman();
virtual bool setWingman(CommonController* cwingman);
virtual bool hasWingman();
@@ -63,7 +62,6 @@
//----action must only be managed by this----
virtual void action(); //<! action() is called in regular intervals managing the bot's behaviour.
Vector3 getFormationPosition ();
- void boostControl();
private:
//----private variables-----
Timer actionTimer_; //<! Regularly calls action().
Modified: code/branches/campaignHS15/src/orxonox/controllers/WingmanController.cc
===================================================================
--- code/branches/campaignHS15/src/orxonox/controllers/WingmanController.cc 2015-11-25 12:51:10 UTC (rev 10855)
+++ code/branches/campaignHS15/src/orxonox/controllers/WingmanController.cc 2015-11-25 13:05:43 UTC (rev 10856)
@@ -95,13 +95,110 @@
}
else if (this->myLeader_)
{
+ switch (this->myLeader_->getAction())
+ {
+ // case Action::FLY:
+ // {
+ // // Vector3 targetRelativePosition = getFormationPosition();
+ // // Quaternion orient =
+ // // this->myDivisionLeader_->getControllableEntity()->getWorldOrientation();
+ // // Vector3 targetAbsolutePosition =
+ // // ((this->myDivisionLeader_->getControllableEntity()->getWorldPosition()) +
+ // // (orient* (targetRelativePosition)));
+ // // this->setAction (Action::FLY, targetAbsolutePosition, orient);
+ // break;
+ // }
+ // case Action::FIGHT:
+ // {
+ // // this->setAction (Action::FLY, targetAbsolutePosition, orient);
+ // break;
+ // }
+ default:
+ {
+ ControllableEntity* myEntity = this->getControllableEntity();
+ Vector3 myPosition = myEntity->getWorldPosition();
+ if (!this->myLeader_)
+ {
+ return;
+ }
+ ControllableEntity* leaderEntity = this->myLeader_->getControllableEntity();
+ Quaternion orient = leaderEntity->getWorldOrientation();
+ Vector3 leaderPosition = leaderEntity->getWorldPosition();
+
+ Vector3 targetRelativePosition = getFormationPosition();
+ if (!this->myLeader_)
+ {
+ return;
+ }
+ Vector3 targetAbsolutePosition =
+ (leaderPosition + (orient*WorldEntity::FRONT) * (leaderEntity->getVelocity().length()/5)
+ + (orient* (targetRelativePosition)));
+
+ this->setAction (Action::FLY, targetAbsolutePosition, orient);
+ if ((targetAbsolutePosition - myPosition).length() > this->tolerance_ * 1.5f)
+ {
+ this->boostControl();
+ }
+ else
+ {
+ this->getControllableEntity()->boost(false);
+ }
+ }
+ }
}
}
-
+ Vector3 WingmanController::getFormationPosition ()
+ {
+ this->setFormationMode( this->myLeader_->getFormationMode() );
+ Vector3* targetRelativePosition;
+
+ if (this->myLeader_->getRank() == Rank::DIVISIONLEADER)
+ {
+ switch (this->formationMode_){
+ case FormationMode::WALL:
+ {
+ targetRelativePositionOfWingman = new Vector3 (400, 0, 0);
+ break;
+ }
+ case FormationMode::FINGER4:
+ {
+ targetRelativePositionOfWingman = new Vector3 (400, 0, 200);
+ break;
+ }
+ case FormationMode::DIAMOND:
+ {
+ targetRelativePositionOfWingman = new Vector3 (400, 0, 200);
+ break;
+ }
+ }
+ }
+ else
+ {
+ switch (this->formationMode_){
+ case FormationMode::WALL:
+ {
+ targetRelativePositionOfWingman = new Vector3 (-400, 0, 0);
+ break;
+ }
+ case FormationMode::FINGER4:
+ {
+ targetRelativePositionOfWingman = new Vector3 (-400, 0, 200);
+ break;
+ }
+ case FormationMode::DIAMOND:
+ {
+ targetRelativePositionOfWingman = new Vector3 (400, -200, 0);
+ break;
+ }
+ }
+ }
+
+ return *targetRelativePosition;
+ }
//----POST: closest leader that is ready to take a new wingman is returned----
CommonController* WingmanController::findNewLeader()
{
Modified: code/branches/campaignHS15/src/orxonox/controllers/WingmanController.h
===================================================================
--- code/branches/campaignHS15/src/orxonox/controllers/WingmanController.h 2015-11-25 12:51:10 UTC (rev 10855)
+++ code/branches/campaignHS15/src/orxonox/controllers/WingmanController.h 2015-11-25 13:05:43 UTC (rev 10856)
@@ -57,6 +57,7 @@
protected:
//----action must only be managed by this----
virtual void action(); //<! action() is called in regular intervals managing the bot's behaviour.
+ Vector3 getFormationPosition ();
private:
//----private variables-----
More information about the Orxonox-commit
mailing list