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.
Motion Class Reference
This class keeps the motion values position
and velocity
, and offers methods to increment these values towards a desired target position or velocity.
More...
#include <Motion.h>
Public Member Functions | |
Motion () | |
Creates a Motion object. | |
Motion (double position, float velocity) | |
Creates a Motion object with given values for position and velocity. | |
Motion (const Motion &motion) | |
Creates a Motion object with given values for position and velocity. | |
virtual | ~Motion () |
Deletes the Motion object. | |
void | set (double position, float velocity) |
Sets the values for position and velocity. | |
void | set (const Motion &motion) |
Sets the values for position and velocity. | |
void | setPosition (double position) |
Sets the position value. | |
double | getPosition () |
Gets the position value. | |
void | setVelocity (float velocity) |
Sets the velocity value. | |
float | getVelocity () |
Gets the velocity value. | |
void | setProfileVelocity (float profileVelocity) |
Sets the limit for the velocity value. | |
void | setProfileAcceleration (float profileAcceleration) |
Sets the limit for the acceleration value. | |
void | setProfileDeceleration (float profileDeceleration) |
Sets the limit for the deceleration value. | |
void | setLimits (float profileVelocity, float profileAcceleration, float profileDeceleration) |
Sets the limits for velocity, acceleration and deceleration values. | |
float | getTimeToPosition (double targetPosition) |
Gets the time needed to move to a given target position. | |
void | incrementToVelocity (float targetVelocity, float period) |
Increments the current motion towards a given target velocity. | |
void | incrementToPosition (double targetPosition, float period) |
Increments the current motion towards a given target position. | |
Data Fields | |
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]. |
Detailed Description
This class keeps the motion values position
and velocity
, and offers methods to increment these values towards a desired target position or velocity.
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.
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.
Definition at line 24 of file Motion.h.
Constructor & Destructor Documentation
Motion | ( | ) |
Creates a Motion
object.
The values for position, velocity and acceleration are set to 0.
Definition at line 20 of file Motion.cpp.
Motion | ( | double | position, |
float | velocity | ||
) |
Creates a Motion
object with given values for position and velocity.
- Parameters:
-
position the initial position value of this motion, given in [m] or [rad]. velocity the initial velocity value of this motion, given in [m/s] or [rad/s].
Definition at line 35 of file Motion.cpp.
Creates a Motion
object with given values for position and velocity.
- Parameters:
-
motion another Motion
object to copy the values from.
Definition at line 49 of file Motion.cpp.
~Motion | ( | ) | [virtual] |
Deletes the Motion object.
Definition at line 62 of file Motion.cpp.
Member Function Documentation
double getPosition | ( | ) |
Gets the position value.
- Returns:
- the position value of this motion, given in [m] or [rad].
Definition at line 98 of file Motion.cpp.
float getTimeToPosition | ( | double | targetPosition ) |
Gets the time needed to move to a given target position.
- Parameters:
-
targetPosition the desired target position given in [m] or [rad].
- Returns:
- the time to move to the target position, given in [s].
Definition at line 166 of file Motion.cpp.
float getVelocity | ( | ) |
Gets the velocity value.
- Returns:
- the velocity value of this motion, given in [m/s] or [rad/s].
Definition at line 116 of file Motion.cpp.
void incrementToPosition | ( | double | targetPosition, |
float | period | ||
) |
Increments the current motion towards a given target position.
- Parameters:
-
targetPosition the desired target position given in [m] or [rad]. period the time period to increment the motion values for, given in [s].
Definition at line 375 of file Motion.cpp.
void incrementToVelocity | ( | float | targetVelocity, |
float | period | ||
) |
Increments the current motion towards a given target velocity.
- Parameters:
-
targetVelocity the desired target velocity given in [m/s] or [rad/s]. period the time period to increment the motion values for, given in [s].
Definition at line 263 of file Motion.cpp.
void set | ( | const Motion & | motion ) |
Sets the values for position and velocity.
- Parameters:
-
motion another Motion
object to copy the values from.
Definition at line 79 of file Motion.cpp.
void set | ( | double | position, |
float | velocity | ||
) |
Sets the values for position and velocity.
- Parameters:
-
position the desired position value of this motion, given in [m] or [rad]. velocity the desired velocity value of this motion, given in [m/s] or [rad/s].
Definition at line 69 of file Motion.cpp.
void setLimits | ( | float | profileVelocity, |
float | profileAcceleration, | ||
float | profileDeceleration | ||
) |
Sets the limits for velocity, acceleration and deceleration values.
- Parameters:
-
profileVelocity the limit of the velocity. profileAcceleration the limit of the acceleration. profileDeceleration the limit of the deceleration.
Definition at line 154 of file Motion.cpp.
void setPosition | ( | double | position ) |
Sets the position value.
- Parameters:
-
position the desired position value of this motion, given in [m] or [rad].
Definition at line 89 of file Motion.cpp.
void setProfileAcceleration | ( | float | profileAcceleration ) |
Sets the limit for the acceleration value.
- Parameters:
-
profileAcceleration the limit of the acceleration.
Definition at line 134 of file Motion.cpp.
void setProfileDeceleration | ( | float | profileDeceleration ) |
Sets the limit for the deceleration value.
- Parameters:
-
profileDeceleration the limit of the deceleration.
Definition at line 143 of file Motion.cpp.
void setProfileVelocity | ( | float | profileVelocity ) |
Sets the limit for the velocity value.
- Parameters:
-
profileVelocity the limit of the velocity.
Definition at line 125 of file Motion.cpp.
void setVelocity | ( | float | velocity ) |
Sets the velocity value.
- Parameters:
-
velocity the desired velocity value of this motion, given in [m/s] or [rad/s].
Definition at line 107 of file Motion.cpp.
Field Documentation
double position |
Generated on Sat Jul 23 2022 17:01:00 by
