altb_pmic / Mbed 2 deprecated Test_Realbot

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 (double position, float velocity, float acceleration)
 Creates a Motion object with given values for position, velocity and acceleration.
 Motion (double position, float velocity, float profileVelocity, float profileAcceleration)
 Creates a Motion object with given values for position, velocity and acceleration.
 Motion (const Motion &motion)
 Creates a Motion object with given values for position and velocity.
void set (double position, float velocity)
 Sets the values for position and velocity.
void set (double position, float velocity, float acceleration)
 Sets the values for position, velocity and acceleration.
void set (const Motion &motion)
 Sets the values for position, velocity and acceleration.
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 setAcceleration (float acceleration)
 Sets the acceleration value.
float getAcceleration ()
 Gets the acceleration 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.
double getDistanceToStop ()
 Gets the distance moved until the velocity reaches zero.
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].
float acceleration
 The acceleration 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 27 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 23 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 39 of file Motion.cpp.

Motion ( double  position,
float  velocity,
float  acceleration 
)

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

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].
accelerationthe initial acceleration value of this motion, given in [m/s] or [rad/s].

Definition at line 56 of file Motion.cpp.

Motion ( double  position,
float  velocity,
float  profileVelocity,
float  profileAcceleration 
)

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

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].
profileVelocitythe limit of the velocity.
profileAccelerationthe limit of the acceleration.
profileDecelerationequal to profileAcceleration.

Definition at line 75 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 90 of file Motion.cpp.


Member Function Documentation

float getAcceleration (  )

Gets the acceleration value.

Returns:
the acceleration value of this motion, given in [m/s] or [rad/s].

Definition at line 187 of file Motion.cpp.

double getDistanceToStop (  )

Gets the distance moved until the velocity reaches zero.

Returns:
the distance to the stop position.

Definition at line 333 of file Motion.cpp.

double getPosition (  )

Gets the position value.

Returns:
the position value of this motion, given in [m] or [rad].

Definition at line 151 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 237 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 169 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 469 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 343 of file Motion.cpp.

void set ( double  position,
float  velocity,
float  acceleration 
)

Sets the values for position, velocity and acceleration.

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].
accelerationthe desired acceleration value of this motion, given in [m/s] or [rad/s].

Definition at line 120 of file Motion.cpp.

void set ( const Motion motion )

Sets the values for position, velocity and acceleration.

Parameters:
motionanother Motion object to copy the values from.

Definition at line 131 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 108 of file Motion.cpp.

void setAcceleration ( float  acceleration )

Sets the acceleration value.

Parameters:
accelerationthe desired acceleration value of this motion, given in [m/s] or [rad/s].

Definition at line 178 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 225 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 142 of file Motion.cpp.

void setProfileAcceleration ( float  profileAcceleration )

Sets the limit for the acceleration value.

Parameters:
profileAccelerationthe limit of the acceleration.

Definition at line 205 of file Motion.cpp.

void setProfileDeceleration ( float  profileDeceleration )

Sets the limit for the deceleration value.

Parameters:
profileDecelerationthe limit of the deceleration.

Definition at line 214 of file Motion.cpp.

void setProfileVelocity ( float  profileVelocity )

Sets the limit for the velocity value.

Parameters:
profileVelocitythe limit of the velocity.

Definition at line 196 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 160 of file Motion.cpp.


Field Documentation

float acceleration

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

Definition at line 33 of file Motion.h.

double position

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

Definition at line 31 of file Motion.h.

float velocity

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

Definition at line 32 of file Motion.h.