Changeset 2766 for code/branches
- Timestamp:
- Mar 9, 2009, 12:58:08 AM (16 years ago)
- Location:
- code/branches/tutorial/src/orxonox/objects
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/tutorial/src/orxonox/objects/controllers/DroneController.cc
r2765 r2766 21 21 * 22 22 * Author: 23 * Fabian 'x3n' Landau23 * Oli Scheuss 24 24 * Co-authors: 25 25 * ... … … 42 42 RegisterObject(DroneController); 43 43 44 45 44 46 // this checks that our creator really is a drone 45 47 // and saves the pointer to the drone for the controlling commands … … 56 58 // Place your code here: 57 59 // - steering commands 58 static float totaltime = 0;59 totaltime += dt;60 60 Drone *myDrone = static_cast<Drone*>(this->getControllableEntity()); 61 if(totaltime<1)62 {63 myDrone->moveFrontBack( -sqrt(dt) );64 myDrone->rotatePitch(-dt);65 }61 // you can use the following commands for steering 62 // - moveFrontBack, moveRightLeft, moveUpDown 63 // - rotatePitch, rotateYaw, rotateRoll 64 // - apply the to myDrone (e.g. myDrone->rotateYaw(..) ) 65 66 66 } 67 67 } -
code/branches/tutorial/src/orxonox/objects/controllers/DroneController.h
r2763 r2766 21 21 * 22 22 * Author: 23 * Fabian 'x3n' Landau23 * Oli Scheuss 24 24 * Co-authors: 25 25 * ... -
code/branches/tutorial/src/orxonox/objects/worldentities/Drone.cc
r2765 r2766 21 21 * 22 22 * Author: 23 * Fabian 'x3n' Landau23 * Oli Scheuss 24 24 * Co-authors: 25 25 * ... … … 35 35 namespace orxonox 36 36 { 37 // put your code in here:37 // PLACE YOUR CODE HERE 38 38 // create the factory for the drone 39 39 CreateFactory(Drone); … … 41 41 Drone::Drone(BaseObject* creator) : ControllableEntity(creator) 42 42 { 43 //put your code in here: 43 this->myController_ = 0; 44 // PLACE YOUR CODE HERE 44 45 // - register the drone class to the core 45 46 // - create a new controller and pass our this pointer to it as creator 46 this->myController_ = 0;47 RegisterObject(Drone);48 47 49 48 this->localLinearAcceleration_.setValue(0, 0, 0); … … 70 69 SUPER(Drone, XMLPort, xmlelement, mode); 71 70 72 XMLPortParamVariable(Drone, "primaryThrust", primaryThrust_, xmlelement, mode); 73 XMLPortParamVariable(Drone, "auxilaryThrust", auxilaryThrust_, xmlelement, mode); 74 XMLPortParamVariable(Drone, "rotationThrust", rotationThrust_, xmlelement, mode); 71 // PLACE YOUR CODE HERE 72 // make sure you add the variables primaryThrust_, auxilaryThrust_ and rotationThrust_ to xmlport 73 // variables can be added by the following command 74 // XMLPortParamVariable(Class, "xml-attribute-name", variable_name, xmlelement, mode); 75 75 } 76 76 77 77 void Drone::tick(float dt) 78 78 { 79 SUPER(Drone, tick, dt); 79 // PLACE YOUR CODE HERE 80 // make sure the tick function of the base class gets called here 80 81 81 //if (this->hasLocalController()) 82 //{ 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); 95 //} 82 this->localLinearAcceleration_.setX(this->localLinearAcceleration_.x() * getMass() * this->auxilaryThrust_); 83 this->localLinearAcceleration_.setY(this->localLinearAcceleration_.y() * getMass() * this->auxilaryThrust_); 84 if (this->localLinearAcceleration_.z() > 0) 85 this->localLinearAcceleration_.setZ(this->localLinearAcceleration_.z() * getMass() * this->auxilaryThrust_); 86 else 87 this->localLinearAcceleration_.setZ(this->localLinearAcceleration_.z() * getMass() * this->primaryThrust_); 88 this->physicalBody_->applyCentralForce(physicalBody_->getWorldTransform().getBasis() * this->localLinearAcceleration_); 89 this->localLinearAcceleration_.setValue(0, 0, 0); 90 91 this->localAngularAcceleration_ *= this->getLocalInertia() * this->rotationThrust_; 92 this->physicalBody_->applyTorque(physicalBody_->getWorldTransform().getBasis() * this->localAngularAcceleration_); 93 this->localAngularAcceleration_.setValue(0, 0, 0); 96 94 } 97 95 -
code/branches/tutorial/src/orxonox/objects/worldentities/Drone.h
r2765 r2766 21 21 * 22 22 * Author: 23 * Fabian 'x3n' Landau23 * Oli Scheuss 24 24 * Co-authors: 25 25 * ...
Note: See TracChangeset
for help on using the changeset viewer.