[Orxonox-commit 1112] r5833 - in code/branches/tutorial/src/orxonox: controllers worldentities
dafrick at orxonox.net
dafrick at orxonox.net
Tue Sep 29 22:24:39 CEST 2009
Author: dafrick
Date: 2009-09-29 22:24:39 +0200 (Tue, 29 Sep 2009)
New Revision: 5833
Modified:
code/branches/tutorial/src/orxonox/controllers/DroneController.cc
code/branches/tutorial/src/orxonox/controllers/DroneController.h
code/branches/tutorial/src/orxonox/worldentities/Drone.cc
code/branches/tutorial/src/orxonox/worldentities/Drone.h
Log:
Added some more comments to the tutorial.
Modified: code/branches/tutorial/src/orxonox/controllers/DroneController.cc
===================================================================
--- code/branches/tutorial/src/orxonox/controllers/DroneController.cc 2009-09-28 21:31:39 UTC (rev 5832)
+++ code/branches/tutorial/src/orxonox/controllers/DroneController.cc 2009-09-29 20:24:39 UTC (rev 5833)
@@ -33,6 +33,10 @@
namespace orxonox
{
+ /**
+ @brief
+ Constructor.
+ */
DroneController::DroneController(BaseObject* creator) : Controller(creator)
{
// Place your code here:
@@ -50,6 +54,12 @@
{
}
+ /**
+ @brief
+ The controlling happens here. This method defines what the controller has to do each tick.
+ @param dt
+ The duration of the tick.
+ */
void DroneController::tick(float dt)
{
// Place your code here:
Modified: code/branches/tutorial/src/orxonox/controllers/DroneController.h
===================================================================
--- code/branches/tutorial/src/orxonox/controllers/DroneController.h 2009-09-28 21:31:39 UTC (rev 5832)
+++ code/branches/tutorial/src/orxonox/controllers/DroneController.h 2009-09-29 20:24:39 UTC (rev 5833)
@@ -36,13 +36,19 @@
namespace orxonox
{
+ /**
+ @brief
+ Controller for the Drone of the PPS tutorial.
+ @author
+ Oli Scheuss
+ */
class _OrxonoxExport DroneController : public Controller, public Tickable
{
public:
DroneController(BaseObject* creator);
virtual ~DroneController();
- virtual void tick(float dt);
+ virtual void tick(float dt); //!< The controlling happens here. This method defines what the controller has to do each tick.
protected:
Modified: code/branches/tutorial/src/orxonox/worldentities/Drone.cc
===================================================================
--- code/branches/tutorial/src/orxonox/worldentities/Drone.cc 2009-09-28 21:31:39 UTC (rev 5832)
+++ code/branches/tutorial/src/orxonox/worldentities/Drone.cc 2009-09-29 20:24:39 UTC (rev 5833)
@@ -37,9 +37,13 @@
// create the factory for the drone
CreateFactory(Drone);
+ /**
+ @brief
+ Constructor. Registers the object and initializes some default values.
+ */
Drone::Drone(BaseObject* creator) : ControllableEntity(creator)
{
- //put your code in here:
+ // put your code in here:
// - register the drone class to the core
// - create a new controller and pass our this pointer to it as creator
this->myController_ = 0;
@@ -57,12 +61,20 @@
myController_ = new DroneController(static_cast<BaseObject*>(this));
}
+ /**
+ @brief
+ Destructor. Destroys controller, if present.
+ */
Drone::~Drone()
{
if( this->myController_ )
delete this->myController_;
}
+ /**
+ @brief
+ Method for creating a Drone through XML.
+ */
void Drone::XMLPort(Element& xmlelement, XMLPort::Mode mode)
{
// this calls the XMLPort function of the parent class
@@ -73,6 +85,12 @@
XMLPortParam(Drone, "rotationThrust", setRotationThrust, getRotationThrust, xmlelement, mode);
}
+ /**
+ @brief
+ Defines which actions the Drone has to take in each tick.
+ @param dt
+ The length of the tick.
+ */
void Drone::tick(float dt)
{
SUPER(Drone, tick, dt);
@@ -94,35 +112,70 @@
//}
}
-
+ /**
+ @brief
+ Moves the Drone in the negative z-direction (Front/Back) by an amount specified by the first component of the input 2-dim vector.
+ @param value
+ The vector determining the amount of the movement.
+ */
void Drone::moveFrontBack(const Vector2& value)
{
this->localLinearAcceleration_.setZ(this->localLinearAcceleration_.z() - value.x);
this->steering_.z = -value.x;
}
+ /**
+ @brief
+ Moves the Drone in the x-direction (Right/Left) by an amount specified by the first component of the input 2-dim vector.
+ @param value
+ The vector determining the amount of the movement.
+ */
void Drone::moveRightLeft(const Vector2& value)
{
this->localLinearAcceleration_.setX(this->localLinearAcceleration_.x() + value.x);
this->steering_.x = value.x;
}
+ /**
+ @brief
+ Moves the Drone in the y-direction (Up/Down) by an amount specified by the first component of the input 2-dim vector.
+ @param value
+ The vector determining the amount of the movement.
+ */
void Drone::moveUpDown(const Vector2& value)
{
this->localLinearAcceleration_.setY(this->localLinearAcceleration_.y() + value.x);
this->steering_.y = value.x;
}
+ /**
+ @brief
+ Rotates the Drone around the y-axis by the amount specified by the first component of the input 2-dim vector.
+ @param value
+ The vector determining the amount of the angular movement.
+ */
void Drone::rotateYaw(const Vector2& value)
{
this->localAngularAcceleration_.setY(this->localAngularAcceleration_.y() - value.x);
}
+ /**
+ @brief
+ Rotates the Drone around the x-axis by the amount specified by the first component of the input 2-dim vector.
+ @param value
+ The vector determining the amount of the angular movement.
+ */
void Drone::rotatePitch(const Vector2& value)
{
this->localAngularAcceleration_.setX(this->localAngularAcceleration_.x() + value.x);
}
+ /**
+ @brief
+ Rotates the Drone around the z-axis by the amount specified by the first component of the input 2-dim vector.
+ @param value
+ The vector determining the amount of the angular movement.
+ */
void Drone::rotateRoll(const Vector2& value)
{
this->localAngularAcceleration_.setZ(this->localAngularAcceleration_.z() + value.x);
Modified: code/branches/tutorial/src/orxonox/worldentities/Drone.h
===================================================================
--- code/branches/tutorial/src/orxonox/worldentities/Drone.h 2009-09-28 21:31:39 UTC (rev 5832)
+++ code/branches/tutorial/src/orxonox/worldentities/Drone.h 2009-09-29 20:24:39 UTC (rev 5833)
@@ -35,14 +35,22 @@
namespace orxonox
{
+
+ /**
+ @brief
+ Drone, that is made to move upon a specified pattern.
+ This class was constructed for the PPS tutorial.
+ @author
+ Oli Scheuss
+ */
class _OrxonoxExport Drone : public ControllableEntity
{
public:
Drone(BaseObject* creator);
virtual ~Drone();
- virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
- virtual void tick(float dt);
+ virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method for creating a Drone through XML.
+ virtual void tick(float dt); //!< Defines which actions the Drone has to take in each tick.
virtual void moveFrontBack(const Vector2& value);
@@ -53,18 +61,41 @@
virtual void rotatePitch(const Vector2& value);
virtual void rotateRoll(const Vector2& value);
-
+ /**
+ @brief Moves the Drone in the Front/Back-direction by the specifed amount.
+ @param value The amount by which the drone is to be moved.
+ */
inline void moveFrontBack(float value)
{ this->moveFrontBack(Vector2(value, 0)); }
+ /**
+ @brief Moves the Drone in the Right/Left-direction by the specifed amount.
+ @param value The amount by which the drone is to be moved.
+ */
inline void moveRightLeft(float value)
{ this->moveRightLeft(Vector2(value, 0)); }
+ /**
+ @brief Moves the Drone in the Up/Down-direction by the specifed amount.
+ @param value The amount by which the drone is to be moved.
+ */
inline void moveUpDown(float value)
{ this->moveUpDown(Vector2(value, 0)); }
+ /**
+ @brief Rotates the Drone around the y-axis by the specifed amount.
+ @param value The amount by which the drone is to be rotated.
+ */
inline void rotateYaw(float value)
{ this->rotateYaw(Vector2(value, 0)); }
+ /**
+ @brief Rotates the Drone around the x-axis by the specifed amount.
+ @param value The amount by which the drone is to be rotated.
+ */
inline void rotatePitch(float value)
{ this->rotatePitch(Vector2(value, 0)); }
+ /**
+ @brief Rotates the Drone around the z-axis by the specifed amount.
+ @param value The amount by which the drone is to be rotated.
+ */
inline void rotateRoll(float value)
{ this->rotateRoll(Vector2(value, 0)); }
@@ -77,11 +108,11 @@
float getRotationThrust(){ return this->rotationThrust_; }
private:
- DroneController *myController_;
+ DroneController *myController_; //!< The controller of the Drone.
Vector3 steering_;
- btVector3 localLinearAcceleration_;
- btVector3 localAngularAcceleration_;
+ btVector3 localLinearAcceleration_; //!< The linear acceleration that is used to move the Drone the next tick.
+ btVector3 localAngularAcceleration_; //!< The linear angular acceleration that is used to move the Drone the next tick.
float primaryThrust_;
float auxilaryThrust_;
float rotationThrust_;
More information about the Orxonox-commit
mailing list