Ejemplo n.º 1
0
    def test_generic_calls(self):
        """
        check whether all generic simulation and postprocessing modules are registered using the general getter call
        """
        # register in wrong module category
        self.assertRaises(TypeError, register_simulation_module, PostProcessingModule, EvalA1)
        self.assertRaises(TypeError, register_processing_module, MetaProcessingModule, EvalA1)
        register_processing_module(PostProcessingModule, EvalA1)

        # check registration
        self.assertEqual([(EvalA1, "EvalA1")],
                         get_registered_processing_modules(PostProcessingModule)[-1:])

        # test for automatic duplicate recognition
        self.assertRaises(ValueError, register_processing_module, PostProcessingModule, EvalA1)
Ejemplo n.º 2
0
    def test_generic_calls(self):
        """
        check whether all generic simulation and postprocessing modules are registered using the general getter call
        """
        # register in wrong module category
        self.assertRaises(TypeError, register_simulation_module,
                          PostProcessingModule, EvalA1)
        self.assertRaises(TypeError, register_processing_module,
                          MetaProcessingModule, EvalA1)
        register_processing_module(PostProcessingModule, EvalA1)

        # check registration
        self.assertEqual(
            [(EvalA1, "EvalA1")],
            get_registered_processing_modules(PostProcessingModule)[-1:])

        # test for automatic duplicate recognition
        self.assertRaises(ValueError, register_processing_module,
                          PostProcessingModule, EvalA1)
Ejemplo n.º 3
0
import pymoskito as pm


class MassMetricMetaProcessor(pm.XYMetaProcessor):

    def __init__(self):
        sort_key = ["modules", "Controller", "type"]
        x_path = ["modules", "Model", "M"]
        y_path = ["metrics", "L1NormITAE"]

        pm.XYMetaProcessor.__init__(self, x_path, y_path, sort_key)

pm.register_processing_module(pm.MetaProcessingModule, MassMetricMetaProcessor)
Ejemplo n.º 4
0

if __name__ == "__main__":
    # register own modules
    register_simulation_module(Model, TwoPendulumModel)
    register_simulation_module(Model, TwoPendulumRigidBodyModel)
    register_simulation_module(Model, TwoPendulumModelParLin)

    register_simulation_module(Controller, LinearStateFeedback)
    register_simulation_module(Controller, LinearStateFeedbackParLin)
    register_simulation_module(Controller, LjapunovController)
    register_simulation_module(Controller, SwingUpController)

    register_visualizer(TwoPendulumVisualizer)

    register_processing_module(PostProcessingModule, TwoPendulum)

    # create an Application instance (needed)
    app = QApplication([])

    if 1:
        # create Simulator
        sim = Simulator()

        # load default config
        sim.load_regimes_from_file("default.sreg")

        # apply a regime
        sim.apply_regime_by_name("test")

        # remotely start a simulation
Ejemplo n.º 5
0
                   label=r"$\dot{\varphi}_{1}$")
        axes1.plot(t, np.rad2deg(phi1_vel_analytic),
                   c="red",
                   linestyle="--",
                   linewidth=0.8,
                   label=r"$\dot{\varphi}_{1,\mathrm{ana}}$")
        axes1.set_xlim(left=t[0], right=t[-1])
        axes1.set_xlabel(r"Time in s")
        axes1.set_ylabel(r"Angular velocity in $^\circ\hspace{-3pt}/\mathrm{s}$")
        axes1.grid()
        axes1.legend()
        axes1.legend(loc=0)
        canvas = FigureCanvas(fig)

        plot_name = "_".join([data["regime name"], self.name, "phi1"])
        return_list.append({"name": plot_name, "figure": canvas})

        # save file
        self.write_output_files(result_name="_".join([data["regime name"], "phi1"]),
                                figure=fig,
                                output=pm.construct_result_dict(data, output={}))

        return return_list

        # parameter of the oscillation differential equation
        # D = d1*np.sqrt(g/l1)/(2*m1*l1**2)
        # omega0 = np.sqrt(l1/g)

pm.register_processing_module(pm.PostProcessingModule, TwoPendulum)
pm.register_processing_module(pm.PostProcessingModule, SimulationVerification)
Ejemplo n.º 6
0
import pymoskito as pm


class MassMetricMetaProcessor(pm.XYMetaProcessor):
    def __init__(self):
        sort_key = ["modules", "Controller", "type"]
        x_path = ["modules", "Model", "M"]
        y_path = ["metrics", "L1NormITAE"]

        pm.XYMetaProcessor.__init__(self, x_path, y_path, sort_key)


