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
Diff: Motion.h
- Revision:
- 0:20ec9d702676
diff -r 000000000000 -r 20ec9d702676 Motion.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Motion.h Tue Mar 31 11:58:30 2020 +0000
@@ -0,0 +1,60 @@
+/*
+ * Motion.h
+ * Copyright (c) 2020, ZHAW
+ * All rights reserved.
+ */
+
+#ifndef MOTION_H_
+#define MOTION_H_
+
+#include <cstdlib>
+
+/**
+ * This class keeps the motion values <code>position</code> and <code>velocity</code>, and
+ * offers methods to increment these values towards a desired target position or velocity.
+ * <br/>
+ * To increment the current motion values, this class uses a simple 2nd order motion planner.
+ * This planner calculates the motion to the target position or velocity with the various motion
+ * phases, based on given limits for the profile velocity, acceleration and deceleration.
+ * <br/>
+ * Note that the trajectory is calculated every time the motion state is incremented.
+ * This allows to change the target position or velocity, as well as the limits for profile
+ * velocity, acceleration and deceleration at any time.
+ */
+class Motion {
+
+ public:
+
+ double position; /**< The position value of this motion, given in [m] or [rad]. */
+ float velocity; /**< The velocity value of this motion, given in [m/s] or [rad/s]. */
+
+ Motion();
+ Motion(double position, float velocity);
+ Motion(const Motion& motion);
+ virtual ~Motion();
+ void set(double position, float velocity);
+ void set(const Motion& motion);
+ void setPosition(double position);
+ double getPosition();
+ void setVelocity(float velocity);
+ float getVelocity();
+ void setProfileVelocity(float profileVelocity);
+ void setProfileAcceleration(float profileAcceleration);
+ void setProfileDeceleration(float profileDeceleration);
+ void setLimits(float profileVelocity, float profileAcceleration, float profileDeceleration);
+ float getTimeToPosition(double targetPosition);
+ void incrementToVelocity(float targetVelocity, float period);
+ void incrementToPosition(double targetPosition, float period);
+
+ private:
+
+ static const float DEFAULT_LIMIT; // default value for limits
+ static const float MINIMUM_LIMIT; // smallest value allowed for limits
+
+ float profileVelocity;
+ float profileAcceleration;
+ float profileDeceleration;
+};
+
+#endif /* MOTION_H_ */
+