Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 2766


Ignore:
Timestamp:
Mar 9, 2009, 12:58:08 AM (16 years ago)
Author:
scheusso
Message:

removed the lines that the student have to find out themselves

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  
    2121 *
    2222 *   Author:
    23  *      Fabian 'x3n' Landau
     23 *      Oli Scheuss
    2424 *   Co-authors:
    2525 *      ...
     
    4242        RegisterObject(DroneController);
    4343       
     44       
     45       
    4446        // this checks that our creator really is a drone
    4547        // and saves the pointer to the drone for the controlling commands
     
    5658        // Place your code here:
    5759        // - steering commands
    58         static float totaltime = 0;
    59         totaltime += dt;
    6060        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       
    6666    }
    6767}
  • code/branches/tutorial/src/orxonox/objects/controllers/DroneController.h

    r2763 r2766  
    2121 *
    2222 *   Author:
    23  *      Fabian 'x3n' Landau
     23 *      Oli Scheuss
    2424 *   Co-authors:
    2525 *      ...
  • code/branches/tutorial/src/orxonox/objects/worldentities/Drone.cc

    r2765 r2766  
    2121 *
    2222 *   Author:
    23  *      Fabian 'x3n' Landau
     23 *      Oli Scheuss
    2424 *   Co-authors:
    2525 *      ...
     
    3535namespace orxonox
    3636{
    37     // put your code in here:
     37    // PLACE YOUR CODE HERE
    3838    // create the factory for the drone
    3939    CreateFactory(Drone);
     
    4141    Drone::Drone(BaseObject* creator) : ControllableEntity(creator)
    4242    {
    43         //put your code in here:
     43        this->myController_ = 0;
     44        // PLACE YOUR CODE HERE
    4445        // - register the drone class to the core
    4546        // - create a new controller and pass our this pointer to it as creator
    46         this->myController_ = 0;
    47         RegisterObject(Drone);
    4847       
    4948        this->localLinearAcceleration_.setValue(0, 0, 0);
     
    7069        SUPER(Drone, XMLPort, xmlelement, mode);
    7170
    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);
    7575    }
    7676
    7777    void Drone::tick(float dt)
    7878    {
    79         SUPER(Drone, tick, dt);
     79        // PLACE YOUR CODE HERE
     80        // make sure the tick function of the base class gets called here
    8081       
    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);
    9694    }
    9795   
  • code/branches/tutorial/src/orxonox/objects/worldentities/Drone.h

    r2765 r2766  
    2121 *
    2222 *   Author:
    23  *      Fabian 'x3n' Landau
     23 *      Oli Scheuss
    2424 *   Co-authors:
    2525 *      ...
Note: See TracChangeset for help on using the changeset viewer.