pm.register_processing_module(pm.MetaProcessingModule, MassMetricMetaProcessor)
Ejemplo n.º 7
0
from processing import TwoPendulum

if __name__ == '__main__':
    # register own modules
    register_simulation_module(Model, TwoPendulumModel)
    register_simulation_module(Model, TwoPendulumRigidBodyModel)
    register_simulation_module(Model, TwoPendulumModelParLin)

    register_simulation_module(Controller, LinearStateFeedback)
    register_simulation_module(Controller, LinearStateFeedbackParLin)
    register_simulation_module(Controller, LjapunovController)
    register_simulation_module(Controller, SwingUpController)

    register_visualizer(TwoPendulumVisualizer)

    register_processing_module(PostProcessingModule, TwoPendulum)

    # create an Application instance (needed)
    app = QApplication([])

    if 1:
        # create Simulator
        sim = Simulator()

        # load default config
        sim.load_regimes_from_file("default.sreg")

        # apply a regime
        sim.apply_regime_by_name("test")

        # remotely start a simulation
Ejemplo n.º 8
0
import pymoskito as pm

from . import settings as st


class BallBeamStepResponse(pm.StepResponse):
    """
    Postprocessor the creates Step Response Diagrams for the Ballbeam system.

    Run the `pp_regimes.sreg` file to create the required simulation data.
    """
    def __init__(self):
        super().__init__(model_idx=0, trajectory_idx=0)


pm.register_processing_module(pm.PostProcessingModule, BallBeamStepResponse)


# TODO get those working again
class EvalA1(pm.PostProcessingModule):
    """
    create diagrams for evaluation step A1
    """
    name = 'A1'

    line_color = '#aaaaaa'
    line_style = '-'
    font_size = 20
    #    epsPercent = 2./5
    spacing = 0.01
    counter = 0
Ejemplo n.º 9
0
    register_simulation_module, register_processing_module, register_visualizer, \
    PostProcessingModule, \
    Model, Controller

from model import BallBeamModel
from control import FController
from visualization import BallBeamVisualizer
from postprocessing import EvalA1

__author__ = 'stefan'

if __name__ == '__main__':
    # register own modules
    register_simulation_module(Model, BallBeamModel)
    register_simulation_module(Controller, FController)
    register_processing_module(PostProcessingModule, EvalA1)
    register_visualizer(BallBeamVisualizer)

    # create an Application instance (needed)
    app = QtGui.QApplication([])

    if 0:
        # create simulator
        sim = Simulator()

        # load default config
        sim.load_regimes_from_file("default.sreg")
        sim.apply_regime_by_name("test-nonlinear")
        sim.start_simulation()

        sim.show()
Ejemplo n.º 10
0
from feedforward import BallInTubeFeedforward
from visualization import BallInTubeVisualizer

from processing import ErrorProcessor


if __name__ == "__main__":
    # register Modules
    register_simulation_module(Model, BallInTubeModel)
    register_simulation_module(Model, BallInTubeSpringModel)
    register_simulation_module(Controller, ExactInputOutputLinearisation)
    register_simulation_module(Controller, OpenLoop)
    register_simulation_module(Feedforward, BallInTubeFeedforward)
    register_visualizer(BallInTubeVisualizer)

    register_processing_module(PostProcessingModule, ErrorProcessor)

    # create an Application instance (needed)
    app = QtGui.QApplication([])

    if 1:
        # create gui
        sim = Simulator()

        # load default config
        sim.load_regimes_from_file("default.sreg")
        sim.apply_regime_by_name("test")
        # gui.start_simulation()

        sim.show()
    else:
Ejemplo n.º 11
0
        # L1 
        dt = 1.0 / data['modules']['solver']['measure rate']
        errorIntegrals = [0, 0, 0, 0]

        # check for sim success
        if not data['results']['finished']:
            for key in output.keys():
                output[key] = None

        for i in range(len(errorIntegrals)):
            for k, val in enumerate(xo[i]):
                # vgl. Betragskriterium L^1
                errorIntegrals[i] += 1
                errorIntegrals[i] += abs(val - xm[i][k]) * dt

            print('errorIntegral_x[' + str(i) + ']:', errorIntegrals[i])
            output.update({'error_L1Norm_x[' + str(i) + ']': errorIntegrals[i]})

        # add settings and metrics to dictionary results
        results = {}
        results.update({'metrics': output})
        results.update({'modules': data['modules']})

        canvas = FigureCanvas(fig)

        self.writeOutputFiles(self.name, data["regime name"], fig, results)

        return dict(name="_".join({data["regime name"], self.name}), figure=canvas)

pm.register_processing_module(pm.PostProcessingModule, EvalA1)