spike.scenario.parts

Classes describing lego robot component parts https://www.ldraw.org/article/218.html and their dynamic data

Classes

ScenarioPart([copy])

Class gathering data on a robot part

ScenarioPartColorSensor(part)

Class color sensor dynamics part

ScenarioPartDistanceSensor(part)

Class distance sensor dynamics part

ScenarioPartForceSensor(part)

Class force sensor dynamics part

ScenarioPartHub(part)

Class hub dynamics part

ScenarioPartMotor(part)

Class defining motor dynamics part

ScenarioPartWheel(part, motor, spin)

Class defining wheel dynamics

class spike.scenario.parts.ScenarioPart(copy=None)

Class gathering data on a robot part

__init__(copy=None)

Constructor

Parameters:

copy (ScenarioPart) – part to copy if copy constructor, None (default) otherwise

property type

Part type getter

Returns:

part type

Return type:

string

property id

Part identifier getter

Returns:

part ldraw identifier

Return type:

string

property pose

Part 3d absolute pose getter

Returns:

part absolute pose

Return type:

Pose3d

property relative

Part 3d relative pose getter

Returns:

part 3d relative pose

Return type:

Pose3d

property port

Part port getter

Returns:

part port, None if the component is not connected

Return type:

string

property color

Part color getter

Returns:

part color

Return type:

string

export()

Export part as end-user dict

Returns:

part representation from the user perspective

Return type:

dictionary

derive_relative(center)

Compute part pose relative to the robot center pose

Parameters:

center (Pose3d) – robot center relative pose

derive_pose(center)

Compute part absolute pose from the robot center absolute pose

Parameters:

center (Pose3d) – robot center absolute pose

class spike.scenario.parts.ScenarioPartMotor(part)

Class defining motor dynamics part

static configure(filename, sheet)

Static method to load speed abaqus from file

Parameters:
  • filename (string) – workbook to read abaqus from

  • sheet (string) – workbook sheet to read abaqus from

__init__(part)

Motor constructor

:param part : part to set as motor :type part : ScenarioPart object

Raises:

ValueError – part is not a known motor

reset()

Part dynamic data reset function

property speed

Rotation speed getter

Returns:

motor rotation speed

Return type:

float (rads-1)

property degrees

degrees getter

Returns:

motor displacement degrees

Return type:

float (radians)

property wheel

Wheel getter

Returns:

motor associated wheel, None if motor is not connected to a wheel

Return type:

ScenarioPartWheel

property clockwise

Returns the direction of the displacement induced by clockwise rotation

Returns:

-1 if clockwise rotation means moving backwards, 1 otherwise

Return type:

integer

export()

Export motor as end-user dict

Returns:

dictionary representing the motor from the user perspective

Return type:

dictionary

command(command, direction='clockwise')

Derive motor rotation speed from command

Parameters:
  • command (integer [-100,100]) – motor command

  • direction (string (clockwise or counterclockwise)) – motor rotation direction

radius()

Access wheel radius if motor is connected to a wheel

Returns:

wheel radius (None if motor is not linked to a wheel)

Return type:

float

side()

Access wheel side if motor is connected to a wheel

Returns:

wheel side (None if motor is not linked to a wheel)

Return type:

str (left or right)

is_pairable(other)

Check if 2 motors are pairables

Parameters:

other (ScenarioPartMotor) – other motor to pair

Returns:

True if motors can be paired, False otherwise

Return type:

boolean

extrapolate(delta)

Extrapolate motor angular displacement from time difference

Parameters:

delta (float) – time period in seconds

class spike.scenario.parts.ScenarioPartWheel(part, motor, spin)

Class defining wheel dynamics

static configure(filename, sheet)

Static method to load speed abaqus from file

Parameters:
  • filename (string) – workbook to read abaqus from

  • sheet (string) – workbook sheet to read abaqus from

__init__(part, motor, spin)

Constructor

Parameters:
  • part (ScenarioPartMotor) – part to set as sheel

  • part – motor associated to the wheel

  • spin – 1 if the wheel rotates in the same direction as its motor (even number of gears), -1 otherwise (odd number of gears)

Raises:

ValueError – part is not a known wheel

property side

Wheel side getter

Returns:

wheel side on robot

Return type:

string (left, right)

property radius

Wheel radius getter

Returns:

wheel radius

Return type:

float (cm)

property speed

Wheel linear speed getter

Returns:

wheel linear

Return type:

float (cms-1)

set_side(other)

Set wheel side on model

Parameters:

other (ScenarioPartWheel) – other wheel to compare for left/right

export()

Export wheel as end-user dict

Returns:

dictionary representing the wheel from the user perspective

Return type:

dictionary

distance(wheel)

Compute distance between 2 wheels

Parameters:

wheel (ScenarioPartWheel) – other wheel to analyse

Returns:

distance between the 2 wheels

Return type:

float (cm)

class spike.scenario.parts.ScenarioPartColorSensor(part)

Class color sensor dynamics part

__init__(part)

Color sensor constructor

Parameters:

part (ScenarioPart) – part to set as motor

Raises:

ValueError – part is not a known color sensor

export()

Export wheel as end-user dict

Returns:

dictionary representing the wheel from the user perspective

Return type:

dictionary

read_color(mat)

Read color at sensor position on mat

Parameters:

mat (ScenarioGround) – mat model

class spike.scenario.parts.ScenarioPartHub(part)

Class hub dynamics part

__init__(part)

Hub constructor

Parameters:

part (ScenarioPart) – part to set as hub

Raises:

ValueError – part is not a known hub

class spike.scenario.parts.ScenarioPartForceSensor(part)

Class force sensor dynamics part

__init__(part)

Force sensor constructor

Parameters:

part (ScenarioPart) – part to set as force sensor

Raises:

ValueError – part is not a known force sensor

class spike.scenario.parts.ScenarioPartDistanceSensor(part)

Class distance sensor dynamics part

__init__(part)

Distance sensor constructor

Parameters:

part (ScenarioPart) – part to set as distance sensor

Raises:

ValueError – part is not a known distance sensor