import matplotlib.pyplot as plt
import lut

# variables
total_iterations = 500
currentspeed = 80  # digital value
targetspeed = 200  # digital value
maxspeed = 255  # digital value
dt = 0.1  # s
totaltime = total_iterations * dt  # s
accelerationtime = 5  # s
acceleration_iterations = int(accelerationtime / dt)

print("total time", totaltime)
print("acceleration time", accelerationtime)
print("")
print("total iterations", total_iterations)
print("acceleration_iterations", acceleration_iterations)
print("")


# lut
sigmoid = lut.sigmoid
number_lut_points = len(sigmoid)
sample_every = int(number_lut_points / acceleration_iterations)

print("sigmoid points", number_lut_points)
print("sample every", sample_every)



# main code
points = []
speed_difference = targetspeed - currentspeed
newspeed = currentspeed
sigmoid_i = 0
for i in range(total_iterations):
    newspeed = currentspeed + speed_difference * sigmoid[sigmoid_i]
    if (sigmoid_i + sample_every < len(sigmoid)):
        sigmoid_i += sample_every
    points.append((i, newspeed))


t = range(total_iterations)
speed = [p[1] for p in points]
plt.plot(t, speed)
plt.ylim(0, maxspeed)
plt.ylabel("Speed value")
plt.xlabel("Iterations")
plt.show()

795fc9348498624f11eea588d6af8b8d65f7c30d
<mask token>

<mask token>
print('total time', totaltime)
print('acceleration time', accelerationtime)
print('')
print('total iterations', total_iterations)
print('acceleration_iterations', acceleration_iterations)
print('')
<mask token>
print('sigmoid points', number_lut_points)
print('sample every', sample_every)
<mask token>
for i in range(total_iterations):
    newspeed = currentspeed + speed_difference * sigmoid[sigmoid_i]
    if sigmoid_i + sample_every < len(sigmoid):
        sigmoid_i += sample_every
    points.append((i, newspeed))
<mask token>
plt.plot(t, speed)
plt.ylim(0, maxspeed)
plt.ylabel('Speed value')
plt.xlabel('Iterations')
plt.show()

<mask token>
total_iterations = 500
currentspeed = 80
targetspeed = 200
maxspeed = 255
dt = 0.1
totaltime = total_iterations * dt
accelerationtime = 5
acceleration_iterations = int(accelerationtime / dt)
print('total time', totaltime)
print('acceleration time', accelerationtime)
print('')
print('total iterations', total_iterations)
print('acceleration_iterations', acceleration_iterations)
print('')
sigmoid = lut.sigmoid
number_lut_points = len(sigmoid)
sample_every = int(number_lut_points / acceleration_iterations)
print('sigmoid points', number_lut_points)
print('sample every', sample_every)
points = []
speed_difference = targetspeed - currentspeed
newspeed = currentspeed
sigmoid_i = 0
for i in range(total_iterations):
    newspeed = currentspeed + speed_difference * sigmoid[sigmoid_i]
    if sigmoid_i + sample_every < len(sigmoid):
        sigmoid_i += sample_every
    points.append((i, newspeed))
t = range(total_iterations)
speed = [p[1] for p in points]
plt.plot(t, speed)
plt.ylim(0, maxspeed)
plt.ylabel('Speed value')
plt.xlabel('Iterations')
plt.show()

import matplotlib.pyplot as plt
import lut
total_iterations = 500
currentspeed = 80
targetspeed = 200
maxspeed = 255
dt = 0.1
totaltime = total_iterations * dt
accelerationtime = 5
acceleration_iterations = int(accelerationtime / dt)
print('total time', totaltime)
print('acceleration time', accelerationtime)
print('')
print('total iterations', total_iterations)
print('acceleration_iterations', acceleration_iterations)
print('')
sigmoid = lut.sigmoid
number_lut_points = len(sigmoid)
sample_every = int(number_lut_points / acceleration_iterations)
print('sigmoid points', number_lut_points)
print('sample every', sample_every)
points = []
speed_difference = targetspeed - currentspeed
newspeed = currentspeed
sigmoid_i = 0
for i in range(total_iterations):
    newspeed = currentspeed + speed_difference * sigmoid[sigmoid_i]
    if sigmoid_i + sample_every < len(sigmoid):
        sigmoid_i += sample_every
    points.append((i, newspeed))
t = range(total_iterations)
speed = [p[1] for p in points]
plt.plot(t, speed)
plt.ylim(0, maxspeed)
plt.ylabel('Speed value')
plt.xlabel('Iterations')
plt.show()

import matplotlib.pyplot as plt
import lut

# variables
total_iterations = 500
currentspeed = 80  # digital value
targetspeed = 200  # digital value
maxspeed = 255  # digital value
dt = 0.1  # s
totaltime = total_iterations * dt  # s
accelerationtime = 5  # s
acceleration_iterations = int(accelerationtime / dt)

print("total time", totaltime)
print("acceleration time", accelerationtime)
print("")
print("total iterations", total_iterations)
print("acceleration_iterations", acceleration_iterations)
print("")


# lut
sigmoid = lut.sigmoid
number_lut_points = len(sigmoid)
sample_every = int(number_lut_points / acceleration_iterations)

print("sigmoid points", number_lut_points)
print("sample every", sample_every)



# main code
points = []
speed_difference = targetspeed - currentspeed
newspeed = currentspeed
sigmoid_i = 0
for i in range(total_iterations):
    newspeed = currentspeed + speed_difference * sigmoid[sigmoid_i]
    if (sigmoid_i + sample_every < len(sigmoid)):
        sigmoid_i += sample_every
    points.append((i, newspeed))


t = range(total_iterations)
speed = [p[1] for p in points]
plt.plot(t, speed)
plt.ylim(0, maxspeed)
plt.ylabel("Speed value")
plt.xlabel("Iterations")
plt.show()
