rome2_p6 imported

Dependencies:   mbed

Committer:
Appalco
Date:
Fri May 18 13:54:25 2018 +0000
Revision:
5:957580f33e52
Parent:
0:351a2fb21235
fixed tolerance and wayponts

Who changed what in which revision?

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