Beispiel #1
0
        private static void RunSimulation(
            CartDoublePolePhysics physics,
            double[] t_series,
            double[] x_series,
            double[] xv_series,
            double[] theta1_series,
            double[] theta2_series)
        {
            double t = 0.0;

            // Record initial state.
            t_series[0]      = t;
            x_series[0]      = physics.State[0];
            xv_series[0]     = physics.State[1];
            theta1_series[0] = physics.State[2];
            theta2_series[0] = physics.State[4];

            for (int timestep = 0; timestep < t_series.Length; timestep++, t += physics.Tau)
            {
                // Update model state.
                physics.Update(0.0);

                // Record state.
                t_series[timestep]      = t;
                x_series[timestep]      = physics.State[0];
                xv_series[timestep]     = physics.State[1];
                theta1_series[timestep] = physics.State[2];
                theta2_series[timestep] = physics.State[4];
            }
        }
Beispiel #2
0
        /// <summary>
        /// Run the simulation.
        /// </summary>
        public void Run()
        {
            double t = 0.0;

            // Run the simulation for the required number of timesteps, and record state at each timestep.
            for (int timestep = 0; timestep < _timesteps; timestep++, t += _tau)
            {
                // Record state.
                _t_series[timestep]      = t;
                _x_series[timestep]      = _cartPolePhysics.State[0];
                _xv_series[timestep]     = _cartPolePhysics.State[1];
                _theta1_series[timestep] = _cartPolePhysics.State[2];
                _theta2_series[timestep] = _cartPolePhysics.State[4];

                // Update model state.
                _cartPolePhysics.Update(0.0);
            }
        }