Bratmobile
Classes | Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
Task Class Reference

A closed hybrid control loop. It has an initial disturbance representing the continuous state and a direction representing (in 2D) the discrete control strategy. More...

#include <task.h>

Collaboration diagram for Task:
Collaboration graph
[legend]

Classes

struct  Action
 The motor instructions generated by the control strategy used in this tasks. More...
 
class  Listener
 Used to find collisions in the Box2D simulation. More...
 

Public Member Functions

Task::Action getAction () const
 
AffordanceIndex getAffIndex ()
 
Direction H (Disturbance ob, Direction d, bool topDown=0)
 Agent transfer function H which generates a motor output (Action) in response to a disturbance. More...
 
void setEndCriteria (const Angle &angle=SAFE_ANGLE, const Distance &distance=BOX2DRANGE)
 Sets the end criteria for this task (bounds of the Flow condition). Angle is a valid measurement for turning task but not for DEFAULT Tasks. More...
 
void setEndCriteria (const Distance &distance)
 
void setEndCriteria (const EndCriteria &ec)
 
EndedResult checkEnded (b2Transform robotTransform=b2Transform_zero, Direction dir=UNDEFINED, bool relax=0, b2Body *robot=NULL, std::pair< bool, b2Transform > use_start=std::pair< bool, b2Transform >(1, b2Transform_zero))
 Check if this task has ended based on state information (default are info for the task which calls the method) More...
 
EndedResult checkEnded (const State &n, Direction dir=UNDEFINED, bool relax=false, std::pair< bool, b2Transform > use_start=std::pair< bool, b2Transform >(1, b2Transform_zero))
 Check if a state represents the end of this task. More...
 
bool checkEnded (const b2PolygonShape &box, const b2Transform &robot_pose=b2Transform_zero, Disturbance *dist_obs=NULL)
 Uses a virtual sensor (attention window) to determine whether the task has ended or not. More...
 
 Task (Direction d)
 
 Task (Disturbance ob, Direction d, b2Transform _start=b2Transform(b2Vec2(0.0, 0.0), b2Rot(0.0)), bool topDown=0)
 
simResult bumping_that (b2World &_world, int iteration, b2Body *, float remaining=SIM_DURATION)
 Executes this task in a Box2D simulation. More...
 
EndCriteria getEndCriteria (const Disturbance &d)
 Returns the endCriteria for this Task if it were to counteract Disturbance. More...
 
EndCriteriagetEndCriteria ()
 Returns a REFERENCE to the endCriteria.
 
bool endCriteria_met (Angle &a, Distance &d)
 Returns true if the endCriteria is met based on. More...
 
b2Transform from_Di (const b2Transform *custom_start=NULL, Disturbance *d_obs=NULL)
 Returns a b2Transform expressing the pose of the disturbance relative to the robot in the robot's local coordinates. More...
 
void set_change (bool b)
 
bool get_change ()
 
bool is_over ()
 If task has finished executing. More...
 
Disturbanceget_disturbance_ptr ()
 Get a pointer to the disturbance. More...
 
const Disturbanceget_disturbance () const
 
void setMotorStep (int i)
 
int getMotorStep () const
 
b2Transform getStart ()
 
b2Transform & getStartRef ()
 
Direction get_direction ()
 
void set_direction (Direction d)
 

Protected Member Functions

bool isTurnFinished (const b2Transform &robotTransform, Direction dir)
 
bool isMoving ()
 

Protected Attributes

char planFile [250]
 
bool debug_k =false
 
bool change =0
 
b2Transform start =b2Transform_zero
 
EndCriteria endCriteria
 
Direction direction = DEFAULT
 
int motorStep =0
 
AffordanceIndex affordance =NONE
 
Action action
 
Disturbance disturbance
 

Friends

class Configurator
 

Detailed Description

A closed hybrid control loop. It has an initial disturbance representing the continuous state and a direction representing (in 2D) the discrete control strategy.

