Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/Presentation_HS17_merge/src/orxonox/controllers/AutonomousDroneController.cc @ 11774

Last change on this file since 11774 was 11774, checked in by landauf, 6 years ago

merged Waypoints_HS17

File size: 3.5 KB
Line 
1/*
2 *   ORXONOX - the hottest 3D action shooter ever to exist
3 *                    > www.orxonox.net <
4 *
5 *
6 *   License notice:
7 *
8 *   This program is free software; you can redistribute it and/or
9 *   modify it under the terms of the GNU General Public License
10 *   as published by the Free Software Foundation; either version 2
11 *   of the License, or (at your option) any later version.
12 *
13 *   This program is distributed in the hope that it will be useful,
14 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
15 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 *   GNU General Public License for more details.
17 *
18 *   You should have received a copy of the GNU General Public License
19 *   along with this program; if not, write to the Free Software
20 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
21 *
22 *   Author:
23 *      Oli Scheuss
24 *   Co-authors:
25 *      Damian 'Mozork' Frick
26 *
27 */
28
29#include "AutonomousDroneController.h"
30
31#include "worldentities/AutonomousDrone.h"
32#include "util/Math.h"
33
34namespace orxonox
35{
36    //TODO: Put your code in here:
37    // Create the factory for the drone controller.
38    RegisterClass(AutonomousDroneController);
39
40
41    /**
42    @brief
43        Constructor.
44    @param context
45        The context of this object.
46    */
47    AutonomousDroneController::AutonomousDroneController(Context* context) : Controller(context)
48    {
49        //TODO: Place your code here:
50        RegisterObject(AutonomousDroneController);
51
52
53        // Make sure to register the object and create the factory.       
54
55        // This checks that our context really is a drone
56        // and saves the pointer to the drone for the controlling commands
57        /* NOTE from Sandro: This is currently broken */
58        //AutonomousDrone* drone = dynamic_cast<AutonomousDrone*>(context);
59        //assert(drone != nullptr);
60        //this->setControllableEntity(drone);
61    }
62
63    /**
64    @brief
65        Destructor.
66    */
67    AutonomousDroneController::~AutonomousDroneController()
68    {
69
70    }
71
72    /**
73    @brief
74        The controlling happens here. This method defines what the controller has to do each tick.
75    @param dt
76        The duration of the tick.
77    */
78    void AutonomousDroneController::tick(float dt)
79    {
80        /* NOTE: Ugly hack by Sandro to make the tutorial work for the moment.
81         * This will be reverted once the framework update is complete
82         */
83        //AutonomousDrone *myDrone = static_cast<AutonomousDrone*>(this->getControllableEntity());
84        ObjectList<AutonomousDrone> objectList;
85        ObjectList<AutonomousDrone>::iterator it = objectList.begin();
86        AutonomousDrone* myDrone = *it;
87
88        if (myDrone != nullptr)
89        {
90
91           
92            //myDrone -> moveFrontBack(50*dt);
93            myDrone -> rotateRoll(2*dt);
94           
95            myDrone -> rotateYaw(2*dt);
96           
97               
98            //TODO: Place your code here:
99            // Steering commands
100            // You can use the commands provided by the AutonomousDrone to steer it:
101            // - moveFrontBack, moveRightLeft, moveUpDown
102            // - rotatePitch, rotateYaw, rotateRoll
103            // You will see, that the AutonomousDrone has two variants for each of these commands, one with a vector as input and one with just a float. Use the one with just the float as input.
104            // Apply them to myDrone (e.g. myDrone->rotateYaw(..) )
105            // dt is the time passed since the last call of the tick function in seconds.
106
107
108
109        }
110    }
111}
Note: See TracBrowser for help on using the repository browser.