Ejemplo n.º 1
0
 def test_system_base_api(self):
     # Test a system with a different number of inputs from outputs.
     system = Adder(3, 10)
     self.assertIsInstance(system, SystemBase)
     self.assertEqual(
         system.GetSystemType(),
         "drake::systems::Adder<double>")
     system.set_name(name="adder")
     self.assertEqual(system.get_name(), "adder")
     self.assertEqual(system.GetSystemName(), "adder")
     self.assertEqual(system.GetSystemPathname(), "::adder")
     self.assertEqual(system.num_input_ports(), 3)
     self.assertEqual(system.num_output_ports(), 1)
     u1 = system.GetInputPort("u1")
     self.assertEqual(u1.get_name(), "u1")
     self.assertIn("u1", u1.GetFullDescription())
     self.assertEqual(u1.get_index(), 1)
     self.assertEqual(u1.size(), 10)
     self.assertIsNotNone(u1.ticket())
     self.assertIs(u1.get_system(), system)
     y = system.GetOutputPort("sum")
     self.assertEqual(y.get_name(), "sum")
     self.assertEqual(y.get_index(), 0)
     self.assertIsInstance(y.Allocate(), Value[BasicVector])
     self.assertIs(y.get_system(), system)
     y.disable_caching_by_default()
     self.assertEqual(y, system.get_output_port())
Ejemplo n.º 2
0
 def __init__(self, num_inputs, size):
     Diagram.__init__(self)
     builder = DiagramBuilder()
     adder = Adder(num_inputs, size)
     builder.AddSystem(adder)
     builder.ExportOutput(adder.get_output_port(0))
     for i in range(num_inputs):
         builder.ExportInput(adder.get_input_port(i))
     builder.BuildInto(self)
Ejemplo n.º 3
0
 def __init__(self, num_inputs, size):
     Diagram.__init__(self)
     builder = DiagramBuilder()
     adder = Adder(num_inputs, size)
     builder.AddSystem(adder)
     builder.ExportOutput(adder.get_output_port(0))
     for i in range(num_inputs):
         builder.ExportInput(adder.get_input_port(i))
     builder.BuildInto(self)