Coverage Control Library
Loading...
Searching...
No Matches
CoverageSystem Class Reference

The CoverageSystem class is the main class for the coverage control library. More...

#include <coverage_system.h>

Public Member Functions

Constructors
 CoverageSystem ()=delete
 
 CoverageSystem (Parameters const &params)
 Create random Gaussian distributions for the world IDF and random start positions for the robots.
 
 CoverageSystem (Parameters const &params, int const num_gaussians, int const num_robots)
 Create random Gaussian distributions for the world IDF and random start positions for the robots.
 
 CoverageSystem (Parameters const &params, int const num_gaussians, int const num_polygons, int const num_robots)
 
 CoverageSystem (Parameters const &params, WorldIDF const &world_idf, std::string const &pos_file_name)
 Create with given world IDF and robot positions from file.
 
 CoverageSystem (Parameters const &params, WorldIDF const &world_idf, std::vector< Point2 > const &robot_positions)
 Constructor for given world IDF and robot positions as a vector.
 
 CoverageSystem (Parameters const &params, std::vector< BivariateNormalDistribution > const &dists, std::vector< Point2 > const &robot_positions)
 Constructor for given normal distributions and robot positions.
 
Setters
void SetLocalRobotPositions (std::vector< Point2 > const &relative_pos)
 
void SetLocalRobotPosition (size_t const robot_id, Point2 const &relative_pos)
 Set the position of robot_id with respect to its current position.
 
void SetGlobalRobotPosition (size_t const robot_id, Point2 const &global_pos)
 Set the global position of robot_id.
 
void SetGlobalRobotPositions (PointVector const &global_positions)
 Set the global positions of all robots.
 
void SetRobotPositions (std::vector< Point2 > const &positions)
 
void SetWorldIDF (WorldIDF const &world_idf)
 Set the world IDF and recompute the world map.
 
Robot related functions
bool StepActions (PointVector const &actions)
 Execute given actions for all robots.
 
bool StepAction (size_t const robot_id, Point2 const action)
 Execute given action for robot_id.
 
bool StepControl (size_t robot_id, Point2 const &direction, double const speed)
 Execute velocity control for robot_id.
 
Point2 AddNoise (Point2 const pt) const
 Add noise to the given point and ensure within bounds.
 
bool CheckOscillation (size_t const robot_id) const
 
void CheckRobotID (size_t const id) const
 
void ComputeVoronoiCells ()
 
bool StepRobotToGoal (int const robot_id, Point2 const &goal, double const speed_factor=1)
 
bool StepRobotsToGoals (PointVector const &goals, PointVector &actions)
 
void ClearRobotMaps ()
 
void ClearExploredIDF ()
 
I/O
int WriteRobotPositions (std::string const &file_name) const
 
int WriteRobotPositions (std::string const &file_name, PointVector const &positions) const
 
int WriteEnvironment (std::string const &pos_filename, std::string const &env_filename) const
 
Plot related functions
void PlotFrontiers (std::string const &, int const &, PointVector const &) const
 
void PlotSystemMap (std::string const &dir_name, int const &step) const
 
void PlotSystemMap (std::string const &) const
 
void PlotSystemMap (std::string const &, int const &, std::vector< int > const &) const
 
void PlotMapVoronoi (std::string const &, int const &)
 
void PlotMapVoronoi (std::string const &, int const &, Voronoi const &, PointVector const &) const
 
void PlotWorldMap (std::string const &, std::string const &) const
 
void PlotWorldMapRobots (std::string const &, std::string const &) const
 
void PlotInitMap (std::string const &filename) const
 
void PlotInitMap (std::string const &, std::string const &) const
 
void PlotRobotLocalMap (std::string const &, int const &, int const &)
 
void PlotRobotSystemMap (std::string const &, int const &, int const &)
 
void PlotRobotExplorationMap (std::string const &, int const &, int const &)
 
