| Title: | Analyzing RoboCupRescue Simulation Data |
|---|---|
| Description: | Tools for analyzing data from RoboCupRescue Simulation (RRS) <https://rescuesim.robocup.org>, a disaster rescue simulation platform. Supports reading virtual city map and disaster scenario files into analyzable data structures and provides functions for their visualization. |
| Authors: | Keisuke Ando [aut, cre] (ORCID: <https://orcid.org/0009-0002-4085-2067>) |
| Maintainer: | Keisuke Ando <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 1.1.0 |
| Built: | 2026-06-03 08:29:01 UTC |
| Source: | https://github.com/NONONOexe/rrstools |
download_scenarios downloads scenario archives for the RoboCupRescue
Simulation from the RCRS Scenario Hub. It allows filtering by scenario name.
download_scenarios(names, download_dir, extract = FALSE)download_scenarios(names, download_dir, extract = FALSE)
names |
A character vector of scenario names to download (e.g., "kobe"). |
download_dir |
A string specifying the directory where files will be downloaded. If the directory does not exist, it will be created. |
extract |
A logical value. If |
Invisibly returns a character vector of the local paths corresponding to the results of the process. If extraction is successful, the path to the newly created data directory is returned; otherwise, the path to the downloaded archive file is returned. Returns an empty character vector if no files were downloaded.
# Download the kobe scenario download_scenarios(names = "kobe", download_dir = tempdir()) # Download and extract the kobe scenario download_scenarios(names = "kobe", download_dir = tempdir(), extract = TRUE)# Download the kobe scenario download_scenarios(names = "kobe", download_dir = tempdir()) # Download and extract the kobe scenario download_scenarios(names = "kobe", download_dir = tempdir(), extract = TRUE)
These functions provide methods to extract specific geographical elements
from an rrs_map object. You can retrieve all elements of a certain type
or filter them by their IDs.
get_nodes(map, ids = character()) get_edges(map, ids = character()) get_roads(map, ids = character()) get_buildings(map, ids = character()) get_entrances(map, ids = character()) get_passage(map, ids = character())get_nodes(map, ids = character()) get_edges(map, ids = character()) get_roads(map, ids = character()) get_buildings(map, ids = character()) get_entrances(map, ids = character()) get_passage(map, ids = character())
map |
An object of class |
ids |
A character vector of element IDs to filter by. If empty (default), all elements of the specified type are returned. |
An sf data frame containing the requested map elements.
gml <- system.file("extdata", "map-test.gml", package = "rrstools") map <- read_rrs_map(gml) # Get all nodes get_nodes(map) # Get a specific node by ID get_nodes(map, c("0", "2"))gml <- system.file("extdata", "map-test.gml", package = "rrstools") map <- read_rrs_map(gml) # Get all nodes get_nodes(map) # Get a specific node by ID get_nodes(map, c("0", "2"))
get_hub_url returns the current URL of the RCRS Scenario Hub.
get_hub_url()get_hub_url()
A string of the current URL of the RCRS Scenario Hub.
get_hub_url()get_hub_url()
get_scenarios retrieves the list of available scenarios from the RCRS
Scenario Hub and returns it as a data frame. The result is cached within
the session to avoid repeated downloads. Use refresh = TRUE to force
re-fetching from the Hub.
get_scenarios(refresh = FALSE)get_scenarios(refresh = FALSE)
refresh |
A logical value. If |
A data frame with the following columns:
Scenario name
URL to download the map scenario archive
Map name
Name of the city that map is modeled after
Name of the country where the city is located
Latitude of the map location. If the exact location is unknown, the center of the city is used.
Longitude of the map location. If the exact location is unknown, the center of the city is used.
URL of the thumbnail image of the map
# Get available scenarios get_scenarios() # Force re-fetch from the Hub get_scenarios(refresh = TRUE)# Get available scenarios get_scenarios() # Force re-fetch from the Hub get_scenarios(refresh = TRUE)
morph_road_network() converts map data from the RoboCupRescue Simulation
into a road network.
morph_road_network(map, mode = c("all", "roads_only", "roads_no_entrances"))morph_road_network(map, mode = c("all", "roads_only", "roads_no_entrances"))
map |
|
mode |
A character string specifying the mode of the road network:
When |
This road network consists of nodes and edges. Nodes are defined as the centroids of all areas and the center points the boundaries between areas. Edges connect nodes between an agent can travel.
A list containing the network components:
nodes: A sf object of nodes with point geometries.
edges: A sf object of edges with linestring geometries.
gml <- system.file("extdata", "map-test.gml", package = "rrstools") map <- read_rrs_map(gml) net <- morph_road_network(map) netgml <- system.file("extdata", "map-test.gml", package = "rrstools") map <- read_rrs_map(gml) net <- morph_road_network(map) net
plot visualizes a rrs_map object, displaying the geographical
features such as buildings and roads. If a rrs_scenario object is
provided, it also overlays the initial locations of rescue platoons,
civilians, and special buildings from the scenario.
It leverages the sf package's plotting capabilities to render
the map components.
## S3 method for class 'rrs_map' plot( x, scenario = NULL, building_colour = "#f0e7d8", building_border = "#121212", road_colour = "#dbdbdb", road_border = "#121212", background_colour = NA, ... )## S3 method for class 'rrs_map' plot( x, scenario = NULL, building_colour = "#f0e7d8", building_border = "#121212", road_colour = "#dbdbdb", road_border = "#121212", background_colour = NA, ... )
x |
An object class |
scenario |
An object of class |
building_colour |
The colour of the buildings. |
building_border |
The border colour of the buildings. |
road_colour |
The colour of the roads. |
road_border |
The border colour of the roads. |
background_colour |
The background colour of the plot. |
... |
Additional arguments passed to |
plot first plots the basic map layout, including buildings and roads.
Then, if a scenario is given, it plots the following entities:
Refuges: Plotted in green (#00ff00), with the capacity
displayed.
Fire Stations: Plotted in yellow (#ffff00).
Ambulance Centers: Plotted in white (#ffffff).
Police Offices: Plotted in blue (#0000ff).
Civilians: Plotted as green circles (#00ff00),
with the number indicating the count at that location.
Fire Brigades: Plotted as red circles (#ff0000),
with the number indicating the count at that location.
Ambulance Teams: Plotted as white circles (#ffffff),
with the number indicating the count at that location.
Police Forces: Plotted as blue circles (#0000ff),
with the number indicating the count at that location.
The positions of human entities (agents and civilians) are slightly offset from the center of their location to avoid overlap.
Invisibly returns NULL (called for side effects).
gml <- system.file("extdata", "map-test.gml", package = "rrstools") map <- read_rrs_map(gml) # Plot only the map plot(map) # Plot the map with a scenario xml <- system.file("extdata", "scenario-test.xml", package = "rrstools") scenario <- read_rrs_scenario(xml) plot(map, scenario)gml <- system.file("extdata", "map-test.gml", package = "rrstools") map <- read_rrs_map(gml) # Plot only the map plot(map) # Plot the map with a scenario xml <- system.file("extdata", "scenario-test.xml", package = "rrstools") scenario <- read_rrs_scenario(xml) plot(map, scenario)
A rrs_scenario object cannot be plotted by itself because it lacks the
necessary spatial context provided by a map. This function exists to
intercept calls to plot(scenario) and provide a helpful error message.
# Collect usage: # plot(map, scenario)# Collect usage: # plot(map, scenario)
x |
An object class |
... |
Not used. |
To visualize a scenario, you must plot it together with a rrs_map
object.
Does not return; always throws an error.
print prints a concise summary of a rrs_map object.
It displays the object type, the number of nodes, edges, and faces it
contains, its overall bounding box.
## S3 method for class 'rrs_map' print(x, ...)## S3 method for class 'rrs_map' print(x, ...)
x |
An object class |
... |
Not used. |
Invisibly returns x (called for side effects).
gml <- system.file("extdata", "map-test.gml", package = "rrstools") map <- read_rrs_map(gml) mapgml <- system.file("extdata", "map-test.gml", package = "rrstools") map <- read_rrs_map(gml) map
print prints a concise summary of a rrs_scenario object.
It displays the object type, the total number of entities, and a
table with the counts of entities for each type.
## S3 method for class 'rrs_scenario' print(x, ...)## S3 method for class 'rrs_scenario' print(x, ...)
x |
An object class |
... |
Not used. |
Invisibly returns x (called for side effects).
xml <- system.file("extdata", "scenario-test.xml", package = "rrstools") scenario <- read_rrs_scenario(xml) scenarioxml <- system.file("extdata", "scenario-test.xml", package = "rrstools") scenario <- read_rrs_scenario(xml) scenario
This function reads and processes map data for RoboCupRescue Simulation from a GML file. It extracts nodes, edges, buildings and roads.
read_rrs_map(gml, scale_data = FALSE)read_rrs_map(gml, scale_data = FALSE)
gml |
Path to the GML file. |
scale_data |
Logical. If |
A list of sf objects: nodes, edges, buildings, and roads.
gml <- system.file("extdata", "map-test.gml", package = "rrstools") map <- read_rrs_map(gml) mapgml <- system.file("extdata", "map-test.gml", package = "rrstools") map <- read_rrs_map(gml) map
read_rrs_scenario() reads and processes scenario data for
RoboCupRescue Simulation from a XML file.
read_rrs_scenario(xml)read_rrs_scenario(xml)
xml |
Path to the XML file containing the scenario data. |
A rrs_scenario object. This object is a data.frame, and contains
the following columns:
type: Character. The type of the entity
(e.g., "refuge", "civilian").
location: Character. The entity ID of the location where
the entity is placed.
attributes: List. A list containing other attributes of the
entity.
xml <- system.file("extdata", "scenario-test.xml", package = "rrstools") scenario <- read_rrs_scenario(xml) scenarioxml <- system.file("extdata", "scenario-test.xml", package = "rrstools") scenario <- read_rrs_scenario(xml) scenario
set_hub_url sets the URL of the RCRS Scenario Hub for the current session.
The cached scenario list is cleared when the URL is changed.
set_hub_url(url)set_hub_url(url)
url |
A string specifying the URL of the RCRS Scenario Hub. |
Invisibly returns the previous URL.
set_hub_url("https://example.com/scenarios.json")set_hub_url("https://example.com/scenarios.json")