spike.scenario.components

Software component registration management

Classes

ScenarioComponents()

Class managing all registered software components and their update along time

class spike.scenario.components.ScenarioComponents

Class managing all registered software components and their update along time

__init__()

Constructor

reset()

reset method

configure(model)

Configure components from robot ground truth

Parameters:

model (ScenarioModel) – robot static description

register(component, port1, port2)

Register a software component associated with the robot

Parameters:
  • component (object (Button, ColorSensor,...)) – the software component initiated

  • port1 (string) – first port to check

  • port2 (string) – second port to check

Raises:

ValueError – unknown component type

update_from_data(time, data)

Update component from synthetic data

Parameters:
  • time (float) – current time

  • data (ScenarioData) – data to use to update components states

update_from_mecanics(time, dynamics)

Update component from robot dynamic data

Parameters:
  • time (float) – current time

  • dynamics (ScenarioDynamics) – robot dynamic state

__register_motor(component, port1, port2)

Check if motor software component can be allocated Atomic operation

Parameters:
  • component (Motor) – the software component initiated

  • port1 (string) – first port to check

  • port2 (string) – second port to check

Raises:

ValueError – Missing port or too many ports provided or unexisting port or port does not host a Motor or Motor already created on port

__register_motorpair(component, port1, port2=None)

Check if motorpair software component can be allocated Atomic operation

Parameters:
  • component (MotorPair) – the software component initiated

  • port1 (string) – first port to check

  • port2 (string) – second port to check

Raises:

ValueError – Single motors not created on port or motorpair already created

__register_colorsensor(component, port1, port2)

Check if color sensor software component can be allocated Atomic operation

Parameters:
  • component (ColorSensor) – the software component initiated

  • port1 (string) – first port to check

  • port2 (string) – second port to check

Raises:

ValueError – Missing port or too many ports provided or unexisting port or port does not host a ColorSensor or ColorSensor already created on port

__register_forcesensor(component, port1, port2)

Check if force sensor software component can be allocated Atomic operation

Parameters:
  • component (ForceSensor) – the software component initiated

  • port1 (string) – first port to check

  • port2 (string) – second port to check

Raises:

ValueError – Missing port or too many ports provided or unexisting port or port does not host a ForceSensor or ForceSensor already created on port

__register_distancesensor(component, port1, port2)

Check if distance sensor software component can be allocated Atomic operation

Parameters:
  • component (DistanceSensor) – the software component initiated

  • port1 (string) – first port to check

  • port2 (string) – second port to check

Raises:

ValueError – Missing port or too many ports provided or unexisting port or port does not host a DistanceSensor or DistanceSensor already created on port

__register_button(component, port1, port2)

Check if button software component can be allocated Atomic operation

Parameters:
  • component (Button) – the software component initiated

  • port1 (string) – first port to check

  • port2 (string) – second port to check

Raises:

ValueError – Missing side or too many sides provided or unknown side or Button already created on side

__register_lightmatrix(component, port1, port2)

Check if light matrix software component can be allocated LightMatrix is part of the hub and not connected to a hub port Atomic operation

Parameters:
  • component (LightMatrix) – the software component initiated

  • port1 (string) – first port to check

  • port2 (string) – second port to check

Raises:

ValueError – port provided or LightMatrix already created

__register_motion_sensor(component, port1, port2)

Check if motion sensor software component can be allocated MotionSensor is part of the hub and not connected to a hub port Atomic operation

Parameters:
  • component (MotionSensor) – the software component initiated

  • port1 (string) – first port to check

  • port2 (string) – second port to check

Raises:

ValueError – port provided or MotionSensor already created

__register_speaker(component, port1, port2=None)

Check if speaker software component can be allocated Speaker is part of the hub and not connected to a hub port Atomic operation

Parameters:
  • component (Speaker) – the software component initiated

  • port1 (string) – first port to check

  • port2 (string) – second port to check

Raises:

ValueError – port provided or Speaker already created

__register_statuslight(component, port1, port2=None)

Check if status light software component can be allocated StatusLight is part of the hub and not connected to a hub port Atomic operation

Parameters:
  • component (StatusLight) – the software component initiated

  • port1 (string) – first port to check

  • port2 (string) – second port to check

Raises:

ValueError – port provided or StatusLight already created

__register_timer(port1, port2=None)

Check if timer software component can be allocated Timer can always be created and is not associated to a hub port Atomic operation

Parameters:
  • component (MotionSensor) – the software component initiated

  • port1 (string) – first port to check

  • port2 (string) – second port to check

Raises:

ValueError – port provided