예제 #1
0
def pendulumTest(timeslice=0.001, tmax=100):
    pendulum = InvertedPendulum()
    for n in np.arange(-5, 5, 1):
        states, time = pendulum.time_to_ground(u=n, tmax=tmax, timeslice=timeslice)

        theta = (state.theta for state in states)
        cart =  (state.x for state in states)
        x, y = transform(theta)

        showGraph(x, y, cart, 0.001, "Cart-Pendulum System --> U={0}".format(n))
예제 #2
0
def pendulumForceTest(timeslice=0.001, tmax=100):
    pendulum = InvertedPendulum()
    for n in np.arange(-5, 5, 1):
        states, time = pendulum.time_to_ground(u=n, tmax=tmax, timeslice=timeslice)
        n=0
        for state in states:
            force = pendulum.get_force(state)
            print('Force : {}'.format(force))
            n+=1
            if n > 60: break

        theta = (state.theta for state in states)
        cart =  (state.x for state in states)
        x, y = transform(theta)