Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

HolonomicMotionModel< ParticleT > Class Template Reference

This class can model the path of a holonomic robot in two dimensions (x and y). More...

#include <HolonomicMotionModel.h>

Inheritance diagram for HolonomicMotionModel< ParticleT >:

Detailed Description

template<typename ParticleT>
class HolonomicMotionModel< ParticleT >

This class can model the path of a holonomic robot in two dimensions (x and y).

This class can also model a non-holonomic robot, just don't use the y parameter!

The static function computeMotion() does the main computational grunt work.

MotionModel.png
Illustration of the equations used. Constant angular and linear velocities result in a circular arc as shown. The radius of the arc is directly determined by the ratio of the linear speed to the angular speed. The final position after time $ \Delta t $ will be $ \delta $ along a bearing $ \theta/2 $, where $ \theta $ is the angle which has been turned during the interval of interest.

You can call setPosition() to initialize the starting location or if the robot has been moved by some external means. You should call setVelocity() whenever the robot's velocity changes. The class will internally store the position and time at which the velocity change happened so that later calls to getPosition() will return points along the new path.

This class can be used as a motion model in the ParticleFilter class, or independently if desired for general purpose motion estimation. (see the standalone computeHolonomicMotion())

However, if you are looking for a motion model for ParticleFiltering, it may be more convenient to use DeadReckoningBehavior because you can start the behavior and it will subscribe to automatically receive LocomotionEvents from then on. If using HolonomicMotionModel directly with the particle filter, you would need to call setVelocity() yourself anytime the robot changes direction.

Variance parameters only come into play with updateMotion(), which is called on collections of particles. The other functions all return "ideal" motion calculations. Be aware that when using in a particle filter, the position is reset on particle updates (updateMotion()). In other words, the position returned by motion model is the offset achieved since the last particle update, not the position relative to world's origin, nor any other fixed point.

Caveat: acceleration is not handled by this model. That would be a nice addition...

See also:
computeHolonomicMotion()

Definition at line 54 of file HolonomicMotionModel.h.

List of all members.

Public Types

typedef ParticleFilter
< ParticleT >
::MotionModel::particle_type 
particle_type
 redefinition here allows reference to the particle type even if the template parameter may be abstracted away due to a typedef
typedef ParticleFilter
< ParticleT >
::MotionModel::particle_collection 
particle_collection
 the collection type we'll be using to store the particles
typedef
particle_collection::size_type 
index_t
 index type for refering to particles within the collection

