Moving Symbols  v1.0
Like Moving MNIST, but way more flexible
Public Member Functions | Public Attributes | List of all members
moving_symbols.moving_symbols.Symbol Class Reference

Public Member Functions

def __init__ (self, id, label, image, image_path, scale_fn)
 Constructor. More...
 
def get_render_image_and_position (self, screen_size)
 Get the PyGame Surface and center coordinate of the scaled, rotated symbol. More...
 
def set_scale (self, step)
 Set the scale of the symbol to the scaling function at the given time step. More...
 
def get_state_message (self, step)
 Produce a message about the state of the symbol at the given time step. More...
 
def get_init_message (self)
 Produce a message about fixed properties of the symbol, i.e. image data. More...
 

Public Attributes

 id
 
 label
 
 image
 
 image_path
 
 pg_image
 
 body
 
 shape
 
 scale_fn
 
 scale
 
 angular_velocity
 

Constructor & Destructor Documentation

def moving_symbols.moving_symbols.Symbol.__init__ (   self,
  id,
  label,
  image,
  image_path,
  scale_fn 
)

Constructor.

Parameters
idA numerical ID for this symbol
labelThe class label of this symbol
imageThe base PIL image for this symbol
image_pathThe path to the (unprocessed) image file
scale_fnA function that returns the scale of the symbol at any given time t

Member Function Documentation

def moving_symbols.moving_symbols.Symbol.get_init_message (   self)

Produce a message about fixed properties of the symbol, i.e. image data.

Return a message containing information required to reconstruct the appearance and shape of the symbol. The returned meta information includes the symbol ID, the image as a HxWx4 np.uint8 array, the path to the source image, and the vertices of the symbol shape, in PyMunk coordinates, as a Vx2 np.float array.

Return values
messageA dict describing the symbol's initial state. Its key-value pairs are:
  • step: Current time step
  • type: 'symbol_init'
  • meta: dict with following key-value pairs:
    • symbol_id: The ID for this symbol
    • label: The class label of this symbol
    • image: An np.array of the full image (dimensions H x W x 4)
    • image_path: Path to the source image (uncropped)
    • vertices: The PyMunk coordinates defining the symbol's hitbox as a V x 2 np.float array
def moving_symbols.moving_symbols.Symbol.get_render_image_and_position (   self,
  screen_size 
)

Get the PyGame Surface and center coordinate of the scaled, rotated symbol.

Parameters
screen_size(width, height) of the PyGame screen
Return values
rotated_imagepygame.Surface of the scaled, rotated image
pg_image_posPyGame coordinates of the scaled, rotated image
def moving_symbols.moving_symbols.Symbol.get_state_message (   self,
  step 
)

Produce a message about the state of the symbol at the given time step.

Return a message containing information about the current pose and motion of the symbol. Everything is a float except for id (int), position (np.float array with shape (2,)), and velocity (np.float array with shape (2,)).

Parameters
stepThe time step of the MovingSymbolEnvironment
Return values
messageA dict describing the symbol's state. Its key-value pairs are:
  • step: Current time step
  • type: 'symbol_state'
  • meta: dict with following key-value pairs:
    • symbol_id: The ID for this symbol
    • position: The symbol's PyGame coordinates as an np.array
    • angle: The symbol's PyGame angle
    • scale: The symbol's scale
    • velocity: The symbol's PyGame velocity as an np.array
    • angular_velocity: The symbol's angular velocity
    • scale_velocity: The symbol's scale velocity
def moving_symbols.moving_symbols.Symbol.set_scale (   self,
  step 
)

Set the scale of the symbol to the scaling function at the given time step.

Parameters
stepThe current time step of the environment