Member Function Documentation

◆ bumping_that()

simResult Task::bumping_that ( b2World &  _world,
int  iteration,
b2Body *  robot,
float  remaining = SIM_DURATION 
)

Executes this task in a Box2D simulation.

Parameters
_worldbox2d world
iterationconfigurator iteration (for logging)
remaining(simulation duration in seconds)
Returns
simResult

◆ checkEnded() [1/3]

EndedResult Task::checkEnded ( b2Transform  robotTransform = b2Transform_zero,
Direction  dir = UNDEFINED,
bool  relax = 0,
b2Body *  robot = NULL,
std::pair< bool, b2Transform >  use_start = std::pair <bool,b2Transform>(1, b2Transform_zero) 
)

Check if this task has ended based on state information (default are info for the task which calls the method)

Parameters
robotTransformthe robot's pose to evaluate
dirthe direction of the task being carried out
relaxapply a larger threshold to check whehter a goal was reached
robotrobot box2d body
use_startuse a custom start for the task
Returns
EndedResult

◆ checkEnded() [2/3]

bool Task::checkEnded ( const b2PolygonShape &  box,
const b2Transform &  robot_pose = b2Transform_zero,
Disturbance dist_obs = NULL 
)

Uses a virtual sensor (attention window) to determine whether the task has ended or not.

Parameters
boxthe sensor
robot_pose
dist_obspointer to the observed disturbance (the disturbance as it was at the beginning of the task, or as it was expected)
Returns
true
false

◆ checkEnded() [3/3]

EndedResult Task::checkEnded ( const State n,
Direction  dir = UNDEFINED,
bool  relax = false,
std::pair< bool, b2Transform >  use_start = std::pair <bool,b2Transform>(1, b2Transform_zero) 
)

Check if a state represents the end of this task.

Parameters
nthe state
dirthe direction of the task being carried out
relaxapply a larger threshold to check whehter a goal was reached
use_startuse a custom start for the task
Returns
EndedResult

◆ endCriteria_met()

bool Task::endCriteria_met ( Angle a,
Distance d 
)

Returns true if the endCriteria is met based on.

Parameters
aangle from the disturbance
ddistance from the disturbance

◆ from_Di()

b2Transform Task::from_Di ( const b2Transform *  custom_start = NULL,
Disturbance d_obs = NULL 
)

Returns a b2Transform expressing the pose of the disturbance relative to the robot in the robot's local coordinates.

Parameters
custom_startglobal coordinates of the task start, if null defaults to the origin
d_obsa disturbance different from the Di for this task. If null defaults to Di
Returns
b2Transform

◆ get_disturbance_ptr()

Disturbance* Task::get_disturbance_ptr ( )
inline

Get a pointer to the disturbance.

Returns
Disturbance*

◆ getEndCriteria()

EndCriteria Task::getEndCriteria ( const Disturbance d)

Returns the endCriteria for this Task if it were to counteract Disturbance.

Parameters
d

◆ H()

Direction Task::H ( Disturbance  ob,
Direction  d,
bool  topDown = 0 
)

Agent transfer function H which generates a motor output (Action) in response to a disturbance.

Parameters
obthe disturbance
dtop-down instruction on how to generate the Action. DEFAULT with no top down control generates a reflex
topDownwhether the input direction should be used as is (true) or to generate a reflex (false)
Returns
Direction

NB: only generates default turns if absolute angle of the disturbance is larger than .1rad

◆ is_over()

bool Task::is_over ( )
inline

If task has finished executing.

Returns
true if step==0 or if manually set to change
false

◆ setEndCriteria()

void Task::setEndCriteria ( const Angle angle = SAFE_ANGLE,
const Distance distance = BOX2DRANGE 
)

Sets the end criteria for this task (bounds of the Flow condition). Angle is a valid measurement for turning task but not for DEFAULT Tasks.

Parameters
anglemanually input angle
distancemanually input distance

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