Changeset 5786 for code/branches/tutorial/src
- Timestamp:
- Sep 25, 2009, 4:16:38 PM (15 years ago)
- Location:
- code/branches/tutorial/src/orxonox
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/tutorial/src/orxonox/controllers
- Property svn:mergeinfo changed
/code/branches/libraries2/src/orxonox/controllers reverse-merged: 5734-5735 /code/branches/tutorial/src/orxonox/objects/controllers reverse-merged: 2766-2767
- Property svn:mergeinfo changed
-
code/branches/tutorial/src/orxonox/controllers/DroneController.cc
r5766 r5786 39 39 // - make sure to register the object in the factory 40 40 // - do any kind of initialisation 41 42 41 RegisterObject(DroneController); 43 42 44 43 // this checks that our creator really is a drone … … 56 55 // Place your code here: 57 56 // - steering commands 57 static float totaltime = 0; 58 totaltime += dt; 58 59 Drone *myDrone = static_cast<Drone*>(this->getControllableEntity()); 59 // you can use the following commands for steering60 // - moveFrontBack, moveRightLeft, moveUpDown61 // - rotatePitch, rotateYaw, rotateRoll62 // - apply the to myDrone (e.g. myDrone->rotateYaw(..) )63 60 if(totaltime<100) 61 { 62 myDrone->moveFrontBack( -sqrt(dt) ); 63 myDrone->rotatePitch(-dt); 64 } 64 65 } 65 66 } -
code/branches/tutorial/src/orxonox/worldentities
- Property svn:mergeinfo changed
/code/branches/libraries2/src/orxonox/worldentities reverse-merged: 5734-5737 /code/branches/tutorial/src/orxonox/objects/worldentities reverse-merged: 2766
- Property svn:mergeinfo changed
-
code/branches/tutorial/src/orxonox/worldentities/Drone.cc
r5766 r5786 34 34 namespace orxonox 35 35 { 36 // PLACE YOUR CODE HERE36 // put your code in here: 37 37 // create the factory for the drone 38 38 CreateFactory(Drone); … … 40 40 Drone::Drone(BaseObject* creator) : ControllableEntity(creator) 41 41 { 42 this->myController_ = 0; 43 // PLACE YOUR CODE HERE 42 //put your code in here: 44 43 // - register the drone class to the core 45 44 // - create a new controller and pass our this pointer to it as creator 45 this->myController_ = 0; 46 RegisterObject(Drone); 46 47 47 48 this->localLinearAcceleration_.setValue(0, 0, 0); … … 70 71 SUPER(Drone, XMLPort, xmlelement, mode); 71 72 72 // PLACE YOUR CODE HERE 73 // make sure you add the variables primaryThrust_, auxilaryThrust_ and rotationThrust_ to xmlport 74 // variables can be added by the following command 75 // XMLPortParamVariable(Class, "xml-attribute-name", variable_name, xmlelement, mode); 73 XMLPortParamVariable(Drone, "primaryThrust", primaryThrust_, xmlelement, mode); 74 XMLPortParamVariable(Drone, "auxilaryThrust", auxilaryThrust_, xmlelement, mode); 75 XMLPortParamVariable(Drone, "rotationThrust", rotationThrust_, xmlelement, mode); 76 76 } 77 77 78 78 void Drone::tick(float dt) 79 79 { 80 // PLACE YOUR CODE HERE 81 // make sure the tick function of the base class gets called here 80 SUPER(Drone, tick, dt); 82 81 83 this->localLinearAcceleration_.setX(this->localLinearAcceleration_.x() * getMass() * this->auxilaryThrust_); 84 this->localLinearAcceleration_.setY(this->localLinearAcceleration_.y() * getMass() * this->auxilaryThrust_); 85 if (this->localLinearAcceleration_.z() > 0) 86 this->localLinearAcceleration_.setZ(this->localLinearAcceleration_.z() * getMass() * this->auxilaryThrust_); 87 else 88 this->localLinearAcceleration_.setZ(this->localLinearAcceleration_.z() * getMass() * this->primaryThrust_); 89 this->physicalBody_->applyCentralForce(physicalBody_->getWorldTransform().getBasis() * this->localLinearAcceleration_); 90 this->localLinearAcceleration_.setValue(0, 0, 0); 91 92 this->localAngularAcceleration_ *= this->getLocalInertia() * this->rotationThrust_; 93 this->physicalBody_->applyTorque(physicalBody_->getWorldTransform().getBasis() * this->localAngularAcceleration_); 94 this->localAngularAcceleration_.setValue(0, 0, 0); 82 //if (this->hasLocalController()) 83 //{ 84 this->localLinearAcceleration_.setX(this->localLinearAcceleration_.x() * getMass() * this->auxilaryThrust_); 85 this->localLinearAcceleration_.setY(this->localLinearAcceleration_.y() * getMass() * this->auxilaryThrust_); 86 if (this->localLinearAcceleration_.z() > 0) 87 this->localLinearAcceleration_.setZ(this->localLinearAcceleration_.z() * getMass() * this->auxilaryThrust_); 88 else 89 this->localLinearAcceleration_.setZ(this->localLinearAcceleration_.z() * getMass() * this->primaryThrust_); 90 this->physicalBody_->applyCentralForce(physicalBody_->getWorldTransform().getBasis() * this->localLinearAcceleration_); 91 this->localLinearAcceleration_.setValue(0, 0, 0); 92 93 this->localAngularAcceleration_ *= this->getLocalInertia() * this->rotationThrust_; 94 this->physicalBody_->applyTorque(physicalBody_->getWorldTransform().getBasis() * this->localAngularAcceleration_); 95 this->localAngularAcceleration_.setValue(0, 0, 0); 96 //} 95 97 } 96 98
Note: See TracChangeset
for help on using the changeset viewer.