Backup 1

Committer:
borlanic
Date:
Tue Apr 24 11:45:18 2018 +0000
Revision:
0:02dd72d1d465
BaBoRo_test2 - backup 1

Who changed what in which revision?

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