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.
Fork of autonomous Robot Android by
RobotControl/MotionState.h@6:48eeb41188dd, 2013-03-23 (annotated)
- Committer:
- chrigelburri
- Date:
- Sat Mar 23 13:52:48 2013 +0000
- Revision:
- 6:48eeb41188dd
- Parent:
- 3:92ba0254af87
- Child:
- 11:775ebb69d5e1
mit link und rechten Radradius
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| chrigelburri | 0:31f7be68e52d | 1 | #ifndef _MOTION_STATE_H_ |
| chrigelburri | 0:31f7be68e52d | 2 | #define _MOTION_STATE_H_ |
| chrigelburri | 0:31f7be68e52d | 3 | |
| chrigelburri | 0:31f7be68e52d | 4 | #include "defines.h" |
| chrigelburri | 0:31f7be68e52d | 5 | |
| chrigelburri | 0:31f7be68e52d | 6 | /** |
| chrigelburri | 0:31f7be68e52d | 7 | * @author Christian Burri |
| chrigelburri | 0:31f7be68e52d | 8 | * |
| chrigelburri | 0:31f7be68e52d | 9 | * @section LICENSE |
| chrigelburri | 0:31f7be68e52d | 10 | * |
| chrigelburri | 1:6cd533a712c6 | 11 | * Copyright © 2013 HSLU Pren Team #1 Cruising Crêpe |
| chrigelburri | 0:31f7be68e52d | 12 | * All rights reserved. |
| chrigelburri | 0:31f7be68e52d | 13 | * |
| chrigelburri | 0:31f7be68e52d | 14 | * @section DESCRIPTION |
| chrigelburri | 0:31f7be68e52d | 15 | * |
| chrigelburri | 3:92ba0254af87 | 16 | * This help class is for calculate and save the actual or desired value. |
| chrigelburri | 3:92ba0254af87 | 17 | * There have the setter and the getter methode to change the value |
| chrigelburri | 3:92ba0254af87 | 18 | * Is also possible to limit the translational and rotational speed |
| chrigelburri | 3:92ba0254af87 | 19 | * by the value acceleration and thetaAcceleration. Therefore |
| chrigelburri | 3:92ba0254af87 | 20 | * can adjust the ramp. |
| chrigelburri | 0:31f7be68e52d | 21 | * |
| chrigelburri | 0:31f7be68e52d | 22 | */ |
| chrigelburri | 0:31f7be68e52d | 23 | class MotionState |
| chrigelburri | 0:31f7be68e52d | 24 | { |
| chrigelburri | 0:31f7be68e52d | 25 | |
| chrigelburri | 0:31f7be68e52d | 26 | private: |
| chrigelburri | 0:31f7be68e52d | 27 | |
| chrigelburri | 0:31f7be68e52d | 28 | float acceleration; |
| chrigelburri | 0:31f7be68e52d | 29 | float thetaAcceleration; |
| chrigelburri | 0:31f7be68e52d | 30 | |
| chrigelburri | 0:31f7be68e52d | 31 | public: |
| chrigelburri | 0:31f7be68e52d | 32 | |
| chrigelburri | 0:31f7be68e52d | 33 | /** The xposition value of this motion state. */ |
| chrigelburri | 0:31f7be68e52d | 34 | float xposition; |
| chrigelburri | 0:31f7be68e52d | 35 | /** The yposition value of this motion state. */ |
| chrigelburri | 0:31f7be68e52d | 36 | float yposition; |
| chrigelburri | 3:92ba0254af87 | 37 | /** The θ of this motion state. */ |
| chrigelburri | 0:31f7be68e52d | 38 | float theta; |
| chrigelburri | 6:48eeb41188dd | 39 | /** The θ of this motion state from the compass. */ |
| chrigelburri | 0:31f7be68e52d | 40 | float thetaCompass; |
| chrigelburri | 0:31f7be68e52d | 41 | /** The speed value of this motion state. */ |
| chrigelburri | 0:31f7be68e52d | 42 | float speed; |
| chrigelburri | 0:31f7be68e52d | 43 | /** The speed rotational value of this motion state. */ |
| chrigelburri | 0:31f7be68e52d | 44 | float omega; |
| chrigelburri | 0:31f7be68e52d | 45 | |
| chrigelburri | 0:31f7be68e52d | 46 | /** |
| chrigelburri | 0:31f7be68e52d | 47 | * Creates a <code>MotionState</code> object. |
| chrigelburri | 0:31f7be68e52d | 48 | * The values for position and speed are set to 0. |
| chrigelburri | 0:31f7be68e52d | 49 | */ |
| chrigelburri | 0:31f7be68e52d | 50 | MotionState(); |
| chrigelburri | 0:31f7be68e52d | 51 | |
| chrigelburri | 0:31f7be68e52d | 52 | /** |
| chrigelburri | 6:48eeb41188dd | 53 | * Creates a <code>MotionState</code> object with given values for position and speed. |
| chrigelburri | 6:48eeb41188dd | 54 | * @param xposition the initial position value of this motion state, given in [m] |
| chrigelburri | 6:48eeb41188dd | 55 | * @param yposition the initial position value of this motion state, given in [m] |
| chrigelburri | 6:48eeb41188dd | 56 | * @param theta the initial θ value of this motion state, given in [rad] |
| chrigelburri | 6:48eeb41188dd | 57 | * @param speed the initial speed value of this motion state, given in [m/s] |
| chrigelburri | 6:48eeb41188dd | 58 | * @param omega the initial ω speed value of this motion state, given in [rad/s] |
| chrigelburri | 6:48eeb41188dd | 59 | */ |
| chrigelburri | 6:48eeb41188dd | 60 | MotionState(float xposition, |
| chrigelburri | 6:48eeb41188dd | 61 | float yposition, |
| chrigelburri | 6:48eeb41188dd | 62 | float theta, |
| chrigelburri | 6:48eeb41188dd | 63 | float speed, |
| chrigelburri | 6:48eeb41188dd | 64 | float omega); |
| chrigelburri | 0:31f7be68e52d | 65 | |
| chrigelburri | 0:31f7be68e52d | 66 | /** |
| chrigelburri | 6:48eeb41188dd | 67 | * Destructor of the Object to destroy the Object. |
| chrigelburri | 6:48eeb41188dd | 68 | **/ |
| chrigelburri | 0:31f7be68e52d | 69 | virtual ~MotionState(); |
| chrigelburri | 0:31f7be68e52d | 70 | |
| chrigelburri | 0:31f7be68e52d | 71 | /** |
| chrigelburri | 6:48eeb41188dd | 72 | * Sets the values for xPosition, yPostion and θ. |
| chrigelburri | 6:48eeb41188dd | 73 | * @param xposition the initial position value of this motion state, given in [m] |
| chrigelburri | 6:48eeb41188dd | 74 | * @param yposition the initial position value of this motion state, given in [m] |
| chrigelburri | 6:48eeb41188dd | 75 | * @param theta the initial θ value of this motion state, given in [rad] |
| chrigelburri | 6:48eeb41188dd | 76 | * @param speed the initial speed value of this motion state, given in [m/s] |
| chrigelburri | 6:48eeb41188dd | 77 | * @param omega the initial ω speed value of this motion state, given in [rad/s] |
| chrigelburri | 6:48eeb41188dd | 78 | */ |
| chrigelburri | 6:48eeb41188dd | 79 | void setState(float xposition, |
| chrigelburri | 6:48eeb41188dd | 80 | float yposition, |
| chrigelburri | 6:48eeb41188dd | 81 | float theta, |
| chrigelburri | 6:48eeb41188dd | 82 | float speed, |
| chrigelburri | 6:48eeb41188dd | 83 | float omega); |
| chrigelburri | 0:31f7be68e52d | 84 | |
| chrigelburri | 0:31f7be68e52d | 85 | /** |
| chrigelburri | 6:48eeb41188dd | 86 | * Sets the values for X-Position, Y-Postion and θ. |
| chrigelburri | 6:48eeb41188dd | 87 | * @param motionState another <code>MotionState</code> object to copy the state values from |
| chrigelburri | 6:48eeb41188dd | 88 | */ |
| chrigelburri | 0:31f7be68e52d | 89 | void setState(MotionState* motionState); |
| chrigelburri | 0:31f7be68e52d | 90 | |
| chrigelburri | 0:31f7be68e52d | 91 | /** |
| chrigelburri | 6:48eeb41188dd | 92 | * Sets the X-position value. |
| chrigelburri | 6:48eeb41188dd | 93 | * @param xposition the desired xposition value of this motion state, given in [m] |
| chrigelburri | 6:48eeb41188dd | 94 | */ |
| chrigelburri | 1:6cd533a712c6 | 95 | void setxPosition(float xposition); |
| chrigelburri | 0:31f7be68e52d | 96 | |
| chrigelburri | 0:31f7be68e52d | 97 | /** |
| chrigelburri | 6:48eeb41188dd | 98 | * Gets the X-position value. |
| chrigelburri | 6:48eeb41188dd | 99 | * @return the xposition value of this motion state, given in [m] |
| chrigelburri | 6:48eeb41188dd | 100 | */ |
| chrigelburri | 0:31f7be68e52d | 101 | float getxPosition(); |
| chrigelburri | 0:31f7be68e52d | 102 | |
| chrigelburri | 0:31f7be68e52d | 103 | /** |
| chrigelburri | 6:48eeb41188dd | 104 | * Sets the Y-position value. |
| chrigelburri | 6:48eeb41188dd | 105 | * @param yposition the desired yposition value of this motion state, given in [m] |
| chrigelburri | 6:48eeb41188dd | 106 | */ |
| chrigelburri | 0:31f7be68e52d | 107 | void setyPosition(float yposition); |
| chrigelburri | 0:31f7be68e52d | 108 | |
| chrigelburri | 0:31f7be68e52d | 109 | /** |
| chrigelburri | 6:48eeb41188dd | 110 | * Gets the Y-position value. |
| chrigelburri | 6:48eeb41188dd | 111 | * @return the xposition value of this motion state, given in [m] |
| chrigelburri | 6:48eeb41188dd | 112 | */ |
| chrigelburri | 0:31f7be68e52d | 113 | float getyPosition(); |
| chrigelburri | 0:31f7be68e52d | 114 | |
| chrigelburri | 0:31f7be68e52d | 115 | /** |
| chrigelburri | 6:48eeb41188dd | 116 | * Sets the θ value. |
| chrigelburri | 6:48eeb41188dd | 117 | * @param theta the desired θ value of this motion state, given in [rad] |
| chrigelburri | 6:48eeb41188dd | 118 | */ |
| chrigelburri | 0:31f7be68e52d | 119 | void setTheta(float theta); |
| chrigelburri | 0:31f7be68e52d | 120 | |
| chrigelburri | 0:31f7be68e52d | 121 | /** |
| chrigelburri | 6:48eeb41188dd | 122 | * Gets the θ value. |
| chrigelburri | 6:48eeb41188dd | 123 | * @return the θ value of this motion state, given in [rad] |
| chrigelburri | 6:48eeb41188dd | 124 | */ |
| chrigelburri | 0:31f7be68e52d | 125 | float getTheta(); |
| chrigelburri | 0:31f7be68e52d | 126 | |
| chrigelburri | 0:31f7be68e52d | 127 | /** |
| chrigelburri | 6:48eeb41188dd | 128 | * Sets the speed value. |
| chrigelburri | 6:48eeb41188dd | 129 | * @param speed the desired speed value of this motion state, given in [m/s] |
| chrigelburri | 6:48eeb41188dd | 130 | */ |
| chrigelburri | 0:31f7be68e52d | 131 | void setSpeed(float speed); |
| chrigelburri | 0:31f7be68e52d | 132 | |
| chrigelburri | 0:31f7be68e52d | 133 | /** |
| chrigelburri | 6:48eeb41188dd | 134 | * Gets the speed value. |
| chrigelburri | 6:48eeb41188dd | 135 | * @return the speed value of this motion state, given in [m/s] |
| chrigelburri | 6:48eeb41188dd | 136 | */ |
| chrigelburri | 0:31f7be68e52d | 137 | float getSpeed(); |
| chrigelburri | 0:31f7be68e52d | 138 | |
| chrigelburri | 0:31f7be68e52d | 139 | /** |
| chrigelburri | 6:48eeb41188dd | 140 | * Sets the ω value. |
| chrigelburri | 6:48eeb41188dd | 141 | * @param omega the desired ω value of this motion state, given in [rad/s] |
| chrigelburri | 6:48eeb41188dd | 142 | */ |
| chrigelburri | 0:31f7be68e52d | 143 | void setOmega(float omega); |
| chrigelburri | 0:31f7be68e52d | 144 | |
| chrigelburri | 0:31f7be68e52d | 145 | /** |
| chrigelburri | 6:48eeb41188dd | 146 | * Gets the ω value. |
| chrigelburri | 6:48eeb41188dd | 147 | * @return the ω value of this motion state, given in [rad/s] |
| chrigelburri | 6:48eeb41188dd | 148 | */ |
| chrigelburri | 0:31f7be68e52d | 149 | float getOmega(); |
| chrigelburri | 0:31f7be68e52d | 150 | |
| chrigelburri | 0:31f7be68e52d | 151 | /** |
| chrigelburri | 6:48eeb41188dd | 152 | * Sets the maximum acceleration value. |
| chrigelburri | 6:48eeb41188dd | 153 | * @param acceleration the maximum acceleration value to use for |
| chrigelburri | 6:48eeb41188dd | 154 | * the calculation of the motion trajectory, given in [m/s<SUP>2</SUP>] |
| chrigelburri | 6:48eeb41188dd | 155 | */ |
| chrigelburri | 0:31f7be68e52d | 156 | void setAcceleration(float acceleration); |
| chrigelburri | 0:31f7be68e52d | 157 | |
| chrigelburri | 0:31f7be68e52d | 158 | /** |
| chrigelburri | 6:48eeb41188dd | 159 | * Gets the maximum acceleration value. |
| chrigelburri | 6:48eeb41188dd | 160 | * @return the maximum acceleration value used for the calculation |
| chrigelburri | 6:48eeb41188dd | 161 | * of the motion trajectory, given in [m/s<SUP>2</SUP>] |
| chrigelburri | 6:48eeb41188dd | 162 | */ |
| chrigelburri | 0:31f7be68e52d | 163 | float getAcceleration(); |
| chrigelburri | 0:31f7be68e52d | 164 | |
| chrigelburri | 0:31f7be68e52d | 165 | /** |
| chrigelburri | 6:48eeb41188dd | 166 | * Sets the maximum acceleration value of rotation. |
| chrigelburri | 6:48eeb41188dd | 167 | * @param thetaAcceleration the maximum acceleration value to use for |
| chrigelburri | 6:48eeb41188dd | 168 | * the calculation of the motion trajectory, given in [rad/<SUP>2</SUP>] |
| chrigelburri | 6:48eeb41188dd | 169 | */ |
| chrigelburri | 0:31f7be68e52d | 170 | void setThetaAcceleration(float thetaAcceleration); |
| chrigelburri | 0:31f7be68e52d | 171 | |
| chrigelburri | 0:31f7be68e52d | 172 | /** |
| chrigelburri | 6:48eeb41188dd | 173 | * Gets the maximum acceleration value of rotation. |
| chrigelburri | 6:48eeb41188dd | 174 | * @return the maximum acceleration value used for the calculation of |
| chrigelburri | 6:48eeb41188dd | 175 | * the motion trajectory, given in [rad/<SUP>2</SUP>] |
| chrigelburri | 6:48eeb41188dd | 176 | */ |
| chrigelburri | 0:31f7be68e52d | 177 | float getThetaAcceleration(); |
| chrigelburri | 0:31f7be68e52d | 178 | |
| chrigelburri | 0:31f7be68e52d | 179 | /** |
| chrigelburri | 6:48eeb41188dd | 180 | * Increments the current motion state towards a given desired speed. |
| chrigelburri | 6:48eeb41188dd | 181 | * @param desiredSpeed the desired speed given in [m/s]. |
| chrigelburri | 6:48eeb41188dd | 182 | * @param desiredOmega the desired ω given in [rad/s]. |
| chrigelburri | 6:48eeb41188dd | 183 | * @param period the time period to increment the motion state for, given in [s] |
| chrigelburri | 6:48eeb41188dd | 184 | */ |
| chrigelburri | 6:48eeb41188dd | 185 | void increment(float desiredSpeed, |
| chrigelburri | 6:48eeb41188dd | 186 | float desiredOmega, |
| chrigelburri | 6:48eeb41188dd | 187 | float period); |
| chrigelburri | 0:31f7be68e52d | 188 | }; |
| chrigelburri | 0:31f7be68e52d | 189 | |
| chrigelburri | 0:31f7be68e52d | 190 | #endif |
