ROME2 - TI / Mbed 2 deprecated ROME2 - Praktikum

Dependencies:   mbed

Committer:
solcager
Date:
Fri Mar 31 11:00:19 2017 +0000
Revision:
1:08ca9b208045
P3

Who changed what in which revision?

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