swarmsim.agent.control.BinaryController#
Binary Controller class.
- class swarmsim.agent.control.BinaryController.BinaryController(a: tuple[Sequence[float] | ndarray, Sequence[float] | ndarray] | ndarray | Sequence[float], b: Sequence[float] | ndarray | None = None, agent=None, parent=None, sensor_id=0, sense_avg_time=1, **kwargs)[source]#
Controller that returns one of two constant control inputs based on a binary sensor state.
There are multiple ways to specify the control values to be output:
- If
aandbare both 1D arrays, then: ais the output when the sensor is in state 0,bis the output when the sensor is in state 1.
- If
- If only
ais specified, then it should either be a 1D array or a 2D array. The first half or first column is the output when the sensor is in state 0,
and the second half or second column is the output when the sensor is in state 1.
- If only
If
bis specified, then it should be the same length asa.- Parameters:
a (Sequence[float, ...] | Sequence[tuple[float, ...], ...] | np.ndarray)
b (Sequence[float, ...] | np.ndarray | None, optional)
agent (Agent, optional)
parent (Agent, optional)
sensor_id (int, default=0) – The index in
agent.sensorsto use for the sensor.sense_avg_time (int, default=1) – The number of timesteps to average over when calculating the sensor state. This is useful for averaging over the sensor state to smooth out noise, i.e., a low-pass filter.
Methods
get_actions(agent)An example of a "from scratch" controller that you can code with any information contained within the agent class
as_config_dict
draw
set_agent
set_parent
Classes
|
Controller that returns one of two constant control inputs based on a binary sensor state. |