smarts.core.sensors.parallel_sensor_resolver module

class smarts.core.sensors.parallel_sensor_resolver.ParallelSensorResolver(process_count_override: int | None = None)[source]

This implementation of the sensor resolver completes observations in parallel.

generate_workers(count: int, workers_list: List[SensorsWorker], worker_kwargs: WorkerKwargs)[source]

Generate the given number of workers requested.

get_workers(count: int, sim_local_constants: SimulationLocalConstants, **kwargs) List['SensorsWorker'][source]

Get the give number of workers.

observe(sim_frame: SimulationFrame, sim_local_constants: SimulationLocalConstants, agent_ids: Set[str], renderer: RendererBase, bullet_client: bc.BulletClient) Tuple[Dict[str, Observation], Dict[str, bool], Dict[str, Dict[str, Sensor]]][source]

Runs observations in parallel where possible. :param sim_frame: The current state from the simulation. :type sim_frame: SimulationFrame :param sim_local_constants: The values that should stay the same for a simulation over a reset. :type sim_local_constants: SimulationLocalConstants :param agent_ids: The agent ids to process. :type agent_ids: {str, …} :param renderer: The renderer (if any) that should be used. :type renderer: Optional[Renderer] :param bullet_client: The physics client.

property process_count_override: int | None

The number of processes this implementation should run.

Returns:

Number of processes.

Return type:

int

step(sim_frame: SimulationFrame, sensor_states: Iterable[SensorState])[source]

Step the sensor state.

stop_all_workers()[source]

Stop all current workers and clear reference to them.

class smarts.core.sensors.parallel_sensor_resolver.ProcessWorker(serialize_results=False)[source]

A utility class that defines a persistent worker which will continue to operate in the background.

class Request(id: Any, data: WorkerKwargs)[source]

A request to made to the process worker

data: WorkerKwargs
id: Any
class WorkerDone[source]

The done signal for a worker.

property connection

The underlying connection to send data to the worker.

result(timeout=None)[source]

The most recent result from the worker.

run()[source]

Start the worker seeded with the given data.

property running: bool

If this current worker is still running.

send(request: Request)[source]

Sends a request to the worker.

stop()[source]

Sends a stop signal to the worker.

class smarts.core.sensors.parallel_sensor_resolver.SensorsWorker[source]

A worker for sensors.

static local(state: Dict)[source]

The work method on the local thread.

class smarts.core.sensors.parallel_sensor_resolver.SensorsWorkerRequestId(value)[source]

Options for update requests to a sensor worker.

SIMULATION_FRAME = 1
SIMULATION_LOCAL_CONSTANTS = 2
class smarts.core.sensors.parallel_sensor_resolver.WorkerKwargs(**kwargs)[source]

Used to serialize arguments for a worker upfront.

deserialize()[source]

Deserialize all objects in the arguments and return a dictionary copy.

merged(o_worker_kwargs: WorkerKwargs) WorkerKwargs[source]

Merge two worker arguments and return a new copy.