Marco Oehler / Mbed 2 deprecated Lab2

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Motion Class Reference

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:
positionthe initial position value of this motion, given in [m] or [rad].
velocitythe initial velocity value of this motion, given in [m/s] or [rad/s].

Definition at line 35 of file Motion.cpp.

Motion ( const Motion motion )

Creates a Motion object with given values for position and velocity.

Parameters:
motionanother 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:
targetPositionthe 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:
targetPositionthe desired target position given in [m] or [rad].
periodthe 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:
targetVelocitythe desired target velocity given in [m/s] or [rad/s].
periodthe 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:
motionanother 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:
positionthe desired position value of this motion, given in [m] or [rad].
velocitythe 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:
profileVelocitythe limit of the velocity.
profileAccelerationthe limit of the acceleration.
profileDecelerationthe limit of the deceleration.

Definition at line 154 of file Motion.cpp.

void setPosition ( double  position )

Sets the position value.

Parameters:
positionthe 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:
profileAccelerationthe limit of the acceleration.

Definition at line 134 of file Motion.cpp.

void setProfileDeceleration ( float  profileDeceleration )

Sets the limit for the deceleration value.

Parameters:
profileDecelerationthe limit of the deceleration.

Definition at line 143 of file Motion.cpp.

void setProfileVelocity ( float  profileVelocity )

Sets the limit for the velocity value.

Parameters:
profileVelocitythe limit of the velocity.

Definition at line 125 of file Motion.cpp.

void setVelocity ( float  velocity )

Sets the velocity value.

Parameters:
velocitythe 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

The position value of this motion, given in [m] or [rad].

Definition at line 28 of file Motion.h.

float velocity

The velocity value of this motion, given in [m/s] or [rad/s].

Definition at line 29 of file Motion.h.