ROME_P5

Dependencies:   mbed

Committer:
Inaueadr
Date:
Fri Apr 27 08:47:34 2018 +0000
Revision:
0:29be10cb0afc
Hallo

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Inaueadr 0:29be10cb0afc 1 /*
Inaueadr 0:29be10cb0afc 2 * TaskWait.cpp
Inaueadr 0:29be10cb0afc 3 * Copyright (c) 2018, ZHAW
Inaueadr 0:29be10cb0afc 4 * All rights reserved.
Inaueadr 0:29be10cb0afc 5 */
Inaueadr 0:29be10cb0afc 6
Inaueadr 0:29be10cb0afc 7 #include "TaskWait.h"
Inaueadr 0:29be10cb0afc 8
Inaueadr 0:29be10cb0afc 9 using namespace std;
Inaueadr 0:29be10cb0afc 10
Inaueadr 0:29be10cb0afc 11 /**
Inaueadr 0:29be10cb0afc 12 * Creates a task object that waits for a given duration.
Inaueadr 0:29be10cb0afc 13 */
Inaueadr 0:29be10cb0afc 14 TaskWait::TaskWait(Controller& controller, float duration) : controller(controller) {
Inaueadr 0:29be10cb0afc 15
Inaueadr 0:29be10cb0afc 16 this->duration = duration;
Inaueadr 0:29be10cb0afc 17
Inaueadr 0:29be10cb0afc 18 time = 0.0f;
Inaueadr 0:29be10cb0afc 19 }
Inaueadr 0:29be10cb0afc 20
Inaueadr 0:29be10cb0afc 21 /**
Inaueadr 0:29be10cb0afc 22 * Deletes the task object.
Inaueadr 0:29be10cb0afc 23 */
Inaueadr 0:29be10cb0afc 24 TaskWait::~TaskWait() {}
Inaueadr 0:29be10cb0afc 25
Inaueadr 0:29be10cb0afc 26 /**
Inaueadr 0:29be10cb0afc 27 * This method is called periodically by a task sequencer.
Inaueadr 0:29be10cb0afc 28 * @param period the period of the task sequencer, given in [s].
Inaueadr 0:29be10cb0afc 29 * @return the status of this task, i.e. RUNNING or DONE.
Inaueadr 0:29be10cb0afc 30 */
Inaueadr 0:29be10cb0afc 31 int TaskWait::run(float period) {
Inaueadr 0:29be10cb0afc 32
Inaueadr 0:29be10cb0afc 33 controller.setTranslationalVelocity(0.0f);
Inaueadr 0:29be10cb0afc 34 controller.setRotationalVelocity(0.0f);
Inaueadr 0:29be10cb0afc 35
Inaueadr 0:29be10cb0afc 36 time += period;
Inaueadr 0:29be10cb0afc 37
Inaueadr 0:29be10cb0afc 38 if (time < duration) {
Inaueadr 0:29be10cb0afc 39
Inaueadr 0:29be10cb0afc 40 return RUNNING;
Inaueadr 0:29be10cb0afc 41
Inaueadr 0:29be10cb0afc 42 } else {
Inaueadr 0:29be10cb0afc 43
Inaueadr 0:29be10cb0afc 44 return DONE;
Inaueadr 0:29be10cb0afc 45 }
Inaueadr 0:29be10cb0afc 46 }
Inaueadr 0:29be10cb0afc 47