Exemplo n.º 1
0
    def test_random_source(self):
        source = RandomSource(distribution=RandomDistribution.kUniform,
                              num_outputs=2, sampling_interval_sec=0.01)
        self.assertEqual(source.get_output_port(0).size(), 2)

        builder = DiagramBuilder()
        # Note: There are no random inputs to add to the empty diagram, but it
        # confirms the API works.
        AddRandomInputs(sampling_interval_sec=0.01, builder=builder)

        builder_ad = DiagramBuilder_[AutoDiffXd]()
        AddRandomInputs(sampling_interval_sec=0.01, builder=builder_ad)
Exemplo n.º 2
0
    def test_random_sources(self):
        uniform_source = UniformRandomSource(num_outputs=2,
                                             sampling_interval_sec=0.01)
        self.assertEqual(uniform_source.get_output_port(0).size(), 2)

        gaussian_source = GaussianRandomSource(num_outputs=3,
                                               sampling_interval_sec=0.01)
        self.assertEqual(gaussian_source.get_output_port(0).size(), 3)

        exponential_source = ExponentialRandomSource(num_outputs=4,
                                                     sampling_interval_sec=0.1)
        self.assertEqual(exponential_source.get_output_port(0).size(), 4)

        builder = DiagramBuilder()
        # Note: There are no random inputs to add to the empty diagram, but it
        # confirms the API works.
        AddRandomInputs(sampling_interval_sec=0.01, builder=builder)