ROME2 - TI / Mbed 2 deprecated ROME2 - Praktikum

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers TaskWait.cpp Source File

TaskWait.cpp

00001 /*
00002  * TaskWait.cpp
00003  * Copyright (c) 2017, ZHAW
00004  * All rights reserved.
00005  */
00006 
00007 #include "TaskWait.h"
00008 
00009 using namespace std;
00010 
00011 /**
00012  * Creates a task object that waits for a given duration.
00013  */
00014 TaskWait::TaskWait(Controller& controller, float duration) : controller(controller) {
00015     
00016     this->duration = duration;
00017     
00018     time = 0.0f;
00019 }
00020 
00021 /**
00022  * Deletes the task object.
00023  */
00024 TaskWait::~TaskWait() {}
00025 
00026 /**
00027  * This method is called periodically by a task sequencer.
00028  * @param period the period of the task sequencer, given in [s].
00029  * @return the status of this task, i.e. RUNNING or DONE.
00030  */
00031 int TaskWait::run(float period) {
00032     
00033     controller.setTranslationalVelocity(0.0f);
00034     controller.setRotationalVelocity(0.0f);
00035     
00036     time += period;
00037     
00038     if (time < duration) {
00039         
00040         return RUNNING;
00041         
00042     } else {
00043         
00044         return DONE;
00045     }
00046 }
00047