spike.scenario.scenario

Simulation scenario management API

Classes

Scenario()

Singleton class managing the robot status

ScenarioThreadData()

Shared data for robot update thread

class spike.scenario.scenario.ScenarioThreadData

Shared data for robot update thread

__init__()

Constructor

reset()

Reset function

reinitialize()

Scenario reinitialization function Keeps registered software components but reinitialize dynamics

configure(scenario, robot, sheet=None, logger=None)

Configuration function

Parameters:
  • scenario (string) – scenario configuration file path

  • robot (string) – robot configuration file path

  • sheet (string) – name of the sheet to use for component data feeding

  • logger (string) – logging configuration file path

Raises:

ValueError – missing information, initial coordinates or workbook sheet or unknown data mode

register_component(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

is_started()

Check if the processing is started

Returns:

True if the processing is started, False otherwise

Return type:

boolean

step()

Step into time

command(component, name, args)

Add new command to process

Parameters:
  • component (object (Button, ColorSensor,...)) – the software component at the origin of the command

  • name (string) – command name

  • args (dictionary) – command parameters

Returns:

command to perform

Return type:

generator function

get_status()

Return current robot status

Returns:

the current robot status processed by the thread

Return type:

dictionary

get_components()

Return robot components

Returns:

the robot components

Return type:

list

set_shall_continue(value)

Shall continue setting function - Atomic function

Parameters:

value (boolean) – True if thread processing shall continue, false otherwise

shall_continue()

Shall continue accessor function - Atomic function

Returns:

True if thread processing shall continue, false otherwise

Return type:

boolean

run()

Thread data processing function

__check_configuration(conf, sheet)

Check input json configuration

Parameters:
  • conf (dictionary) – configuration file content

  • sheet (string) – workbook sheet to use for synthetic data

Raises:

ValueError – missing information, initial coordinates or workbook sheet or unknown data mode

class spike.scenario.scenario.Scenario

Singleton class managing the robot status

s_init()

Constructor for singleton / only called once

__init__()

Contructor for each instantiation / do nothing

configure(scenario, robot, sheet=None)

Loading configuration from file

Parameters:
  • scenario (string) – path of json file to read scenario data from

  • robot (string) – path of json file describing robot configuration

  • sheet (string) – sheet to read scenario data from

register(component, port1=None, port2=None)

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

start()

Robot starting function

step()

Step into time from a period set by configuation

command(component, name, args)

Process new robot command

Parameters:
  • component (object (Button, ColorSensor,...)) – the software component at the origin of the command

  • name (string) – command name

  • args (dictionary) – command parameters

Returns:

command to perform

Return type:

generator function

stop()

End scenario

reset()

Reset scenario — All components will be deregistered

status()

Return robot current status

Returns:

robot real status

Return type:

dictionary

components()

Return robot components list

Returns:

robot component lists

Return type:

list