void PlotRobotSensorView (std::string const &, int const &, int const &)
 
void PlotRobotObstacleMap (std::string const &, int const &, int const &)
 
void PlotRobotCommunicationMaps (std::string const &, int const &, int const &, size_t const &)
 
void RenderRecordedMap (std::string const &, std::string const &) const
 
void RecordPlotData (std::vector< int > const &, std::string const &)
 
void RecordPlotData (std::vector< int > const &robot_status)
 
void RecordPlotData (std::string const &map_name)
 
void RecordPlotData ()
 
Getters
std::shared_ptr< const WorldIDFGetWorldIDFPtr () const
 
const WorldIDFGetWorldIDFObject () const
 
const MapTypeGetSystemMap () const
 
const MapTypeGetSystemExplorationMap () const
 
const MapTypeGetSystemExploredIDFMap () const
 
MapTypeGetSystemExploredIDFMapMutable ()
 
const MapTypeGetWorldMap () const
 Get the world map.
 
MapTypeGetWorldMapMutable ()
 Get the world map (mutable)
 
MapTypeGetRobotMapMutable (size_t const id)
 
auto GetNumRobots () const
 
auto GetNumFeatures () const
 
double GetExplorationRatio () const
 
double GetWeightedExplorationRatio () const
 Get the weighted (by IDF) exploration ratio.
 
PointVector GetRelativePositonsNeighbors (size_t const robot_id)
 
std::vector< int > GetNeighborIDs (size_t const robot_id) const
 
PointVector GetRobotPositions (bool force_no_noise=false)
 Get the global positions of all robots.
 
Point2 GetRobotPosition (int const robot_id, bool force_no_noise=false) const
 
const MapTypeGetRobotLocalMap (size_t const id)
 
const MapTypeGetRobotMap (size_t const id) const
 
const MapTypeGetRobotExplorationMap (size_t const id)
 
const MapTypeGetRobotSystemMap (size_t const id)
 
const MapTypeGetRobotObstacleMap (size_t const id)
 
const MapTypeGetRobotSensorView (size_t const id) const
 
auto GetRobotsInCommunication (size_t const id) const
 
std::pair< MapType, MapTypeGetRobotCommunicationMaps (size_t const, size_t)
 
std::vector< MapTypeGetCommunicationMaps (size_t map_size)
 
auto GetObjectiveValue ()
 
auto GetRobotExplorationFeatures ()
 
auto GetRobotVoronoiFeatures ()
 
std::vector< double > GetLocalVoronoiFeatures (int const robot_id)
 
std::vector< std::vector< double > > GetLocalVoronoiFeatures ()
 
auto GetVoronoiCells ()
 
VoronoiGetVoronoi ()
 
auto GetVoronoiCell (int const robot_id)
 
double GetNormalizationFactor ()
 

Detailed Description

The CoverageSystem class is the main class for the coverage control library.

Definition at line 66 of file coverage_system.h.

Constructor & Destructor Documentation

◆ CoverageSystem() [1/7]

CoverageSystem ( )
delete

Delete the default constructor

◆ CoverageSystem() [2/7]

CoverageSystem ( Parameters const & params)
explicit

Create random Gaussian distributions for the world IDF and random start positions for the robots.

Parameters
paramsParameters for the coverage system

Definition at line 39 of file coverage_system.cpp.

◆ CoverageSystem() [3/7]

CoverageSystem ( Parameters const & params,
int const num_gaussians,
int const num_robots )

Create random Gaussian distributions for the world IDF and random start positions for the robots.

Parameters
paramsParameters for the coverage system
num_gaussiansNumber of gaussian distributions for the world IDF
num_robotsNumber of robots

Definition at line 43 of file coverage_system.cpp.

◆ CoverageSystem() [4/7]

CoverageSystem ( Parameters const & params,
int const num_gaussians,
int const num_polygons,
int const num_robots )

