PPL API Reference |
|
---|
Public Member Functions | |
Construction | |
PlanningAgent (Robot *const _r) | |
PlanningAgent (Robot *const _r, const PlanningAgent &_a) | |
PlanningAgent (Robot *const _r, XMLNode &_node) | |
virtual std::unique_ptr< Agent > | Clone (Robot *const _r) const override |
virtual | ~PlanningAgent () |
Agent Overrides | |
virtual void | Initialize () override |
virtual void | Step (const double _dt) override |
virtual void | Uninitialize () override |
virtual void | SetTask (std::shared_ptr< MPTask > const _task) override |
Planning | |
virtual bool | HasPlan () const |
virtual void | ClearPlan () |
bool | IsPlanning () const |
size_t | GetPlanVersion () const |
MPSolution * | GetMPSolution () |
Agent Properties | |
Robot * | GetRobot () const noexcept |
Get the robot object to which this agent belongs. | |
virtual bool | IsChild () const noexcept |
Is this agent a child of some group/aggregate? | |
Task Management | |
std::shared_ptr< MPTask > | GetTask () const noexcept |
Get the task that the agent is currently working on. | |
virtual void | ResetStartConstraint () |
Simulation Interface | |
size_t | MinimumSteps () const |
std::vector< Agent * > | ProximityCheck (const double _distance) const |
Agent Control | |
void | Halt () |
void | PauseAgent (const size_t _steps) |
Accessors | |
const std::string & | GetCapability () const noexcept |
Get the type of agent. | |
Static Public Member Functions | |
Construction | |
static std::unique_ptr< Agent > | Factory (Robot *const _r, XMLNode &_node) |
Protected Member Functions | |
void | Localize () |
Instruct the agent to enqueue a command for gathering sensor readings. | |
bool | IsLocalizing () const noexcept |
Is the agent waiting on sensor data? | |
Cfg | EstimateState () |
Estimate the state of the robot from the last localization data. | |
bool | ContinueLastControls () |
virtual void | ExecuteControls (const ControlSet &_c, const size_t _steps) |
virtual void | ExecuteControlsSimulation (const ControlSet &_c, const size_t _steps) |
virtual void | ExecuteControlsHardware (const ControlSet &_c, const size_t _steps) |
Planning Helpers | |
virtual void | GeneratePlan () |
virtual void | WorkFunction (std::shared_ptr< MPProblem > _problem) |
Function call for PPL. More... | |
void | StopPlanning () |
Task Helpers | |
virtual bool | SelectTask () |
virtual bool | EvaluateTask () |
virtual void | ExecuteTask (const double _dt) |
Localization Helpers | |
void | UpdateSimulatedState () |
Protected Attributes | |
Internal State | |
std::unique_ptr< MPLibrary > | m_library |
This agent's planning library. | |
std::unique_ptr< MPSolution > | m_solution |
The current solution. | |
std::thread | m_thread |
Thread for agent to run PPL. | |
std::atomic< bool > | m_planning {false} |
Is the agent currently planning. | |
std::atomic< size_t > | m_planVersion {1} |
The current plan version. | |
size_t | m_roadmapVisualID {size_t(-1)} |
The ID of the roadmap drawing. | |
size_t | m_pathVisualID {size_t(-1)} |
The ID of the path drawing. | |
size_t | m_localizePeriod {200} |
The number of timesteps between localize calls. | |
size_t | m_localizeCount {1} |
The number of timesteps since the last localize call. | |
double | m_localizeErrorThreshold {0.4} |
The largest allowed error before requiring a replan. | |
Internal State | |
Robot *const | m_robot |
The robot that this agent controls. | |
bool | m_initialized {false} |
Is the agent initialized? | |
std::shared_ptr< MPTask > | m_task |
The task this agent is working on. | |
ControlSet | m_currentControls |
The current control set. | |
size_t | m_stepsRemaining {0} |
Steps remaining on current controls. | |
bool | m_debug {true} |
Toggle debug messages. | |
std::string | m_capability |
Specifies the type of agent for heterogenous multiagent teams. More... | |
std::unique_ptr< StepFunction > | m_stepFunction |
Base class for agents which will plan paths using PPL. This agent only plans; it does not attempt to execute the plan in the simulation.
The core behavior is: 1. If no task, select one (or pass if none is available). 2. If no plan, create one (in a separate thread, robot waits during planning). 3. Continue executing current plan.
There are two primary mechanisms for directing agents of this type: 1. The task: describes the agent's planning task/high level goal. Without a task, the agent will not attempt to do anything. 2. The plan: describes the agent's motion plan for achieving the task. Clearing this without clearing the task will cause the agent to replan.
Whenever the agent produces a new plan or clears an existing one, its 'plan version' will be incremented by one. This allows coordinated agents to detect changes in each others' plans and possibly react/replan in response.
PlanningAgent::PlanningAgent | ( | Robot *const | _r | ) |
Create an agent for a robot.
_r | The robot which this agent will reason for. |
PlanningAgent::PlanningAgent | ( | Robot *const | _r, |
const PlanningAgent & | _a | ||
) |
Copy an agent for another robot.
_r | The destination robot. |
_a | The agent to copy. |
Create an agent for a robot.
_r | The robot which this agent will reason for. |
_node | The XML node to parse. |
Create a copy of this agent for another robot. This is provided so that we can copy an agent without knowing its type.
_r | The robot which this cloned agent will reason for. |
Implements Agent.
Reimplemented in PathFollowingAgent.
|
overridevirtual |
Set up the agent before running. Anything that needs to be done only once on first starting should go here.
Implements Agent.
|
overridevirtual |
Decide what to do on each time step in the simulation. The agent should implement its decision by sending commands to the robot's controller.
_dt | The timestep length. |
Implements Agent.
|
overridevirtual |
Tear down the agent. Release any resources and reset the object to its pre-initialize state.
Implements Agent.
Reimplemented in PathFollowingAgent.
|
overridevirtual |
|
virtual |
Does the agent have a plan for its current task?
Reimplemented in PathFollowingAgent.
|
virtual |
Clear the agent's current plan. If a plan was cleared, the plan version will be updated. Overrides should always call this base method to update the plan version.
Reimplemented in PathFollowingAgent.
bool PlanningAgent::IsPlanning | ( | ) | const |
Is the agent currently generating a plan?
size_t PlanningAgent::GetPlanVersion | ( | ) | const |
Get the current version number for the agent's plan.
MPSolution * PlanningAgent::GetMPSolution | ( | ) |
Get the pointer to this agents solution object.
|
protectedvirtual |
Generate a plan for the agent's current task. Calls the WorkFunction in a separate thread.
|
protectedvirtual |
Function call for PPL.
Reimplemented in PathFollowingAgent.
|
protected |
Stop the current plan (only works for MPStrategies which are implemented using the base Run() method).
|
protectedvirtual |
Select the next task for this agent. The base implementation selects the first available task.
|
protectedvirtual |
Evaluate the agent's progress on its current task.
Reimplemented in PathFollowingAgent.
|
protectedvirtual |
Continue executing the agent's current task.
_dt | The step length. |
Reimplemented in PathFollowingAgent.
|
protected |
Evaluates whether the robot's simulated state is incorrect (beyond some error threshold) and sets the simulated state as necessary.
Create a dynamically-allocated agent from an XML node.
_r | The robot which this agent will reason for. |
_node | The XML node to parse. |
|
virtualinherited |
Resets the start constraint of the current task to the robot's current position.
|
inherited |
Find the smallest time interval which is an integer multiple of the problem time resolution and larger than the hardware time (if any).
|
inherited |
Check for proximity to other robots and return those that lie within some threshold. @WARNING This checks the distance between the robots' reference points; it does not indicate the minimum distance between their hulls.
_distance | The distance threshold. |
|
inherited |
Stop the robot in simulation (places 0s in all 6 velocity dofs). @WARNING Arbitrarily setting the velocity does not respect the robot's dynamics. It is suitable for debugging and freezing a scenario upon completion, but it is not physically realistic.
|
inherited |
Orders the agent to stop itself at its current position. It will ask the controller to choose actions which stay as close as possible to the current position.
_steps | The number of steps to stop for. |
|
protectedinherited |
Continue executing the last controls if time remains.
|
protectedvirtualinherited |
Execute a set of controls on the simulated robot, and additionally on the hardware if present.
_c | The controls to execute. |
_steps | The number of time steps to execute the control. |
|
protectedvirtualinherited |
Execute a set of controls on the simulated robot.
_c | The controls to execute. |
|
protectedvirtualinherited |
Execute a set of controls on the hardware if present.
_c | The controls to execute. |
_steps | The number of time steps to execute the control. |
|
protectedinherited |
Specifies the type of agent for heterogenous multiagent teams.
Step function to define agent behaviors.