Nav2 Navigation Stack - lyrical  lyrical
ROS 2 Navigation Stack
Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
mppi::MotionModel Class Referenceabstract

Abstract pluginlib class for modeling a vehicle. More...

#include <nav2_mppi_controller/include/nav2_mppi_controller/motion_models.hpp>

Inheritance diagram for mppi::MotionModel:
Inheritance graph
[legend]
Collaboration diagram for mppi::MotionModel:
Collaboration graph
[legend]

Public Member Functions

 MotionModel ()=default
 Constructor for mppi::MotionModel.
 
virtual ~MotionModel ()=default
 Destructor for mppi::MotionModel.
 
virtual void initialize (ParametersHandler *, const std::string &)
 Initialize motion model on bringup. More...
 
void setConstraints (const models::ControlConstraints &control_constraints, float model_dt, float model_delay_vx, float model_delay_vy, float model_delay_wz, bool clamp_raw_controls)
 Initialize motion model on bringup and set required variables. More...
 
void pushCommandHistory (float vx, float vy, float wz)
 Push the most recently published command to the per-axis history ring buffers. Called once per controller cycle from the optimizer.
 
void clearCommandHistory ()
 Zero the ring buffers.
 
virtual void predict (models::State &state)
 With input velocities, find the vehicle's output velocities. More...
 
virtual bool isHolonomic () const =0
 Whether the motion model is holonomic, using Y axis. More...
 
virtual void applyConstraints (models::ControlSequence &)
 Apply hard vehicle constraints to a control sequence. More...
 

Protected Member Functions

void applyDelayShift (models::State &state, bool is_holo, unsigned int offset_vx, unsigned int offset_vy, unsigned int offset_wz) const
 Apply the per-axis input-delay shift to velocity rollout. More...
 
std::size_t offsetSteps (float delay) const
 Convert a delay in seconds to an offset in number of rollout steps, rounding to the nearest step.
 

Static Protected Member Functions

static void pushOne (std::vector< float > &buf, float v)
 Push a value to the back of a ring buffer and rotate the elements.
 

Protected Attributes

float model_dt_ {0.0}
 
float model_delay_vx_ {0.0}
 
float model_delay_vy_ {0.0}
 
float model_delay_wz_ {0.0}
 
bool clamp_raw_controls_ {false}
 
std::vector< float > cmd_history_vx_
 
std::vector< float > cmd_history_vy_
 
std::vector< float > cmd_history_wz_
 
models::ControlConstraints control_constraints_
 

Detailed Description

Abstract pluginlib class for modeling a vehicle.

Definition at line 39 of file motion_models.hpp.

Member Function Documentation

◆ applyConstraints()

virtual void mppi::MotionModel::applyConstraints ( models::ControlSequence )
inlinevirtual

Apply hard vehicle constraints to a control sequence.

Parameters
control_sequenceControl sequence to apply constraints to

Reimplemented in mppi::AckermannMotionModel.

Definition at line 179 of file motion_models.hpp.

◆ applyDelayShift()

void mppi::MotionModel::applyDelayShift ( models::State state,
bool  is_holo,
unsigned int  offset_vx,
unsigned int  offset_vy,
unsigned int  offset_wz 
) const
inlineprotected

Apply the per-axis input-delay shift to velocity rollout.

For j in [1, offset) — the delay window — fill dst with history[j]

Definition at line 187 of file motion_models.hpp.

Referenced by predict().

Here is the caller graph for this function:

◆ initialize()

virtual void mppi::MotionModel::initialize ( ParametersHandler ,
const std::string &   
)
inlinevirtual

Initialize motion model on bringup.

Parameters
param_handlerPointer to the shared parameters handler
plugin_nameNamespaced name of this plugin instance

Reimplemented in mppi::AckermannMotionModel.

Definition at line 57 of file motion_models.hpp.

◆ isHolonomic()

virtual bool mppi::MotionModel::isHolonomic ( ) const
pure virtual

Whether the motion model is holonomic, using Y axis.

Returns
Bool If holonomic

Implemented in mppi::OmniMotionModel, mppi::DiffDriveMotionModel, and mppi::AckermannMotionModel.

Referenced by predict().

Here is the caller graph for this function:

◆ predict()

virtual void mppi::MotionModel::predict ( models::State state)
inlinevirtual

With input velocities, find the vehicle's output velocities.

Parameters
stateContains control velocities to use to populate vehicle velocities

Definition at line 108 of file motion_models.hpp.

References applyDelayShift(), and isHolonomic().

Here is the call graph for this function:

◆ setConstraints()

void mppi::MotionModel::setConstraints ( const models::ControlConstraints control_constraints,
float  model_dt,
float  model_delay_vx,
float  model_delay_vy,
float  model_delay_wz,
bool  clamp_raw_controls 
)
inline

Initialize motion model on bringup and set required variables.

Parameters
control_constraintsConstraints on control
model_dtduration of a time step

Definition at line 67 of file motion_models.hpp.

References offsetSteps().

Here is the call graph for this function:

Member Data Documentation

◆ control_constraints_

models::ControlConstraints mppi::MotionModel::control_constraints_
protected
Initial value:
{0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f,
0.0f, 0.0f}

Definition at line 250 of file motion_models.hpp.


The documentation for this class was generated from the following file: