ROME_P5

Dependencies:   mbed

Committer:
Inaueadr
Date:
Fri Apr 27 08:47:34 2018 +0000
Revision:
0:29be10cb0afc
Hallo

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Inaueadr 0:29be10cb0afc 1 /*
Inaueadr 0:29be10cb0afc 2 * Motion.h
Inaueadr 0:29be10cb0afc 3 * Copyright (c) 2018, ZHAW
Inaueadr 0:29be10cb0afc 4 * All rights reserved.
Inaueadr 0:29be10cb0afc 5 */
Inaueadr 0:29be10cb0afc 6
Inaueadr 0:29be10cb0afc 7 #ifndef MOTION_H_
Inaueadr 0:29be10cb0afc 8 #define MOTION_H_
Inaueadr 0:29be10cb0afc 9
Inaueadr 0:29be10cb0afc 10 #include <cstdlib>
Inaueadr 0:29be10cb0afc 11
Inaueadr 0:29be10cb0afc 12 /**
Inaueadr 0:29be10cb0afc 13 * This class keeps the motion values <code>position</code> and <code>velocity</code>, and
Inaueadr 0:29be10cb0afc 14 * offers methods to increment these values towards a desired target position or velocity.
Inaueadr 0:29be10cb0afc 15 * <br/>
Inaueadr 0:29be10cb0afc 16 * To increment the current motion values, this class uses a simple 2nd order motion planner.
Inaueadr 0:29be10cb0afc 17 * This planner calculates the motion to the target position or velocity with the various motion
Inaueadr 0:29be10cb0afc 18 * phases, based on given limits for the profile velocity, acceleration and deceleration.
Inaueadr 0:29be10cb0afc 19 * <br/>
Inaueadr 0:29be10cb0afc 20 * Note that the trajectory is calculated every time the motion state is incremented.
Inaueadr 0:29be10cb0afc 21 * This allows to change the target position or velocity, as well as the limits for profile
Inaueadr 0:29be10cb0afc 22 * velocity, acceleration and deceleration at any time.
Inaueadr 0:29be10cb0afc 23 */
Inaueadr 0:29be10cb0afc 24 class Motion {
Inaueadr 0:29be10cb0afc 25
Inaueadr 0:29be10cb0afc 26 public:
Inaueadr 0:29be10cb0afc 27
Inaueadr 0:29be10cb0afc 28 double position; /**< The position value of this motion, given in [m] or [rad]. */
Inaueadr 0:29be10cb0afc 29 float velocity; /**< The velocity value of this motion, given in [m/s] or [rad/s]. */
Inaueadr 0:29be10cb0afc 30
Inaueadr 0:29be10cb0afc 31 Motion();
Inaueadr 0:29be10cb0afc 32 Motion(double position, float velocity);
Inaueadr 0:29be10cb0afc 33 Motion(const Motion& motion);
Inaueadr 0:29be10cb0afc 34 virtual ~Motion();
Inaueadr 0:29be10cb0afc 35 void set(double position, float velocity);
Inaueadr 0:29be10cb0afc 36 void set(const Motion& motion);
Inaueadr 0:29be10cb0afc 37 void setPosition(double position);
Inaueadr 0:29be10cb0afc 38 double getPosition();
Inaueadr 0:29be10cb0afc 39 void setVelocity(float velocity);
Inaueadr 0:29be10cb0afc 40 float getVelocity();
Inaueadr 0:29be10cb0afc 41 void setProfileVelocity(float profileVelocity);
Inaueadr 0:29be10cb0afc 42 void setProfileAcceleration(float profileAcceleration);
Inaueadr 0:29be10cb0afc 43 void setProfileDeceleration(float profileDeceleration);
Inaueadr 0:29be10cb0afc 44 void setLimits(float profileVelocity, float profileAcceleration, float profileDeceleration);
Inaueadr 0:29be10cb0afc 45 float getTimeToPosition(double targetPosition);
Inaueadr 0:29be10cb0afc 46 void incrementToVelocity(float targetVelocity, float period);
Inaueadr 0:29be10cb0afc 47 void incrementToPosition(double targetPosition, float period);
Inaueadr 0:29be10cb0afc 48
Inaueadr 0:29be10cb0afc 49 private:
Inaueadr 0:29be10cb0afc 50
Inaueadr 0:29be10cb0afc 51 static const float DEFAULT_LIMIT; // default value for limits
Inaueadr 0:29be10cb0afc 52 static const float MINIMUM_LIMIT; // smallest value allowed for limits
Inaueadr 0:29be10cb0afc 53
Inaueadr 0:29be10cb0afc 54 float profileVelocity;
Inaueadr 0:29be10cb0afc 55 float profileAcceleration;
Inaueadr 0:29be10cb0afc 56 float profileDeceleration;
Inaueadr 0:29be10cb0afc 57 };
Inaueadr 0:29be10cb0afc 58
Inaueadr 0:29be10cb0afc 59 #endif /* MOTION_H_ */
Inaueadr 0:29be10cb0afc 60
Inaueadr 0:29be10cb0afc 61