Definition at line 47 of file coverage_system.cpp.

◆ CoverageSystem() [5/7]

CoverageSystem ( Parameters const & params,
WorldIDF const & world_idf,
std::string const & pos_file_name )

Create with given world IDF and robot positions from file.

Parameters
paramsParameters for the coverage system
world_idfWorld IDF
pos_file_nameFile name for initial positions

Definition at line 113 of file coverage_system.cpp.

◆ CoverageSystem() [6/7]

CoverageSystem ( Parameters const & params,
WorldIDF const & world_idf,
std::vector< Point2 > const & robot_positions )

Constructor for given world IDF and robot positions as a vector.

Parameters
paramsParameters for the coverage system
world_idfWorld IDF
robot_positionsInitial positions of the robots

Definition at line 143 of file coverage_system.cpp.

◆ CoverageSystem() [7/7]

CoverageSystem ( Parameters const & params,
std::vector< BivariateNormalDistribution > const & dists,
std::vector< Point2 > const & robot_positions )

Constructor for given normal distributions and robot positions.

Parameters
paramsParameters for the coverage system
distsBivariate normal distributions for the world IDF
robot_positionsInitial positions of the robots

Definition at line 157 of file coverage_system.cpp.

Member Function Documentation

◆ AddNoise()

Point2 AddNoise ( Point2 const pt) const

Add noise to the given point and ensure within bounds.

Definition at line 339 of file coverage_system.cpp.

◆ CheckOscillation()

bool CheckOscillation ( size_t const robot_id) const
inline

Check if the robot is oscillating about its current position

Warning
This function is dependent on the size of the robot positions history

Definition at line 341 of file coverage_system.h.

◆ CheckRobotID()

void CheckRobotID ( size_t const id) const
inline

Definition at line 365 of file coverage_system.h.

◆ ClearExploredIDF()

void ClearExploredIDF ( )
inline

Definition at line 405 of file coverage_system.h.

◆ ClearRobotMaps()

void ClearRobotMaps ( )
inline

Definition at line 399 of file coverage_system.h.

◆ ComputeVoronoiCells()

void ComputeVoronoiCells ( )
inline

Definition at line 371 of file coverage_system.h.

◆ GetCommunicationMaps()

std::vector< MapType > GetCommunicationMaps ( size_t map_size)
inline

Definition at line 587 of file coverage_system.h.

◆ GetExplorationRatio()

double GetExplorationRatio ( ) const
inline

Definition at line 488 of file coverage_system.h.

◆ GetLocalVoronoiFeatures() [1/2]

std::vector< std::vector< double > > GetLocalVoronoiFeatures ( )
inline

Definition at line 626 of file coverage_system.h.

◆ GetLocalVoronoiFeatures() [2/2]

std::vector< double > GetLocalVoronoiFeatures ( int const robot_id)
Note
The centroid is computed with orgin of the map, i.e., the lower left corner of the map.
Uses neighboring robots' positions to compute the centroid.

Definition at line 648 of file coverage_system.cpp.

◆ GetNeighborIDs()

std::vector< int > GetNeighborIDs ( size_t const robot_id) const
inline

Definition at line 503 of file coverage_system.h.

◆ GetNormalizationFactor()

double GetNormalizationFactor ( )
inline

Definition at line 640 of file coverage_system.h.

◆ GetNumFeatures()

auto GetNumFeatures ( ) const
inline

Definition at line 486 of file coverage_system.h.

◆ GetNumRobots()

auto GetNumRobots ( ) const
inline

Definition at line 485 of file coverage_system.h.

◆ GetObjectiveValue()

auto GetObjectiveValue ( )
inline

Definition at line 598 of file coverage_system.h.

◆ GetRelativePositonsNeighbors()

PointVector GetRelativePositonsNeighbors ( size_t const robot_id)

Definition at line 625 of file coverage_system.cpp.

