TeamSurface / Mbed 2 deprecated ROME_P3

Dependencies:   mbed

Committer:
kueenste
Date:
Fri Mar 23 13:07:58 2018 +0000
Revision:
0:7cf5bf7e9486
Child:
1:7bf9b6c007a1
P3 Anfang;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
kueenste 0:7cf5bf7e9486 1 /*
kueenste 0:7cf5bf7e9486 2 * TaskMoveTo.cpp
kueenste 0:7cf5bf7e9486 3 * Copyright (c) 2017, ZHAW
kueenste 0:7cf5bf7e9486 4 * All rights reserved.
kueenste 0:7cf5bf7e9486 5 */
kueenste 0:7cf5bf7e9486 6
kueenste 0:7cf5bf7e9486 7 #include <cmath>
kueenste 0:7cf5bf7e9486 8 #include "TaskMoveTo.h"
kueenste 0:7cf5bf7e9486 9
kueenste 0:7cf5bf7e9486 10 using namespace std;
kueenste 0:7cf5bf7e9486 11
kueenste 0:7cf5bf7e9486 12 const float TaskMoveTo::DEFAULT_VELOCITY = 0.2f; // default velocity value, given in [m/s]
kueenste 0:7cf5bf7e9486 13 const float TaskMoveTo::DEFAULT_ZONE = 0.01f; // default zone value, given in [m]
kueenste 0:7cf5bf7e9486 14 const float TaskMoveTo::PI = 3.14159265f; // the constant PI
kueenste 0:7cf5bf7e9486 15 const float TaskMoveTo::K1 = 2.0f; // position controller gain parameter
kueenste 0:7cf5bf7e9486 16 const float TaskMoveTo::K2 = 0.5f; // position controller gain parameter
kueenste 0:7cf5bf7e9486 17 const float TaskMoveTo::K3 = 0.5f; // position controller gain parameter
kueenste 0:7cf5bf7e9486 18
kueenste 0:7cf5bf7e9486 19 /**
kueenste 0:7cf5bf7e9486 20 * Creates a task object that moves the robot to a given pose.
kueenste 0:7cf5bf7e9486 21 * @param conroller a reference to the controller object of the robot.
kueenste 0:7cf5bf7e9486 22 * @param x the x coordinate of the target position, given in [m].
kueenste 0:7cf5bf7e9486 23 * @param y the y coordinate of the target position, given in [m].
kueenste 0:7cf5bf7e9486 24 * @param alpha the target orientation, given in [rad].
kueenste 0:7cf5bf7e9486 25 */
kueenste 0:7cf5bf7e9486 26 TaskMoveTo::TaskMoveTo(Controller& controller, float x, float y, float alpha) : controller(controller) {
kueenste 0:7cf5bf7e9486 27
kueenste 0:7cf5bf7e9486 28 this->x = x;
kueenste 0:7cf5bf7e9486 29 this->y = y;
kueenste 0:7cf5bf7e9486 30 this->alpha = alpha;
kueenste 0:7cf5bf7e9486 31 this->velocity = DEFAULT_VELOCITY;
kueenste 0:7cf5bf7e9486 32 this->zone = DEFAULT_ZONE;
kueenste 0:7cf5bf7e9486 33 }
kueenste 0:7cf5bf7e9486 34
kueenste 0:7cf5bf7e9486 35 /**
kueenste 0:7cf5bf7e9486 36 * Creates a task object that moves the robot to a given pose.
kueenste 0:7cf5bf7e9486 37 * @param conroller a reference to the controller object of the robot.
kueenste 0:7cf5bf7e9486 38 * @param x the x coordinate of the target position, given in [m].
kueenste 0:7cf5bf7e9486 39 * @param y the y coordinate of the target position, given in [m].
kueenste 0:7cf5bf7e9486 40 * @param alpha the target orientation, given in [rad].
kueenste 0:7cf5bf7e9486 41 * @param velocity the maximum translational velocity, given in [m/s].
kueenste 0:7cf5bf7e9486 42 */
kueenste 0:7cf5bf7e9486 43 TaskMoveTo::TaskMoveTo(Controller& controller, float x, float y, float alpha, float velocity) : controller(controller) {
kueenste 0:7cf5bf7e9486 44
kueenste 0:7cf5bf7e9486 45 this->x = x;
kueenste 0:7cf5bf7e9486 46 this->y = y;
kueenste 0:7cf5bf7e9486 47 this->alpha = alpha;
kueenste 0:7cf5bf7e9486 48 this->velocity = velocity;
kueenste 0:7cf5bf7e9486 49 this->zone = DEFAULT_ZONE;
kueenste 0:7cf5bf7e9486 50 }
kueenste 0:7cf5bf7e9486 51
kueenste 0:7cf5bf7e9486 52 /**
kueenste 0:7cf5bf7e9486 53 * Creates a task object that moves the robot to a given pose.
kueenste 0:7cf5bf7e9486 54 * @param conroller a reference to the controller object of the robot.
kueenste 0:7cf5bf7e9486 55 * @param x the x coordinate of the target position, given in [m].
kueenste 0:7cf5bf7e9486 56 * @param y the y coordinate of the target position, given in [m].
kueenste 0:7cf5bf7e9486 57 * @param alpha the target orientation, given in [rad].
kueenste 0:7cf5bf7e9486 58 * @param velocity the maximum translational velocity, given in [m/s].
kueenste 0:7cf5bf7e9486 59 * @param zone the zone threshold around the target position, given in [m].
kueenste 0:7cf5bf7e9486 60 */
kueenste 0:7cf5bf7e9486 61 TaskMoveTo::TaskMoveTo(Controller& controller, float x, float y, float alpha, float velocity, float zone) : controller(controller) {
kueenste 0:7cf5bf7e9486 62
kueenste 0:7cf5bf7e9486 63 this->x = x;
kueenste 0:7cf5bf7e9486 64 this->y = y;
kueenste 0:7cf5bf7e9486 65 this->alpha = alpha;
kueenste 0:7cf5bf7e9486 66 this->velocity = velocity;
kueenste 0:7cf5bf7e9486 67 this->zone = zone;
kueenste 0:7cf5bf7e9486 68 }
kueenste 0:7cf5bf7e9486 69
kueenste 0:7cf5bf7e9486 70 /**
kueenste 0:7cf5bf7e9486 71 * Deletes the task object.
kueenste 0:7cf5bf7e9486 72 */
kueenste 0:7cf5bf7e9486 73 TaskMoveTo::~TaskMoveTo() {}
kueenste 0:7cf5bf7e9486 74
kueenste 0:7cf5bf7e9486 75 /**
kueenste 0:7cf5bf7e9486 76 * This method is called periodically by a task sequencer.
kueenste 0:7cf5bf7e9486 77 * @param period the period of the task sequencer, given in [s].
kueenste 0:7cf5bf7e9486 78 * @return the status of this task, i.e. RUNNING or DONE.
kueenste 0:7cf5bf7e9486 79 */
kueenste 0:7cf5bf7e9486 80 int TaskMoveTo::run(float period) {
kueenste 0:7cf5bf7e9486 81
kueenste 0:7cf5bf7e9486 82 // bitte implementieren!
kueenste 0:7cf5bf7e9486 83
kueenste 0:7cf5bf7e9486 84 return RUNNING;
kueenste 0:7cf5bf7e9486 85 }
kueenste 0:7cf5bf7e9486 86