BBR 1 Ebene

Committer:
borlanic
Date:
Mon May 14 11:29:06 2018 +0000
Revision:
0:fbdae7e6d805
BBR

Who changed what in which revision?

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