Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
Motion.h
00001 /* 00002 * Motion.h 00003 * Copyright (c) 2017, ZHAW 00004 * All rights reserved. 00005 * 00006 * Created on: 02.02.2017 00007 * Author: Marcel Honegger 00008 */ 00009 00010 #ifndef MOTION_H_ 00011 #define MOTION_H_ 00012 00013 #include <cstdlib> 00014 00015 /** 00016 * This class keeps the motion values <code>position</code> and <code>velocity</code>, and 00017 * offers methods to increment these values towards a desired target position or velocity. 00018 * <br/> 00019 * To increment the current motion values, this class uses a simple 2nd order motion planner. 00020 * This planner calculates the motion to the target position or velocity with the various motion 00021 * phases, based on given limits for the profile velocity, acceleration and deceleration. 00022 * <br/> 00023 * Note that the trajectory is calculated every time the motion state is incremented. 00024 * This allows to change the target position or velocity, as well as the limits for profile 00025 * velocity, acceleration and deceleration at any time. 00026 */ 00027 class Motion { 00028 00029 public: 00030 00031 double position; /**< The position value of this motion, given in [m] or [rad]. */ 00032 float velocity; /**< The velocity value of this motion, given in [m/s] or [rad/s]. */ 00033 float acceleration; /**< The acceleration value of this motion, given in [m/s²] or [rad/s²]. */ 00034 00035 Motion(); 00036 Motion(double position, float velocity); 00037 Motion(double position, float velocity, float acceleration); 00038 Motion(double position, float velocity, float profileVelocity, float profileAcceleration); 00039 Motion(const Motion& motion); 00040 virtual ~Motion(); 00041 void set(double position, float velocity); 00042 void set(double position, float velocity, float acceleration); 00043 void set(const Motion& motion); 00044 void setPosition(double position); 00045 double getPosition(); 00046 void setVelocity(float velocity); 00047 float getVelocity(); 00048 void setAcceleration(float acceleration); 00049 float getAcceleration(); 00050 void setProfileVelocity(float profileVelocity); 00051 void setProfileAcceleration(float profileAcceleration); 00052 void setProfileDeceleration(float profileDeceleration); 00053 void setLimits(float profileVelocity, float profileAcceleration, float profileDeceleration); 00054 float getTimeToPosition(double targetPosition); 00055 double getDistanceToStop(); 00056 void incrementToVelocity(float targetVelocity, float period); 00057 void incrementToPosition(double targetPosition, float period); 00058 00059 private: 00060 00061 static const float DEFAULT_LIMIT; // default value for limits 00062 static const float MINIMUM_LIMIT; // smallest value allowed for limits 00063 00064 float profileVelocity; 00065 float profileAcceleration; 00066 float profileDeceleration; 00067 }; 00068 00069 #endif /* MOTION_H_ */
Generated on Wed Jul 20 2022 10:02:38 by
1.7.2