Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
Diff: TaskWait.cpp
- Revision:
- 0:20ec9d702676
diff -r 000000000000 -r 20ec9d702676 TaskWait.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/TaskWait.cpp Tue Mar 31 11:58:30 2020 +0000
@@ -0,0 +1,47 @@
+/*
+ * TaskWait.cpp
+ * Copyright (c) 2020, 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;
+ }
+}
+