rome2_p6 imported

Dependencies:   mbed

TaskWait.cpp

Committer:
Appalco
Date:
2018-05-18
Revision:
5:957580f33e52
Parent:
0:351a2fb21235

File content as of revision 5:957580f33e52:

/*
 * TaskWait.cpp
 * Copyright (c) 2018, ZHAW
 * All rights reserved.
 */

#include "TaskWait.h"

using namespace std;

/**
 * Creates a task object that waits for a given duration.
 */
TaskWait::TaskWait(Controller& controller, float duration) : controller(controller) {
    
    this->duration = duration;
    
    time = 0.0f;
}

/**
 * Deletes the task object.
 */
TaskWait::~TaskWait() {}

/**
 * This method is called periodically by a task sequencer.
 * @param period the period of the task sequencer, given in [s].
 * @return the status of this task, i.e. RUNNING or DONE.
 */
int TaskWait::run(float period) {
    
    controller.setTranslationalVelocity(0.0f);
    controller.setRotationalVelocity(0.0f);
    
    time += period;
    
    if (time < duration) {
        
        return RUNNING;
        
    } else {
        
        return DONE;
    }
}