◆ GetRobotCommunicationMaps()

std::pair< MapType, MapType > GetRobotCommunicationMaps ( size_t const id,
size_t map_size )

Definition at line 177 of file coverage_system.cpp.

◆ GetRobotExplorationFeatures()

auto GetRobotExplorationFeatures ( )
inline

Definition at line 603 of file coverage_system.h.

◆ GetRobotExplorationMap()

const MapType & GetRobotExplorationMap ( size_t const id)
inline

Definition at line 547 of file coverage_system.h.

◆ GetRobotLocalMap()

const MapType & GetRobotLocalMap ( size_t const id)
inline

Definition at line 537 of file coverage_system.h.

◆ GetRobotMap()

const MapType & GetRobotMap ( size_t const id) const
inline

Definition at line 542 of file coverage_system.h.

◆ GetRobotMapMutable()

MapType & GetRobotMapMutable ( size_t const id)
inline

Definition at line 480 of file coverage_system.h.

◆ GetRobotObstacleMap()

const MapType & GetRobotObstacleMap ( size_t const id)
inline

Definition at line 556 of file coverage_system.h.

◆ GetRobotPosition()

Point2 GetRobotPosition ( int const robot_id,
bool force_no_noise = false ) const
inline

Definition at line 526 of file coverage_system.h.

◆ GetRobotPositions()

PointVector GetRobotPositions ( bool force_no_noise = false)
inline

Get the global positions of all robots.

Can add noise to the positions based on the parameters

Parameters
force_no_noiseIf true, returns the positions without noise
Returns
Vector of global positions of all robots

Definition at line 514 of file coverage_system.h.

◆ GetRobotSensorView()

const MapType & GetRobotSensorView ( size_t const id) const
inline

Definition at line 561 of file coverage_system.h.

◆ GetRobotsInCommunication()

auto GetRobotsInCommunication ( size_t const id) const
inline

Definition at line 566 of file coverage_system.h.

◆ GetRobotSystemMap()

const MapType & GetRobotSystemMap ( size_t const id)
inline

Definition at line 552 of file coverage_system.h.

◆ GetRobotVoronoiFeatures()

auto GetRobotVoronoiFeatures ( )
inline

Definition at line 612 of file coverage_system.h.

◆ GetSystemExplorationMap()

const MapType & GetSystemExplorationMap ( ) const
inline

Definition at line 472 of file coverage_system.h.

◆ GetSystemExploredIDFMap()

const MapType & GetSystemExploredIDFMap ( ) const
inline

Definition at line 473 of file coverage_system.h.

◆ GetSystemExploredIDFMapMutable()

MapType & GetSystemExploredIDFMapMutable ( )
inline

Definition at line 474 of file coverage_system.h.

◆ GetSystemMap()

const MapType & GetSystemMap ( ) const
inline

Definition at line 471 of file coverage_system.h.

◆ GetVoronoi()

Voronoi & GetVoronoi ( )
inline

Definition at line 636 of file coverage_system.h.

◆ GetVoronoiCell()

auto GetVoronoiCell ( int const robot_id)
inline

Definition at line 638 of file coverage_system.h.

◆ GetVoronoiCells()

auto GetVoronoiCells ( )
inline

Definition at line 635 of file coverage_system.h.

◆ GetWeightedExplorationRatio()

double GetWeightedExplorationRatio ( ) const
inline

Get the weighted (by IDF) exploration ratio.

Definition at line 496 of file coverage_system.h.

◆ GetWorldIDFObject()

const WorldIDF & GetWorldIDFObject ( ) const
inline

Definition at line 470 of file coverage_system.h.

◆ GetWorldIDFPtr()

std::shared_ptr< const WorldIDF > GetWorldIDFPtr ( ) const
inline

Definition at line 467 of file coverage_system.h.

◆ GetWorldMap()

const MapType & GetWorldMap ( ) const
inline

Get the world map.

