コード例 #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];
            }
        }
コード例 #2
0
        public CartDoublePoleSimulator(

            double durationSecs,
            CartDoublePolePhysics cartPolePhysics)
        {
            _tau             = cartPolePhysics.Tau;
            _durationSecs    = durationSecs;
            _timesteps       = (int)(durationSecs / _tau);
            _cartPolePhysics = cartPolePhysics;

            _t_series      = new double[_timesteps];
            _x_series      = new double[_timesteps];
            _xv_series     = new double[_timesteps];
            _theta1_series = new double[_timesteps];
            _theta2_series = new double[_timesteps];
        }