Changeset 10856 for code/branches/campaignHS15/src
- Timestamp:
- Nov 25, 2015, 2:05:43 PM (9 years ago)
- Location:
- code/branches/campaignHS15/src/orxonox/controllers
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/campaignHS15/src/orxonox/controllers/CommonController.cc
r10855 r10856 1120 1120 } 1121 1121 } 1122 void CommonController::takeActionpoints (std::vector<Point > vector, std::vector<Point > loop, bool b) 1123 { 1124 this->parsedActionpoints_ = vector; 1125 this->loopActionpoints_ = loop; 1126 this->bLoop_ = b; 1127 this->setAction (Action::NONE); 1128 this->setTarget(0); 1129 this->setTargetPosition (this->getControllableEntity()->getWorldPosition()); 1130 orxout(internal_error) << "Top action is " << this->parsedActionpoints_.back().action << endl; 1131 } 1132 void CommonController::boostControl() 1133 { 1134 SpaceShip* ship = orxonox_cast<SpaceShip*>(this->getControllableEntity()); 1135 if(ship == NULL) return; 1136 if(ship->getBoostPower()*1.5f > ship->getInitialBoostPower() ) //upper limit ->boost 1137 { 1138 1139 this->getControllableEntity()->boost(true); 1140 } 1141 else if(ship->getBoostPower()*4.0f < ship->getInitialBoostPower()) //lower limit ->do not boost 1142 { 1143 this->getControllableEntity()->boost(false); 1144 } 1145 } 1122 1146 } -
code/branches/campaignHS15/src/orxonox/controllers/CommonController.h
r10855 r10856 156 156 void setTargetOrientation(const Quaternion& orient); 157 157 void setTargetOrientation(ControllableEntity* target); 158 virtual void boostControl(); 158 159 159 160 … … 227 228 bool bInLoop_; 228 229 bool bLoop_; 229 //----[/"Private" variables]---- 230 //----[/"Private" variables]---- 231 virtual void takeActionpoints (std::vector<Point > vector, std::vector<Point > loop, bool b); 232 230 233 }; 231 234 } -
code/branches/campaignHS15/src/orxonox/controllers/DivisionController.cc
r10855 r10856 52 52 if (this->myFollower_) 53 53 { 54 this->myFollower_->takeActionpoints(this->parsedActionpoints_); 54 this->myFollower_->takeActionpoints(this->parsedActionpoints_, this->loopActionpoints_, this->bLoop_); 55 } 56 else if (this->myWingman_) 57 { 58 this->myWingman_->takeActionpoints(this->parsedActionpoints_, this->loopActionpoints_, this->bLoop_); 55 59 } 56 60 for (size_t i = 0; i < this->actionpoints_.size(); ++i) … … 82 86 { 83 87 CommonController::stayNearProtect(); 84 }85 void DivisionController::setTargetPositionOfWingman()86 {87 if (!this->myWingman_)88 return;89 Vector3* targetRelativePositionOfWingman;90 switch (this->formationMode_){91 case FormationMode::WALL:92 {93 targetRelativePositionOfWingman = new Vector3 (400, 0, 0);94 break;95 }96 case FormationMode::FINGER4:97 {98 targetRelativePositionOfWingman = new Vector3 (400, 0, 200);99 break;100 }101 102 case FormationMode::DIAMOND:103 {104 targetRelativePositionOfWingman = new Vector3 (400, 0, 200);105 break;106 }107 }108 Quaternion orient = this->getControllableEntity()->getWorldOrientation();109 110 Vector3 targetAbsolutePositionOfWingman = ((this->getControllableEntity()->getWorldPosition()) +111 (this->getControllableEntity()->getWorldOrientation()* (*targetRelativePositionOfWingman)));112 113 myWingman_->setAction( Action::FLY, targetAbsolutePositionOfWingman, orient);114 115 88 } 116 89 -
code/branches/campaignHS15/src/orxonox/controllers/DivisionController.h
r10854 r10856 56 56 virtual bool hasWingman(); 57 57 virtual bool hasFollower(); 58 59 void setTargetPositionOfWingman();60 58 61 59 //----[/own functions]---- -
code/branches/campaignHS15/src/orxonox/controllers/LeaderController.cc
r10854 r10856 51 51 { 52 52 } 53 void LeaderController::takeActionpoints (std::vector<Point > vector) 54 { 55 this->parsedActionpoints_ = vector; 56 this->setAction (Action::NONE); 57 this->setTarget(0); 58 this->setTargetPosition (this->getControllableEntity()->getWorldPosition()); 59 orxout(internal_error) << "Top action is " << this->parsedActionpoints_.back().action << endl; 60 } 53 61 54 62 55 -
code/branches/campaignHS15/src/orxonox/controllers/LeaderController.h
r10854 r10856 53 53 { return true; } 54 54 //----[/pseudo virtual methods]---- 55 virtual void takeActionpoints (std::vector<Point > vector);56 55 57 56 -
code/branches/campaignHS15/src/orxonox/controllers/SectionController.cc
r10854 r10856 51 51 SectionController::~SectionController() 52 52 { 53 if (this->myWingman_) 54 { 55 this->myWingman_->takeActionpoints(this->parsedActionpoints_, this->loopActionpoints_, this->bLoop_); 56 } 53 57 for (size_t i = 0; i < this->actionpoints_.size(); ++i) 54 58 { … … 151 155 } 152 156 153 void SectionController::boostControl() 154 { 155 SpaceShip* ship = orxonox_cast<SpaceShip*>(this->getControllableEntity()); 156 if(ship == NULL) return; 157 if(ship->getBoostPower()*1.5f > ship->getInitialBoostPower() ) //upper limit ->boost 158 { 159 160 this->getControllableEntity()->boost(true); 161 } 162 else if(ship->getBoostPower()*4.0f < ship->getInitialBoostPower()) //lower limit ->do not boost 163 { 164 this->getControllableEntity()->boost(false); 165 } 166 } 157 167 158 //PRE: myDivisionLeader_ != 0 && myDivisionLeader_->action_ == Action::FIGHT 168 159 //POST: this->target_ is set unless division leader doesn't have one … … 250 241 } 251 242 252 //----stay in formation---- 253 //gani-TODO: sum targetAbso... and this->predicted position 254 void SectionController::setTargetPositionOfWingman() 255 { 256 if (!this->myWingman_) 257 return; 258 Vector3* targetRelativePositionOfWingman; 259 switch (this->formationMode_){ 260 case FormationMode::WALL: 261 { 262 targetRelativePositionOfWingman = new Vector3 (-400, 0, 0); 263 break; 264 } 265 case FormationMode::FINGER4: 266 { 267 targetRelativePositionOfWingman = new Vector3 (-400, 0, 200); 268 break; 269 } 270 case FormationMode::DIAMOND: 271 { 272 targetRelativePositionOfWingman = new Vector3 (400, -200, 0); 273 break; 274 } 275 } 276 Quaternion orient = this->getControllableEntity()->getWorldOrientation(); 277 278 Vector3 targetAbsolutePositionOfWingman = ((this->getControllableEntity()->getWorldPosition()) + 279 (this->getControllableEntity()->getWorldOrientation()* (*targetRelativePositionOfWingman))); 280 281 myWingman_->setAction (Action::FLY, targetAbsolutePositionOfWingman, orient); 282 283 } 243 284 244 285 245 LeaderController* SectionController::findNewDivisionLeader() -
code/branches/campaignHS15/src/orxonox/controllers/SectionController.h
r10854 r10856 52 52 //----[own functions]---- 53 53 LeaderController* findNewDivisionLeader(); 54 void setTargetPositionOfWingman();55 54 56 55 virtual bool setWingman(CommonController* cwingman); … … 64 63 virtual void action(); //<! action() is called in regular intervals managing the bot's behaviour. 65 64 Vector3 getFormationPosition (); 66 void boostControl();67 65 private: 68 66 //----private variables----- -
code/branches/campaignHS15/src/orxonox/controllers/WingmanController.cc
r10854 r10856 96 96 else if (this->myLeader_) 97 97 { 98 98 switch (this->myLeader_->getAction()) 99 { 100 // case Action::FLY: 101 // { 102 // // Vector3 targetRelativePosition = getFormationPosition(); 103 // // Quaternion orient = 104 // // this->myDivisionLeader_->getControllableEntity()->getWorldOrientation(); 105 // // Vector3 targetAbsolutePosition = 106 // // ((this->myDivisionLeader_->getControllableEntity()->getWorldPosition()) + 107 // // (orient* (targetRelativePosition))); 108 // // this->setAction (Action::FLY, targetAbsolutePosition, orient); 109 // break; 110 // } 111 // case Action::FIGHT: 112 // { 113 114 // // this->setAction (Action::FLY, targetAbsolutePosition, orient); 115 // break; 116 // } 117 default: 118 { 119 ControllableEntity* myEntity = this->getControllableEntity(); 120 Vector3 myPosition = myEntity->getWorldPosition(); 121 if (!this->myLeader_) 122 { 123 return; 124 } 125 ControllableEntity* leaderEntity = this->myLeader_->getControllableEntity(); 126 Quaternion orient = leaderEntity->getWorldOrientation(); 127 Vector3 leaderPosition = leaderEntity->getWorldPosition(); 128 129 Vector3 targetRelativePosition = getFormationPosition(); 130 if (!this->myLeader_) 131 { 132 return; 133 } 134 Vector3 targetAbsolutePosition = 135 (leaderPosition + (orient*WorldEntity::FRONT) * (leaderEntity->getVelocity().length()/5) 136 + (orient* (targetRelativePosition))); 137 138 this->setAction (Action::FLY, targetAbsolutePosition, orient); 139 if ((targetAbsolutePosition - myPosition).length() > this->tolerance_ * 1.5f) 140 { 141 this->boostControl(); 142 } 143 else 144 { 145 this->getControllableEntity()->boost(false); 146 } 147 } 148 } 99 149 } 100 150 … … 102 152 103 153 104 154 Vector3 WingmanController::getFormationPosition () 155 { 156 this->setFormationMode( this->myLeader_->getFormationMode() ); 157 Vector3* targetRelativePosition; 158 159 if (this->myLeader_->getRank() == Rank::DIVISIONLEADER) 160 { 161 switch (this->formationMode_){ 162 case FormationMode::WALL: 163 { 164 targetRelativePositionOfWingman = new Vector3 (400, 0, 0); 165 break; 166 } 167 case FormationMode::FINGER4: 168 { 169 targetRelativePositionOfWingman = new Vector3 (400, 0, 200); 170 break; 171 } 172 case FormationMode::DIAMOND: 173 { 174 targetRelativePositionOfWingman = new Vector3 (400, 0, 200); 175 break; 176 } 177 } 178 } 179 else 180 { 181 switch (this->formationMode_){ 182 case FormationMode::WALL: 183 { 184 targetRelativePositionOfWingman = new Vector3 (-400, 0, 0); 185 break; 186 } 187 case FormationMode::FINGER4: 188 { 189 targetRelativePositionOfWingman = new Vector3 (-400, 0, 200); 190 break; 191 } 192 case FormationMode::DIAMOND: 193 { 194 targetRelativePositionOfWingman = new Vector3 (400, -200, 0); 195 break; 196 } 197 } 198 } 199 200 return *targetRelativePosition; 201 } 105 202 //----POST: closest leader that is ready to take a new wingman is returned---- 106 203 CommonController* WingmanController::findNewLeader() -
code/branches/campaignHS15/src/orxonox/controllers/WingmanController.h
r10851 r10856 58 58 //----action must only be managed by this---- 59 59 virtual void action(); //<! action() is called in regular intervals managing the bot's behaviour. 60 Vector3 getFormationPosition (); 60 61 61 62 private:
Note: See TracChangeset
for help on using the changeset viewer.