[Orxonox-commit 64] r2766 - in branches/tutorial/src/orxonox/objects: controllers worldentities
scheusso at orxonox.net
scheusso at orxonox.net
Mon Mar 9 00:58:08 CET 2009
Author: scheusso
Date: 2009-03-09 00:58:08 +0100 (Mon, 09 Mar 2009)
New Revision: 2766
Modified:
branches/tutorial/src/orxonox/objects/controllers/DroneController.cc
branches/tutorial/src/orxonox/objects/controllers/DroneController.h
branches/tutorial/src/orxonox/objects/worldentities/Drone.cc
branches/tutorial/src/orxonox/objects/worldentities/Drone.h
Log:
removed the lines that the student have to find out themselves
Modified: branches/tutorial/src/orxonox/objects/controllers/DroneController.cc
===================================================================
--- branches/tutorial/src/orxonox/objects/controllers/DroneController.cc 2009-03-08 23:07:31 UTC (rev 2765)
+++ branches/tutorial/src/orxonox/objects/controllers/DroneController.cc 2009-03-08 23:58:08 UTC (rev 2766)
@@ -20,7 +20,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Author:
- * Fabian 'x3n' Landau
+ * Oli Scheuss
* Co-authors:
* ...
*
@@ -41,6 +41,8 @@
// - do any kind of initialisation
RegisterObject(DroneController);
+
+
// this checks that our creator really is a drone
// and saves the pointer to the drone for the controlling commands
assert(dynamic_cast<Drone*>(creator)!=0);
@@ -55,13 +57,11 @@
{
// Place your code here:
// - steering commands
- static float totaltime = 0;
- totaltime += dt;
Drone *myDrone = static_cast<Drone*>(this->getControllableEntity());
- if(totaltime<1)
- {
- myDrone->moveFrontBack( -sqrt(dt) );
- myDrone->rotatePitch(-dt);
- }
+ // you can use the following commands for steering
+ // - moveFrontBack, moveRightLeft, moveUpDown
+ // - rotatePitch, rotateYaw, rotateRoll
+ // - apply the to myDrone (e.g. myDrone->rotateYaw(..) )
+
}
}
Modified: branches/tutorial/src/orxonox/objects/controllers/DroneController.h
===================================================================
--- branches/tutorial/src/orxonox/objects/controllers/DroneController.h 2009-03-08 23:07:31 UTC (rev 2765)
+++ branches/tutorial/src/orxonox/objects/controllers/DroneController.h 2009-03-08 23:58:08 UTC (rev 2766)
@@ -20,7 +20,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Author:
- * Fabian 'x3n' Landau
+ * Oli Scheuss
* Co-authors:
* ...
*
Modified: branches/tutorial/src/orxonox/objects/worldentities/Drone.cc
===================================================================
--- branches/tutorial/src/orxonox/objects/worldentities/Drone.cc 2009-03-08 23:07:31 UTC (rev 2765)
+++ branches/tutorial/src/orxonox/objects/worldentities/Drone.cc 2009-03-08 23:58:08 UTC (rev 2766)
@@ -20,7 +20,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Author:
- * Fabian 'x3n' Landau
+ * Oli Scheuss
* Co-authors:
* ...
*
@@ -34,17 +34,16 @@
namespace orxonox
{
- // put your code in here:
+ // PLACE YOUR CODE HERE
// create the factory for the drone
CreateFactory(Drone);
Drone::Drone(BaseObject* creator) : ControllableEntity(creator)
{
- //put your code in here:
+ this->myController_ = 0;
+ // PLACE YOUR CODE HERE
// - register the drone class to the core
// - create a new controller and pass our this pointer to it as creator
- this->myController_ = 0;
- RegisterObject(Drone);
this->localLinearAcceleration_.setValue(0, 0, 0);
this->localAngularAcceleration_.setValue(0, 0, 0);
@@ -69,30 +68,29 @@
// this calls the XMLPort function of the parent class
SUPER(Drone, XMLPort, xmlelement, mode);
- XMLPortParamVariable(Drone, "primaryThrust", primaryThrust_, xmlelement, mode);
- XMLPortParamVariable(Drone, "auxilaryThrust", auxilaryThrust_, xmlelement, mode);
- XMLPortParamVariable(Drone, "rotationThrust", rotationThrust_, xmlelement, mode);
+ // PLACE YOUR CODE HERE
+ // make sure you add the variables primaryThrust_, auxilaryThrust_ and rotationThrust_ to xmlport
+ // variables can be added by the following command
+ // XMLPortParamVariable(Class, "xml-attribute-name", variable_name, xmlelement, mode);
}
void Drone::tick(float dt)
{
- SUPER(Drone, tick, dt);
+ // PLACE YOUR CODE HERE
+ // make sure the tick function of the base class gets called here
- //if (this->hasLocalController())
- //{
- this->localLinearAcceleration_.setX(this->localLinearAcceleration_.x() * getMass() * this->auxilaryThrust_);
- this->localLinearAcceleration_.setY(this->localLinearAcceleration_.y() * getMass() * this->auxilaryThrust_);
- if (this->localLinearAcceleration_.z() > 0)
- this->localLinearAcceleration_.setZ(this->localLinearAcceleration_.z() * getMass() * this->auxilaryThrust_);
- else
- this->localLinearAcceleration_.setZ(this->localLinearAcceleration_.z() * getMass() * this->primaryThrust_);
- this->physicalBody_->applyCentralForce(physicalBody_->getWorldTransform().getBasis() * this->localLinearAcceleration_);
- this->localLinearAcceleration_.setValue(0, 0, 0);
-
- this->localAngularAcceleration_ *= this->getLocalInertia() * this->rotationThrust_;
- this->physicalBody_->applyTorque(physicalBody_->getWorldTransform().getBasis() * this->localAngularAcceleration_);
- this->localAngularAcceleration_.setValue(0, 0, 0);
- //}
+ this->localLinearAcceleration_.setX(this->localLinearAcceleration_.x() * getMass() * this->auxilaryThrust_);
+ this->localLinearAcceleration_.setY(this->localLinearAcceleration_.y() * getMass() * this->auxilaryThrust_);
+ if (this->localLinearAcceleration_.z() > 0)
+ this->localLinearAcceleration_.setZ(this->localLinearAcceleration_.z() * getMass() * this->auxilaryThrust_);
+ else
+ this->localLinearAcceleration_.setZ(this->localLinearAcceleration_.z() * getMass() * this->primaryThrust_);
+ this->physicalBody_->applyCentralForce(physicalBody_->getWorldTransform().getBasis() * this->localLinearAcceleration_);
+ this->localLinearAcceleration_.setValue(0, 0, 0);
+
+ this->localAngularAcceleration_ *= this->getLocalInertia() * this->rotationThrust_;
+ this->physicalBody_->applyTorque(physicalBody_->getWorldTransform().getBasis() * this->localAngularAcceleration_);
+ this->localAngularAcceleration_.setValue(0, 0, 0);
}
Modified: branches/tutorial/src/orxonox/objects/worldentities/Drone.h
===================================================================
--- branches/tutorial/src/orxonox/objects/worldentities/Drone.h 2009-03-08 23:07:31 UTC (rev 2765)
+++ branches/tutorial/src/orxonox/objects/worldentities/Drone.h 2009-03-08 23:58:08 UTC (rev 2766)
@@ -20,7 +20,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Author:
- * Fabian 'x3n' Landau
+ * Oli Scheuss
* Co-authors:
* ...
*
More information about the Orxonox-commit
mailing list