Definition at line 476 of file coverage_system.h.

◆ GetWorldMapMutable()

MapType & GetWorldMapMutable ( )
inline

Get the world map (mutable)

Definition at line 478 of file coverage_system.h.

◆ PlotFrontiers()

void PlotFrontiers ( std::string const & dir_name,
int const & step,
PointVector const & frontiers ) const

Definition at line 549 of file coverage_system.cpp.

◆ PlotInitMap() [1/2]

void PlotInitMap ( std::string const & dir_name,
std::string const & map_name ) const

Definition at line 519 of file coverage_system.cpp.

◆ PlotInitMap() [2/2]

void PlotInitMap ( std::string const & filename) const
inline

Definition at line 437 of file coverage_system.h.

◆ PlotMapVoronoi() [1/2]

void PlotMapVoronoi ( std::string const & dir_name,
int const & step )

Definition at line 528 of file coverage_system.cpp.

◆ PlotMapVoronoi() [2/2]

void PlotMapVoronoi ( std::string const & dir_name,
int const & step,
Voronoi const & voronoi,
PointVector const & goals ) const

Definition at line 539 of file coverage_system.cpp.

◆ PlotRobotCommunicationMaps()

void PlotRobotCommunicationMaps ( std::string const & dir_name,
int const & robot_id,
int const & step,
size_t const & map_size )

Definition at line 608 of file coverage_system.cpp.

◆ PlotRobotExplorationMap()

void PlotRobotExplorationMap ( std::string const & dir_name,
int const & robot_id,
int const & step )

Definition at line 581 of file coverage_system.cpp.

◆ PlotRobotLocalMap()

void PlotRobotLocalMap ( std::string const & dir_name,
int const & robot_id,
int const & step )

Definition at line 572 of file coverage_system.cpp.

◆ PlotRobotObstacleMap()

void PlotRobotObstacleMap ( std::string const & dir_name,
int const & robot_id,
int const & step )

Definition at line 598 of file coverage_system.cpp.

◆ PlotRobotSensorView()

void PlotRobotSensorView ( std::string const & dir_name,
int const & robot_id,
int const & step )

Definition at line 590 of file coverage_system.cpp.

◆ PlotRobotSystemMap()

void PlotRobotSystemMap ( std::string const & dir_name,
int const & robot_id,
int const & step )

Definition at line 559 of file coverage_system.cpp.

◆ PlotSystemMap() [1/3]

void PlotSystemMap ( std::string const & filename) const

Definition at line 478 of file coverage_system.cpp.

◆ PlotSystemMap() [2/3]

void PlotSystemMap ( std::string const & dir_name,
int const & step,
std::vector< int > const & robot_status ) const

Definition at line 489 of file coverage_system.cpp.

◆ PlotSystemMap() [3/3]

void PlotSystemMap ( std::string const & dir_name,
int const & step ) const
inline

Definition at line 425 of file coverage_system.h.

◆ PlotWorldMap()

void PlotWorldMap ( std::string const & dir_name,
std::string const & map_name ) const

Definition at line 510 of file coverage_system.cpp.

◆ PlotWorldMapRobots()

void PlotWorldMapRobots ( std::string const & dir_name,
std::string const & map_name ) const

Definition at line 499 of file coverage_system.cpp.

◆ RecordPlotData() [1/4]

void RecordPlotData ( )
inline

Definition at line 458 of file coverage_system.h.

◆ RecordPlotData() [2/4]

void RecordPlotData ( std::string const & map_name)
inline

Definition at line 454 of file coverage_system.h.

◆ RecordPlotData() [3/4]

void RecordPlotData ( std::vector< int > const & robot_status,
std::string const & map_name )

Definition at line 451 of file coverage_system.cpp.

◆ RecordPlotData() [4/4]

void RecordPlotData ( std::vector< int > const & robot_status)
inline

Definition at line 451 of file coverage_system.h.

