Skip to content
kfriedrichs edited this page Feb 5, 2022 · 3 revisions

Json format

The following is an example state in json format, including one gripper and two objects.

{
  "grippers": {
    "1": {
      "x": 5.5,
      "y": 5.5,
      "gripped": "2"
    }
  },
  "objs": {
    "1": {
      "type": "I",
      "x": 10,
      "y": 8,
      "width": 5,
      "height": 5
    },
    "2": {
      "type": "F",
      "x": 3,
      "y": 3,
      "width": 5,
      "height": 5,
      "color": "yellow",
      "mirrored": true,
      "rotation": 90
    }
  } 
}

Object and gripper properties

The table below provides details on the object / gripper properties:

Object class key default description
objs id_n identifier, str / int
type str: type name, must be specified in type_config in the configuration
x float: should be within the interface dimensions
y float: should be within the interface dimensions
width None float: horizontal size of the object in blocks
height None float: horizontal size of the object in blocks
color "blue" string: defined CSS color string, name or hex code
rotation 0 int, one of [0, 90, 180, 270], angle of the object with respect to the base position defined in type_config
mirrored False bool: true if the object is flipped once with respect to the base position defined in type_config. Might not have a visible effect depending on the shape
gripped False bool: true if the object is gripped by some gripper
block_matrix [] 0/1 matrix defining the shape of an object made up of blocks. 0 signifies the absence of a block, 1 signifies the presence of a block
grippers id_n identifier, str / int
x float: should be within the interface dimensions
y float: should be within the interface dimensions
gripped None id of the gripped object or null if no object is gripped
color "blue" string: defined CSS color string, name or hex code
width 1 float: horizontal size of the object in blocks
height 1 float: horizontal size of the object in blocks

Loading a state

There are several options to change the state of a model.

"load_state"

Using the "load_state" event, a specific state can be loaded. Grippers and objects can be specified in their exact properties and locations.

"random_init"

If some variation to the loaded state is desired, the generation can be randomized. The following parameters are possible:

parameter values default explanation 
n_objects int number of objects to generate
n_grippers int number of grippers to generate
obj_area str, one of ["all“, "top", "bottom", "left", "right"] "all" Area of the board to place objects in. Using "all", the objects have locations randomly selected from the whole board; using "top", only locations within the top half will we chosen, etc.
target_area null/None or str, one of ["all“, "top", "bottom", "left", "right"] "all" If an area is given, a target will be generated for each object. Targets are special objects that may be used in experiments to mark an object's target position. Pass None to not generate any targets.
random_gr_position bool False If set to true, generated grippers will receive random start positions on the board. If false, grippers always start in the center.
Clone this wiki locally