P2 halbfertig

Fork of Library by St Knz

Committer:
kueenste
Date:
Sat Mar 10 13:47:28 2018 +0000
Revision:
2:6dd39662e6e5
Parent:
0:bb408887ab78
funktioniert soso

Who changed what in which revision?

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