Experimental run#
Holds the configuration to record sensing during an experimental run
- Type:
The name of the dataset group
- Type:
The sensor to record, if none, it will the record the behavior sensing state
Holds the configuration to record neighbors during an experimental run
- Type:
Whether to record neighbors or not
- Type:
The number of neighbors to record. If more, it will record the nearest number record. If fewer, it will pads with zeros.
- Type:
Whether to use a frame relative to the agent or the absolute frame.
Holds which data to record during an experimental run
Sets all to record or not record.
- Returns:
The configuration.
Add a sensor to be recorded
- Parameters:
name – The name of the group
sensor – The sensor to record
agent_indices – The agent indices whose sensing to record
Sets all to record or not record.
- Parameters:
value – The desired value
- Type:
Whether to record the agents actuated control commands
- Type:
Whether to record the agents control commands
- Type:
Whether to record collisions
- Type:
Whether to record the time since when agents are stuck
- Type:
Whether to record efficacy (i.e., fraction of actual velocity vs optimal velocity)
-
Whether and how to record neighbors
- Type:
Whether to record the agents poses
- Type:
Whether to record safety violations
-
The sensors to record
- Type:
Whether to record the agents targets
- Type:
Whether to record data from task events
- Type:
Whether to record the simulation time
- Type:
Whether to record the agents twists
- Type:
Whether to use uid as keys for sensing and task events. Else it will use the agent index.
- Type:
Whether to record the initial world state (as YAML)
Simulates a world and collects data.
Adds a group record probe.
- Parameters:
key (Callable[[], sim.GroupRecordProbe]) – the key of the group to be created
probe – the probe factory like a GroupRecordProbe class.
Adds a probe
- Parameters:
probe – The probe
Adds a record.
- Parameters:
key (str) – the record key
data (
numpy.typing.ArrayLike
| None) – Copies shape, data and dtype from this numpy array (if specified)dtype (
numpy.typing.DTypeLike
| None.) – The type of data to store (if specified and ifdata
is None)item_shape (List[int]) – Set the shape of all axis except the first (only if
data
is None ). Set to an empty list to instantiate a flat dataset.
Adds a record probe.
- Parameters:
key (Callable[[navground.sim.Dataset], sim.RecordProbe]) – the key of the record to be created
probe – the probe factory like a RecordProbe class.
Encode a target to be stored by a run.
- Parameters:
target – The target
- Returns:
The data
The recorded collision events between pairs of entities as as a Dataset of shape
(number of collisions, 3)
and dtypenp.uint32
:[[time_step, uid_0, uid_1], ...]
Only collision among the same pair separated by at least
minimal_interval
are returned. The array is empty if collisions have not been recorded in the run.
Gets recorded collisions at a given step.
- Parameters:
step – The step. Negative steps are interpreted as relative to the last registered step, i.e., -1 is the last step.
- Returns:
The set of colliding entity pairs.
Gets the record associated to a given key.
- Parameters:
key – The key
- Returns:
The record or null if none is found.
Gets the names of records.
- Parameters:
group – An optional group. If specified, the looks for record associated to keys
<group>/...
.- Returns:
The record names (relative to the group if specified).
Gets the records.
- Parameters:
group – If specified, limits to records in a given group.
- Returns:
The records
Gets the recorded sensing.
- Parameters:
id – The agent uid or index (if
RecordConfig.use_agent_uid_as_key
is not set)- Returns:
The dictionary {key: sensing data}
The number of steps to the next recorded collision for each agent as as a Dataset of shape
(number of steps, number of agents)
and dtypenp.uint32
:[[agent_0_steps, agent_1_steps, ...], ...]
Overloaded function.
get_task_events(agent: navground.sim.NativeAgent) -> numpy.ndarray
The recorded events logged by the task of an agent as a numpy array of shape
(number events, size of event log)
and dtypefloat
:[[data_0, ...], ...]
The array is empty if the agent’s task has not been recorded in the run.
- Parameters:
agent – The agent
- Returns:
The events logged by the agent task
get_task_events(uid: int) -> object
The recorded events logged by the task of an agent as a numpy array of shape
(number events, size of event log)
and dtypefloat
:[[data_0, ...], ...]
The array is empty if the agent’s task has not been recorded in the run.
- Parameters:
uid – The uid of the agent
- Returns:
The events logged by the agent task
Try to advance the world to a given recorded step.
Depending if the data has been recorded, it will update:
poses
twists
cmds
targets
sensing
time
collisions
- Parameters:
step – The step. Negative steps are interpreted as relative to the last registered step, i.e., -1 is the last step.
ignore_collisions – Whether to skip setting collisions
ignore_twists – Whether to skip setting twists
ignore_cmds – Whether to skip setting [last] commands
ignore_targets – Whether to skip setting targets
ignore_sensing – Whether to skip setting sensing
- Returns:
True if the operation was possible and false otherwise.
Associate an index to a given agent.
Data related to agents is stored in this order. For example, poses at a given time step are stored as
[[x_0, y_0, z_0], [x_1, y_1, z_1], ...]
where the pose of agent a is at the index returned by this function.
- Parameters:
agent – The agent
- Returns:
The index of data related to this agent.
Resets the run.
Runs a simulation and automatically record data step by step
You don’t need to call
start()
,update()
,stop()
besiderun()
asrun()
manages all the simulation and recording.You don’t need to call
run()
when running anExperiment
(seeExperiment.run()
instead) but only if you are want to perform a run outside of anExperiment
.
Signals that has simulation has started.
Note that this won’t neither execute the simulation nor record data. It will just record the a time stamp and change the state to running.
You don’t need to call
start()
,update()
,stop()
, orrun()
when running anExperiment
(seeExperiment.run()
instead) but only if you are want to perform a run outside of anExperiment
.Either call
start()
->update()
periodically after manually advancing the simulation ->stop()
, orrun()
once, which does perform all the steps automatically.
Signals that has simulation has stopped.
Call this after
start()
to stop the recording of a simulation.You don’t need to call
start()
,update()
,stop()
, orrun()
when running anExperiment
(seeExperiment.run()
instead) but only if you are want to perform a run outside of anExperiment
.
Decode a target from data stored by a run.
- Parameters:
data – The data
- Returns:
The target
Signals that data needs to be updated
Note that this won’t execute the simulation. Use it only between
start()
andstop()
calls to collect data about the current world state.Note that after the maximal number of steps has been recorded, it won’t record any more data.
- Type:
The recorded actuated commands of the agents as a numpy array of shape
(simulation steps, number of agents, 3)
and dtypefloat
:[[[vx_0, vy_0, omega_0], [vx_1, vy_1, omega_1], ...], ...]
The array is empty if actuated commands have not been recorded in the run.
-
The rectangle that contains the world during the whole run.
- Type:
The recorded collisions between pairs of entities as as a numpy array of shape
(number of collisions, 3)
and dtypenp.uint32
:[[time_step, uid_0, uid_1], ...]
The array is empty if collisions have not been recorded in the run.
- Type:
The recorded commands of the agents as a numpy array of shape
(simulation steps, number of agents, 3)
and dtypefloat
:[[[vx_0, vy_0, omega_0], [vx_1, vy_1, omega_1], ...], ...]
The array is empty if commands have not been recorded in the run.
- Type:
The time since agents are deadlocked as a numpy array of shape
(number of agents, )
and dtypefloat
:[time_0, time_1, ...]
If
time_i
is negative, the i-th agent is not stuck at the end of the recording. Else, it has been stuck sincetime_i
.The array is empty if deadlocks have not been recorded in the run.
- Type:
The real-time duration of the run.
- Type:
The recorded agents’ efficacy as a numpy array of shape
(simulation steps, number of agents)
and dtypefloat
:[[efficacy_0, efficacy_1, ...], ...]
The array is empty if efficacy has not been recorded in the run.
- Type:
The last recorded simulation time
- Type:
Whether the run is finished.
- Type:
The number of steps execute
- Type:
The recorded agents’ neighbors as a numpy array of shape
(simulation steps, number of agents, number of neighbors, 5)
and dtypefloat
:[[[radius, x, y, vx, vy]], ...]
The array is empty if efficacy has not been recorded in the run.
- Type:
The recorded poses of the agents as a numpy array of shape
(simulation steps, number of agents, 3)
and dtypefloat
:[[[x_0, y_0, theta_0], [x_1, y_1, theta_1], ...], ...]
The array is empty if poses have not been recorded in the run.
-
The record config on which data to record
-
The names of records.
- Parameters:
group – an optional group. if specified, the looks for record associated to keys
<group>/...
.
- Type:
The number of recorded steps.
- Type:
The records.
- Parameters:
group – if specified, limits to records in a given group.
- Type:
The recorded amounts of safety violation as a numpy array of shape
(simulation steps, number of agents)
and dtypefloat
:[[violation_0, violation_1, ...], ...]
where a value of 0 represents no violations.
The array is empty if safety violations have not been recorded in the run.
- Type:
The seed used to initialize the simulation.
- Type:
The recorded sensing.
- Type:
The recorded targets of the agents as a numpy array of shape
(simulation steps, number of agents, 14)
and dtypefloat
:[[[position?, position[0], position[1], orientation?, orientation, speed?, speed, direction?, direction[0], direction[1], angular_speed?, angular_speed, position_tol, orientation_tol], ...] ...]
where <x>? is 1.0 if the field is defined with value <x>, else <x>? is 0.0 and value <x> is set to zero.
The array is empty if targets have not been recorded in the run.
-
The recorded events logged by the tasks all agents as a dictionart of numpy array of shape
(number events, size of event log)
and dtypefloat
:{<agent_uid>: [[data_0, ...], ...]}
The array are empty if the agent’s task has not been recorded in the run.
- Returns:
The events logged by the tasks all agents
- Type:
Whether to terminate when all agents are idle or stuck.
- Type:
The time step used for simulation.
- Type:
The recorded simulation times as a numpy array of shape
(simulation steps)
and dtypefloat
:[t_0, t_1, ...]
The array is empty if times have not been recorded in the run.
- Type:
The recorded twists of the agents as a numpy array of shape
(simulation steps, number of agents, 3)
and dtypefloat
:[[[vx_0, vy_0, omega_0], [vx_1, vy_1, omega_1], ...], ...]
The array is empty if twist have not been recorded in the run.
-
Returns the simulated world.