Public Member Functions

 HolonomicMotionModel ()
 constructor, with default noise parameters (xvar=yvar=50, avar=0.15f)
 HolonomicMotionModel (float xVariance, float yVariance, float aVariance)
 constructor, with noise parameters (pass 0's to make it an "ideal" motion model)
virtual void updateMotion (particle_collection &particles, particle_type &estimate)
 called by the particle filter when the current position of each particle should be updated
void getPosition (float &outx, float &outy, float &outa) const
 stores the current position into the arguments (based on get_time() vs the time the position was last set)
void getPosition (float &outx, float &outy, float &outa, unsigned int curtime) const
 stores the current position into the arguments (based on curtime vs the time the position was last set)
void setPosition (float x, float y, float angle)
 sets the current position to the specified values and updates the timestamp to the current time
void setPosition (float x, float y, float angle, unsigned int curtime)
 sets the current position to the specified values and updates the timestamp to the specified time
void getVelocity (float &outxv, float &outyv, float &outav) const
 stores the current velocity into the arguments (no noise is added, this just echos the values passed to setVelocity())
void setVelocity (float xv, float yv, float av)
 sets the current velocity to the specified values and updates the position and timestamp to the current time
void setVelocity (float xv, float yv, float av, unsigned int curtime)
 sets the current velocity to the specified values and updates the position and timestamp to the specified time
void setVariance (float xv, float yv, float av)
 allows you to change the variance parameters (xvar, yvar, avar)
void setCrossVariance (float axis, float angle)
 allows you to change the cross-variance parameters (crossAxis, crossAngle)
float getXVariance () const
 accessor for xvar
float getYVariance () const
 accessor for yvar
float getAVariance () const
 accessor for avar
float getAxisCrossVariance () const
 accessor for crossAxis
float getAngleCrossVariance () const
 accessor for crossAngle

Protected Attributes

float xvel
 current x velocity
float yvel
 current y velocity
float avel
 current angular velocity
unsigned int prevtime
 time (in milliseconds) that the position was last set
float posx
 x position at which prevtime was set
float posy
 y position at which prevtime was set
float posa
 orientation at which prevtime was set
float xvar
 variance of x velocities as ratio of x speed, used when updating particle list (updateMotion())
float yvar
 variance of y velocities as ratio of y speed, used when updating particle list (updateMotion())
float avar
 variance of angular velocities as ratio of angular speed, used when updating particle list (updateMotion())
float crossAxis
 cross variance of x speed on y speed and vice versa
float crossAngle
 cross variance of x,y speed on angular speed

Member Typedef Documentation

template<typename ParticleT >
typedef particle_collection::size_type HolonomicMotionModel< ParticleT >::index_t

index type for refering to particles within the collection

Reimplemented from ParticleFilter< ParticleT >::MotionModel.

Definition at line 58 of file HolonomicMotionModel.h.

template<typename ParticleT >
typedef ParticleFilter<ParticleT>::MotionModel::particle_collection HolonomicMotionModel< ParticleT >::particle_collection

the collection type we'll be using to store the particles

Reimplemented from ParticleFilter< ParticleT >::MotionModel.

Definition at line 57 of file HolonomicMotionModel.h.

template<typename ParticleT >
typedef ParticleFilter<ParticleT>::MotionModel::particle_type HolonomicMotionModel< ParticleT >::particle_type

redefinition here allows reference to the particle type even if the template parameter may be abstracted away due to a typedef

Reimplemented from ParticleFilter< ParticleT >::MotionModel.

Definition at line 56 of file HolonomicMotionModel.h.


Constructor & Destructor Documentation

template<typename ParticleT >
HolonomicMotionModel< ParticleT >::HolonomicMotionModel (  ) 

constructor, with default noise parameters (xvar=yvar=50, avar=0.15f)

Definition at line 61 of file HolonomicMotionModel.h.

template<typename ParticleT >
HolonomicMotionModel< ParticleT >::HolonomicMotionModel ( float  xVariance,
float  yVariance,
float  aVariance 
)

constructor, with noise parameters (pass 0's to make it an "ideal" motion model)

Variance parameters only come into play with updateMotion(), which is called on collections of particles. The other functions all return "ideal" motion calculations.

Definition at line 69 of file HolonomicMotionModel.h.


Member Function Documentation

template<typename ParticleT >
float HolonomicMotionModel< ParticleT >::getAngleCrossVariance (  )  const

accessor for crossAngle

Definition at line 198 of file HolonomicMotionModel.h.

template<typename ParticleT >
float HolonomicMotionModel< ParticleT >::getAVariance (  )  const

accessor for avar

Definition at line 196 of file HolonomicMotionModel.h.

template<typename ParticleT >
float HolonomicMotionModel< ParticleT >::getAxisCrossVariance (  )  const

accessor for crossAxis

Definition at line 197 of file HolonomicMotionModel.h.

template<typename ParticleT >
void HolonomicMotionModel< ParticleT >::getPosition ( float outx,
float outy,
float outa,
unsigned int  curtime 
) const

stores the current position into the arguments (based on curtime vs the time the position was last set)

Definition at line 134 of file HolonomicMotionModel.h.

template<typename ParticleT >
void HolonomicMotionModel< ParticleT >::getPosition ( float outx,
float outy,
float outa 
) const

stores the current position into the arguments (based on get_time() vs the time the position was last set)

Definition at line 125 of file HolonomicMotionModel.h.

Referenced by DeadReckoningBehavior< ParticleT >::doEvent().

template<typename ParticleT >
void HolonomicMotionModel< ParticleT >::getVelocity ( float outxv,
float outyv,
float outav 
) const

stores the current velocity into the arguments (no noise is added, this just echos the values passed to setVelocity())

Definition at line 157 of file HolonomicMotionModel.h.

template<typename ParticleT >
float HolonomicMotionModel< ParticleT >::getXVariance (  )  const

accessor for xvar

Definition at line 194 of file HolonomicMotionModel.h.

template<typename ParticleT >
float HolonomicMotionModel< ParticleT >::getYVariance (  )  const

accessor for yvar

Definition at line 195 of file HolonomicMotionModel.h.

template<typename ParticleT >
void HolonomicMotionModel< ParticleT >::setCrossVariance ( float  axis,
float  angle 
)

allows you to change the cross-variance parameters (crossAxis, crossAngle)

Definition at line 189 of file HolonomicMotionModel.h.

template<typename ParticleT >
void HolonomicMotionModel< ParticleT >::setPosition ( float  x,
float  y,
float  angle,
unsigned int  curtime 
)

sets the current position to the specified values and updates the timestamp to the specified time

Definition at line 149 of file HolonomicMotionModel.h.

template<typename ParticleT >
void HolonomicMotionModel< ParticleT >::setPosition ( float  x,
float  y,
float  angle 
)

sets the current position to the specified values and updates the timestamp to the current time

Definition at line 146 of file HolonomicMotionModel.h.

Referenced by HolonomicMotionModel< ParticleT >::setPosition().

template<typename ParticleT >
void HolonomicMotionModel< ParticleT >::setVariance ( float  xv,
float  yv,
float  av 
)

allows you to change the variance parameters (xvar, yvar, avar)

Definition at line 185 of file HolonomicMotionModel.h.

template<typename ParticleT >
void HolonomicMotionModel< ParticleT >::setVelocity ( float  xv,
float  yv,
float  av,
unsigned int  curtime 
)

sets the current velocity to the specified values and updates the position and timestamp to the specified time

Definition at line 167 of file HolonomicMotionModel.h.

template<typename ParticleT >
void HolonomicMotionModel< ParticleT >::setVelocity ( float  xv,
float  yv,
float  av 
)

sets the current velocity to the specified values and updates the position and timestamp to the current time

Definition at line 164 of file HolonomicMotionModel.h.

Referenced by DeadReckoningBehavior< ParticleT >::doEvent(), DeadReckoningBehavior< ParticleT >::doStart(), and HolonomicMotionModel< ParticleT >::setVelocity().

template<typename ParticleT >
virtual void HolonomicMotionModel< ParticleT >::updateMotion ( particle_collection particles,
particle_type estimate 
) [virtual]

called by the particle filter when the current position of each particle should be updated

This will reset the motion model to set the origin at the current location after the particles are updated, so that the next call to updateMotion() will supply the particles with the displacement which occurred since the last update

Definition at line 79 of file HolonomicMotionModel.h.


Member Data Documentation

template<typename ParticleT >
float HolonomicMotionModel< ParticleT >::avar [protected]

variance of angular velocities as ratio of angular speed, used when updating particle list (updateMotion())

Definition at line 212 of file HolonomicMotionModel.h.

Referenced by HolonomicMotionModel< ParticleT >::getAVariance(), HolonomicMotionModel< ParticleT >::setVariance(), and HolonomicMotionModel< ParticleT >::updateMotion().

template<typename ParticleT >
float HolonomicMotionModel< ParticleT >::crossAngle [protected]
template<typename ParticleT >
float HolonomicMotionModel< ParticleT >::crossAxis [protected]
template<typename ParticleT >
unsigned int HolonomicMotionModel< ParticleT >::prevtime [protected]
template<typename ParticleT >
float HolonomicMotionModel< ParticleT >::xvar [protected]

variance of x velocities as ratio of x speed, used when updating particle list (updateMotion())

Definition at line 210 of file HolonomicMotionModel.h.

Referenced by HolonomicMotionModel< ParticleT >::getXVariance(), HolonomicMotionModel< ParticleT >::setVariance(), and HolonomicMotionModel< ParticleT >::updateMotion().

template<typename ParticleT >
float HolonomicMotionModel< ParticleT >::yvar [protected]

variance of y velocities as ratio of y speed, used when updating particle list (updateMotion())

Definition at line 211 of file HolonomicMotionModel.h.

Referenced by HolonomicMotionModel< ParticleT >::getYVariance(), HolonomicMotionModel< ParticleT >::setVariance(), and HolonomicMotionModel< ParticleT >::updateMotion().


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

Tekkotsu v5.1CVS
Generated Mon May 9 04:59:09 2016 by Doxygen 1.6.3