Velocity, acceleration and jerk: Difference between revisions
(Created page with "== Introduction == The Newton <math>F=ma</math> force rule states that force and acceleration are proportionally related. Is it possible to accelerate without noticing that?...") |
(→Sensor) |
||
Line 12: | Line 12: | ||
=== Sensor === | === Sensor === | ||
The Vernier acceleration sensor with NXT Adapter is used. The sensor is attached to port number 4. | The Vernier acceleration sensor with the NXT Adapter is used. The sensor is attached to port number 4. | ||
Very simple test program to see what are the measured values is shown below. The values are in arbitrary scale, and need to be normalized. We found, that the | Very simple test program to see what are the measured values is shown below. The values are in arbitrary scale, and need to be normalized. We found, that the | ||
Line 25: | Line 25: | ||
import time | import time | ||
import os | import os | ||
import csv | |||
os.system('setfont Lat15-TerminusBold32x16') # Try this larger font | os.system('setfont Lat15-TerminusBold32x16') # Try this larger font | ||
Line 44: | Line 45: | ||
writer.writerow((time.time(), acc )) | writer.writerow((time.time(), acc )) | ||
time.sleep( tstep ) | time.sleep( tstep ) | ||
</syntaxhighlight> | |||
The resulted file ''acc.csv'' is then manually downloaded into a computer, and plotted using Python Pandas: | |||
<syntaxhighlight lang="python"> | |||
import pandas as pd | |||
import matplotlib.pyplot as plt | |||
# Read CSV file into DataFrame df | |||
df = pd.read_csv('acc.csv', index_col=0) | |||
# Show thedataframe | |||
print(df) | |||
plt.plot(df) | |||
</syntaxhighlight> | </syntaxhighlight> | ||
Revision as of 19:49, 24 September 2020
Introduction
The Newton force rule states that force and acceleration are proportionally related. Is it possible to accelerate without noticing that? The method is used in elevators, for example, and hopefully in modern (electric) cars.
We consider the acceleration the robot is subjected to while accelerating it using different acceleration functions.
Robot
Almost any robot will be ok, we use Asimov 2/ Verne.
Sensor
The Vernier acceleration sensor with the NXT Adapter is used. The sensor is attached to port number 4.
Very simple test program to see what are the measured values is shown below. The values are in arbitrary scale, and need to be normalized. We found, that the
#!/usr/bin/env python3
# https://sites.google.com/site/ev3devpython/
from ev3dev2.sensor import *
from ev3dev2.sensor import INPUT_4
import time
import os
import csv
os.system('setfont Lat15-TerminusBold32x16') # Try this larger font
p = Sensor( INPUT_4 )
p.mode="ANALOG-1"
def measureAcc(p):
acc = p.value(0)
return acc
f = open('acc.csv',"w")
writer = csv.writer(f)
tstep = 0.001
while True:
acc = measureAcc(p)
print( acc )
writer.writerow((time.time(), acc ))
time.sleep( tstep )
The resulted file acc.csv is then manually downloaded into a computer, and plotted using Python Pandas:
import pandas as pd
import matplotlib.pyplot as plt
# Read CSV file into DataFrame df
df = pd.read_csv('acc.csv', index_col=0)
# Show thedataframe
print(df)
plt.plot(df)