◆ RenderRecordedMap()

void RenderRecordedMap ( std::string const & dir_name,
std::string const & video_name ) const

Definition at line 405 of file coverage_system.cpp.

◆ SetGlobalRobotPosition()

void SetGlobalRobotPosition ( size_t const robot_id,
Point2 const & global_pos )
inline

Set the global position of robot_id.

Definition at line 230 of file coverage_system.h.

◆ SetGlobalRobotPositions()

void SetGlobalRobotPositions ( PointVector const & global_positions)
inline

Set the global positions of all robots.

Definition at line 236 of file coverage_system.h.

◆ SetLocalRobotPosition()

void SetLocalRobotPosition ( size_t const robot_id,
Point2 const & relative_pos )
inline

Set the position of robot_id with respect to its current position.

Definition at line 223 of file coverage_system.h.

◆ SetLocalRobotPositions()

void SetLocalRobotPositions ( std::vector< Point2 > const & relative_pos)
inline

Set the positions of all robots with respect to their current positions

Note
Same as SetRobotPositions

Definition at line 218 of file coverage_system.h.

◆ SetRobotPositions()

void SetRobotPositions ( std::vector< Point2 > const & positions)
inline

Set the positions of all robots with respect to their current positions

Note
Same as SetLocalRobotPositions

Definition at line 249 of file coverage_system.h.

◆ SetWorldIDF()

void SetWorldIDF ( WorldIDF const & world_idf)
inline

Set the world IDF and recompute the world map.

Definition at line 261 of file coverage_system.h.

◆ StepAction()

bool StepAction ( size_t const robot_id,
Point2 const action )
inlinenodiscard

Execute given action for robot_id.

Warning
If the function returns 1 (control is incorrect), the system state is not updated
Parameters
robot_idID of the robot
actionAction for the robot
Returns
0 if successful, 1 if control is incorrect

Definition at line 303 of file coverage_system.h.

◆ StepActions()

bool StepActions ( PointVector const & actions)
inlinenodiscard

Execute given actions for all robots.

Warning
If the function returns 1 (control is incorrect), the system state is not updated
Parameters
actionsVector of actions for all robots
Returns
0 if successful, 1 if control is incorrect

Definition at line 279 of file coverage_system.h.

◆ StepControl()

bool StepControl ( size_t robot_id,
Point2 const & direction,
double const speed )
inlinenodiscard

Execute velocity control for robot_id.

Warning
If the function returns 1 (control is incorrect), the system state is not updated
Parameters
robot_idID of the robot
directionVelocity direction
speedVelocity magnitude
Returns
0 if successful, 1 if control is incorrect

Definition at line 325 of file coverage_system.h.

◆ StepRobotsToGoals()

bool StepRobotsToGoals ( PointVector const & goals,
PointVector & actions )

Step all robots towards given goals

Parameters
goalsVector of goals for the robots
actionsVector of actions for the robots
Returns
True if any robot is still moving

Definition at line 313 of file coverage_system.cpp.

◆ StepRobotToGoal()

bool StepRobotToGoal ( int const robot_id,
Point2 const & goal,
double const speed_factor = 1 )

Step a robot towards a given goal

Parameters
robot_idID of the robot
goalGoal for the robot
speed_factorSpeed factor for the robots
Returns
True if any robot is still moving

Definition at line 293 of file coverage_system.cpp.

◆ WriteEnvironment()

int WriteEnvironment ( std::string const & pos_filename,
std::string const & env_filename ) const

Definition at line 398 of file coverage_system.cpp.

◆ WriteRobotPositions() [1/2]

int WriteRobotPositions ( std::string const & file_name) const

Definition at line 368 of file coverage_system.cpp.

◆ WriteRobotPositions() [2/2]

int WriteRobotPositions ( std::string const & file_name,
PointVector const & positions ) const

Definition at line 383 of file coverage_system.cpp.