Exemplo n.º 1
0
    def test_simple_robot(self):
        """
        Tests whether a simple robot is correctly encoded.
        :return:
        """

        protobuf_robot = yaml_to_proto(body_spec, brain_spec,
                                       basic_yaml_object)
        yaml_robot = rty(protobuf_robot)
        robot = yaml.safe_load(yaml_robot)

        self.assertEqual(0, robot["id"], "Robot ID not correctly set.")

        self.assertEqual(
            "Core", robot["body"]["id"],
            "Root ID not correctly set. (%s)" % robot["body"]["id"])

        self.assertEqual(2, len(robot["body"]["children"]),
                         "Root should have two children.")
Exemplo n.º 2
0
      id: Wheel
      type: Wheel
      params:
        red: 0.0
        green: 1.0
        blue: 0.0
    5:
      id: Wheel2
      type: Wheel
      params:
        red: 0.0
        green: 1.0
        blue: 0.0
brain:
  params:
    Wheel-out-0:
      type: Oscillator
      period: 3
    Wheel2-out-0:
      type: Oscillator
      period: 3
'''

bot = yaml_to_proto(body_spec, brain_spec, bot_yaml)
builder = RobotBuilder(BodyBuilder(body_spec), NeuralNetBuilder(brain_spec))
model = builder.sdf_robot(bot, "libRobotControlPlugin.so")
model.translate(Vector3(0, 0, 0.5))
sdf = SDF()
sdf.add_element(model)
logger.info(str(sdf))
Exemplo n.º 3
0
      id: Wheel
      type: Wheel
      params:
        red: 0.0
        green: 1.0
        blue: 0.0
    5:
      id: Wheel2
      type: Wheel
      params:
        red: 0.0
        green: 1.0
        blue: 0.0
brain:
  params:
    Wheel-out-0:
      type: Oscillator
      period: 3
    Wheel2-out-0:
      type: Oscillator
      period: 3
'''

bot = yaml_to_proto(body_spec, brain_spec, bot_yaml)
builder = RobotBuilder(BodyBuilder(body_spec), NeuralNetBuilder(brain_spec))
model = builder.sdf_robot(bot, "libRobotControlPlugin.so")
model.translate(Vector3(0, 0, 0.5))
sdf = SDF()
sdf.add_element(model)
print(str(sdf))
Exemplo n.º 4
0
             params=[
                 ParamSpec("param_a", default=-1),
                 ParamSpec("param_b", default=15)
             ])
})

brain_spec = NeuralNetImplementation({
    "Simple":
    NeuronSpec(params=["bias"]),
    "Oscillator":
    NeuronSpec(params=["period", "phaseOffset", "amplitude"])
})

# Enter the test cases below (make alterations to the basic yaml object)
# Body test cases
missing_body = yaml_to_proto(body_spec, brain_spec, basic_yaml_object)
missing_body.body.root.Clear()

missing_id = yaml_to_proto(body_spec, brain_spec, basic_yaml_object)
missing_id.body.root.id = ""

missing_part_type = yaml_to_proto(body_spec, brain_spec, basic_yaml_object)
missing_part_type.body.root.type = ""

part_not_in_spec = yaml_to_proto(body_spec, brain_spec, basic_yaml_object)
part_not_in_spec.body.root.type = "NonExistent"

arity_fail = yaml_to_proto(body_spec, brain_spec, basic_yaml_object)
arity_fail.body.root.child[0].src_slot = 5

slot_reuse = yaml_to_proto(body_spec, brain_spec, basic_yaml_object)
Exemplo n.º 5
0
def ytr(yaml):
    return yaml_to_proto(body_spec, brain_spec, yaml)