Klamp't  0.9.0
Public Types | Public Member Functions | Public Attributes | List of all members
Klampt::RealTimePlanner Class Reference

A real-time planner. Supports constant time-stepping or adaptive time-stepping. More...

#include <RealTimePlanner.h>

Public Types

enum  SplitUpdateProtocol { Constant, ExponentialBackoff, Learning }

Public Member Functions

void SetSpace (SingleRobotCSpace *space)
 Convenience fn: will set up the planner's robot, space, settings pointers.
void SetConstantPath (const Config &q)
 Should be called at the start to initialize the start configuration.
void SetCurrentPath (Real tglobal, const ParabolicRamp::DynamicPath &path)
virtual void Reset (shared_ptr< PlannerObjectiveBase > newgoal)
 Set the objective function.
shared_ptr< PlannerObjectiveBaseObjective () const
 Gets the objective function.
virtual bool PlanUpdate (Real tglobal, Real &splitTime, Real &planTime)
bool StopPlanning ()
 Tells the planner to stop, when called from an external thread.
virtual void MarkSendFailure ()

Public Attributes

shared_ptr< DynamicMotionPlannerBaseplanner
 Users must set these members before planning. More...
Real pathStartTime
 Set the current path before planning, using SetConstantPath or SetCurrentPath.
ParabolicRamp::DynamicPath currentPath
shared_ptr< SendPathCallbackBasesendPathCallback
 Users should set this up to capture the outputted path.
Real cognitiveMultiplier
bool acceptTimeOverruns
SplitUpdateProtocol protocol
Real currentSplitTime
Real currentPadding
Real currentExternalPadding
Real maxPadding
StatCollector planFailTimeStats
 Statistics captured on planning times, depending on PlanMore output.
StatCollector planSuccessTimeStats
StatCollector planTimeoutTimeStats

Detailed Description

A real-time planner. Supports constant time-stepping or adaptive time-stepping.

Users must set up the underlying planner, the planning problem and may add in path sending hooks.

See also

Setup: Given a world and a robotIndex (typically 0), assuming the robot model is set to its current configuration ...

RealTimePlanner planner;
planner.planner = new MyDynamicMotionPlanner;
(try, for example, DynamicIKPlanner, DynamicHybridTreePlanner)
SingleRobotCSpace cspace(...); (initialize cspace as necessary)
//set planning problem
//set current path -- just stationary
//set objective
IKObjective* objective = new IKObjective(robot);
objective->ikGoal = ... // setup initial IK objective
planner.sendPathCallback = new MySendPathCallback;

Online: The planner should be launched in a parallel thread to the execution thread. The planning thread should maintain a global timer, synchronized with the execution thread.

while(true) {
Real t = currentGlobalTime();
if(objectiveChanged) {
//set new objective if needed
IKObjective* objective = new IKObjective(robot);
objective->ikGoal = ... // setup IK objective
Real splitTime, planTime;
bool changed = planner.PlanUpdate(t,splitTime,planTime);
//planner.sendPathCallback will be called if the planner succeeded
if(changed) {
printf("Path was successfully updated, split time %g, plan time %g\n",splitTime,planTime);
else {
printf("Path update was unsuccessful, split time %g, plan time %g\n",splitTime,planTime);

Member Function Documentation

virtual void Klampt::RealTimePlanner::MarkSendFailure ( )

Called whenever the sendPathCallback returned false on a planned path (e.g., the padding was too short)

virtual bool Klampt::RealTimePlanner::PlanUpdate ( Real  tglobal,
Real &  splitTime,
Real &  planTime 

Calls the planner, returns the splitting time and planning time. tglobal is a global clock synchronized between the planning and execution threads. Default implementation: fix the split time, call planner->PlanFrom Returns true if the path changed and planTime < splitTime

void Klampt::RealTimePlanner::SetCurrentPath ( Real  tglobal,
const ParabolicRamp::DynamicPath path 

If the robot's path has changed for a reason outside of the planner's control, call this before planning

Member Data Documentation

bool Klampt::RealTimePlanner::acceptTimeOverruns

Use only in simulation: set to true if you want to allow PlanFrom instances that overrun their alloted time to still update the path.

Real Klampt::RealTimePlanner::cognitiveMultiplier

Use only in simulation: multiplies the effective computational power of this machine (i.e., simulate a machine that's x times faster)

shared_ptr<DynamicMotionPlannerBase> Klampt::RealTimePlanner::planner

Users must set these members before planning.

The underlying planing algorithm

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