Nim leo niiiim

Committer:
Kiwicjam
Date:
Fri May 11 12:21:19 2018 +0000
Revision:
0:da791f233257
start of rome2 p5;

Who changed what in which revision?

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