File server.cpp#
Definition (server/src/server.cpp)#
Includes#
ExecutionManager.h
Namespaces#
Functions#
Full File Listing#
-
namespace RPC#
API functions for external communication with the MAPF planner and the executor (the robots).
-
namespace rpc_api#
Functions
-
string getRobotsLocation()#
Get the latest MAPF instance, newly finished task IDs, and initialization status.
- Returns:
A JSON string with the following schema.
{ "initialized": true, "mapf_instance": { "starts": [ State, ... ], "goals": [ [ Task, ... ], ... ] }, "new_finished_tasks": [ 0, 1, 2, 3 ] }initializedindicates whether the system has completed initialization.mapf_instancecontains the current MAPF problem state:startsis a list ofStateobjects describing the current start states of all agents:Each
Statehas the structure:{ "location": 42, "timestep": 10, "orientation": 1 }
locationis the flattened cell ID.timestepis the start timestep, usually0.orientationis encoded as:0: East1: North2: West3: South
goalsis a list of task lists, where each task list corresponds to a robot:Each
Taskobject has the structure:{ "id": 0, "location": 84, "task_wait_time": 0, "orientation": -1 }
idis the unique task identifier.locationis the flattened cell ID of the task location.task_wait_timeis the number of timesteps the agent should wait at the task location, usually0.orientationis the required orientation at the task location, with-1indicating no constraint.
new_finished_tasksis a list of task IDs completed since the last query.
-
void addNewPlan(string &new_plan_json_str)#
Add a new MAPF plan to the ADG.
This function takes a JSON string representing a new MAPF plan and adds it to the ADG (Action Decision Graph). If necessary, it utilizes the backup planner to ensure the plan is integrated correctly.
- Parameters:
new_plan_json_str – A JSON string with a new MAPF plan with the following schema:
{ "success": true, "plan": [ [(row, col, timestep, task_id), ... ], ... ], "congested": false, "stats": { ... } }plan: a list of lists of tuples, where each outer list corresponds to a single robot’s path. Each inner list contains tuples of the form(row, col, timestep, task_id):row: The row index of the robot’s position on the grid.col: The column index of the robot’s position on the grid.timestep: The timestep at which the robot should be at the specified position.task_id: The task identifier, or-1if no task is associated.
success: indicates whether the planner successfully produced collision-free paths for all robots. Iffalse, the backup planner is invoked.congested[Optional]: indicates whether congestion was detected, typically defined as more than half of the robots making no progress.stats[Optional]: contains additional planner statistics recorded by LSMART.
-
bool isInitialized()#
Check if the system has been initialized.
- Returns:
a boolean indicating whether the system has been initialized.
-
bool invokePlanner()#
Determine whether to invoke the planner.
- Returns:
a boolean indicating whether the planner should be invoked. In practice, the MAPF planner can have a while loop checking for this condition to decide whether to request a new MAPF instance from the system.
-
string getRobotsLocation()#