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) 2018, ZHAW 00004 * All rights reserved. 00005 */ 00006 00007 #ifndef MOTION_H_ 00008 #define MOTION_H_ 00009 00010 #include <cstdlib> 00011 00012 /** 00013 * This class keeps the motion values <code>position</code> and <code>velocity</code>, and 00014 * offers methods to increment these values towards a desired target position or velocity. 00015 * <br/> 00016 * To increment the current motion values, this class uses a simple 2nd order motion planner. 00017 * This planner calculates the motion to the target position or velocity with the various motion 00018 * phases, based on given limits for the profile velocity, acceleration and deceleration. 00019 * <br/> 00020 * Note that the trajectory is calculated every time the motion state is incremented. 00021 * This allows to change the target position or velocity, as well as the limits for profile 00022 * velocity, acceleration and deceleration at any time. 00023 */ 00024 class Motion { 00025 00026 public: 00027 00028 double position; /**< The position value of this motion, given in [m] or [rad]. */ 00029 float velocity; /**< The velocity value of this motion, given in [m/s] or [rad/s]. */ 00030 00031 Motion(); 00032 Motion(double position, float velocity); 00033 Motion(const Motion& motion); 00034 virtual ~Motion(); 00035 void set(double position, float velocity); 00036 void set(const Motion& motion); 00037 void setPosition(double position); 00038 double getPosition(); 00039 void setVelocity(float velocity); 00040 float getVelocity(); 00041 void setProfileVelocity(float profileVelocity); 00042 void setProfileAcceleration(float profileAcceleration); 00043 void setProfileDeceleration(float profileDeceleration); 00044 void setLimits(float profileVelocity, float profileAcceleration, float profileDeceleration); 00045 float getTimeToPosition(double targetPosition); 00046 void incrementToVelocity(float targetVelocity, float period); 00047 void incrementToPosition(double targetPosition, float period); 00048 00049 private: 00050 00051 static const float DEFAULT_LIMIT; // default value for limits 00052 static const float MINIMUM_LIMIT; // smallest value allowed for limits 00053 00054 float profileVelocity; 00055 float profileAcceleration; 00056 float profileDeceleration; 00057 }; 00058 00059 #endif /* MOTION_H_ */ 00060 00061
Generated on Thu Jul 14 2022 09:49:36 by
