Robotic Mechanics and Modeling/Kinematics/Additional Examples for Velocity and Acceleration
Example 1 (Spring '20 - Team 1)
[edit | edit source]A particle is moving in space. Its position is given by . Find the particle's velocity and acceleration when . Assume SI units.
An example on how to set up a vector in unit vector notation in IPython (JupyterLab) is shown below.
from sympy import *
from sympy.physics.vector import *
t = Symbol('t')
e=ReferenceFrame('e')
x = (t**2 + 1)*e.x + 6*t**3*e.y + (8*t + 4)*e.z
x
The velocity of the particle is the first derivative of the position.
An example of how to stake a derivative in IPython is shown below.
v=x.diff(t,e) # arguments in parenthesis are variable to take dervivative wrt, frame to take derviative in
v
Once the velocity vector is found, is plugged in to find the velocity at this time.
v_5=v.subs(t,5)
v_5
The acceleration of the particle is the first derivative of the velocity or the second derivative of the position.
a=v.diff(t,e)
a
Once the acceleration vector is found, is plugged in to find the acceleration at this time.
a_5=a.subs(t,5)
a_5
Note that the answers will be given in unit vector notation. An example of an IPython code to find the magnitude of a vector is shown below.
import numpy as np
x=np.array([2,180])
a_m=np.linalg.norm(x)
round(a_m,2)
The magnitude of the velocity is ., and the magnitude of the acceleration is .
We can then graph the velocity and position over a particular time frame which we choose here to be 10 seconds. We define each component of the velocity and acceleration in a function and graph them. From the resulting graphs we observe the z-component of the velocity to increase the most over time (exponentially) and find that the y-component of acceleration to increase the most over time (linearly).
%reset -f
import numpy as np
import matplotlib.pyplot as plt
vel=[]
def vx(t):
return 2*t
def vy(t):
return 18*t**2
def vz(t):
return 8+0*t
def ax(t):
return 2+0*t
def ay(t):
return 36*t
def az(t):
return 0+0*t
t1=np.arange(0,10,0.2)
plt.figure()
plt.subplot(211)
plt.plot(t1,vx(t1),'bo',t1,vy(t1),'ks',t1,vz(t1),'r^')
plt.title('Velocity vs. Time',size=20)
plt.ylabel('Velocity (m/s)')
plt.xlabel('Time (s)')
plt.savefig('robotics_velocity_ex2.png',dpi=300,bbox_inches='tight')
plt.figure()
plt.subplot(211)
plt.plot(t1,ax(t1),'go',t1,ay(t1),'ms',t1,az(t1),'c^')
plt.title('Acceleration vs. Time',size=20)
plt.ylabel('Acceleration (m/s^2)')
plt.xlabel('Time (s)')
plt.savefig('robotics_acceleration_ex2.png',dpi=300,bbox_inches='tight')
Example 2 (Spring '20 - Team 2)
[edit | edit source]We are running some wind tunnel experiments at Rutgers University. We are focused on a single fluid particle moving through the test section. The particle's path in the test section is defined by a vector function , where t is measured in seconds and the distance is measured in meters.
(a) Find the components of acceleration, tangential component and the normal component as the function of time (t).
(b) Find the components of acceleration, tangential component and the normal component at time and the total acceleration of the particle.
# Clearing Variables and Initializing Symbols
import numpy as np
import sympy as sym
from sympy import *
# Initializing variables
r_x, r_y, r_z, v_x, v_y, v_z, a_x, a_y, a_z, t, i, j, k = symbols(' r_x, r_y, r_z, v_x, v_y, v_z, a_x, a_y, a_z, t, i, j, k ')
We can find the velocity of the particle by differentiating the position vector with respect to time (t). Using the velocity vector we can find the acceleration vector by differentiating the with respect to time (t).
# Setting up the position vector
r_x = (2 * (t ** 2))
r_y = (5 * (t ** 2) + 3)
r_z = (-3 * t)
# Calculating the velocity vector equation
v_x = sym.diff(r_x)
v_y = sym.diff(r_y)
v_z = sym.diff(r_z)
# Calculating the acceleration vector equation
a_x = sym.diff(v_x)
a_y = sym.diff(v_y)
a_z = sym.diff(v_z)
print("a(t) = ", a_x, "i +", a_y, "j +", a_z, "k")
(a) Find the two components of the acceleration: the tangential component and the normal component as a function of time.
[edit | edit source]The general equation for each of the components is given by
Tangential component of acceleration :
Normal component of acceleration :
# Finding Tangent Acceleration
aTan_x = np.dot(a_x, v_x)
aTan_y = np.dot(a_y, v_y)
aTan_z = np.dot(a_z, v_z)
vMag = sqrt((np.dot(v_x, v_x)) + (np.dot(v_y, v_y)) + (np.dot(v_z, v_z)))
aTan = (aTan_x + aTan_y + aTan_z)/vMag
print("aTan(t) =", aTan)
# Finding Normal Acceleration
aMag = vMag = (np.dot(a_x, a_x)) + (np.dot(a_y, a_y)) + (np.dot(a_z, a_z))
aNorm = sqrt(aMag - aTan)
print("aNorm(t) =", aNorm)
Answers
[edit | edit source]The tangential component :
The normal component :
(b) Find the two components of the acceleration: the tangential component and the normal component at time t = 5 seconds.
[edit | edit source]For this part, we can simply plug in the value of time as t = 5s in the answers of part (a).
# Evaluating the components of acceleration at t = 5s.
aTan = aTan.subs(t, 5)
aNorm = aNorm.subs(t, 5)
print("Tangent Acceleration at 5 seconds:", aTan, "meters per seconds squared")
print("Normal Acceleration at 5 seconds:", aNorm, "meters per seconds squared")
The total acceleration of the particle can be calculated by adding the two components.
Answers
[edit | edit source]The final answer for each of the components is: and .
The total acceleration is:
Example 3 (Spring '20 - Team 3)
[edit | edit source]A bus driver accidentally enters a go-kart track with his bus which loops in a perfect circle. If the track is viewed as being on the x-y spatial plane, the buses x position can be described, as a function of time as and the y position can be described, as a function of time as . Knowing this, we can plot the position of the bus as it goes around the track as function of time and can take the derivatives of these functions to obtain both the velocity and acceleration of the bus as it is moving around the track. We can define a path and plot the x and y components with time. This comes out to be a spiral.
import numpy as np
from matplotlib import pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
ax = plt.axes(projection='3d')
# Data for a three-dimensional line
t = np.linspace(0, 15, 1000)
x = np.sin(t)
y = np.cos(t)
ax.plot3D(x, y, t, 'gray')
ax.view_init(50,20)
We can make this a bit prettier by adding some color by adding some data points instead of just a line, but this is not necessary.
ax = plt.axes(projection='3d')
# Data for a three-dimensional line
t = np.linspace(0, 15, 1000)
x = np.sin(t)
y = np.cos(t)
ax.plot3D(x, y, t, 'gray')
# Data for three-dimensional scattered points
tdata = np.linspace(0, 15, 1000)
xdata = np.sin(tdata)
ydata = np.cos(tdata)
ax.scatter3D(xdata, ydata, tdata, c=tdata);
ax.view_init(50,75)
Now we can take the derivatives of each of the x and y components.
from sympy import *
import numpy as np
t = symbols('t')
vx = diff(sin(t), t)
vy = diff(cos(t), t)
vx
vy
This results in an x velocity of and a y velocity of . Now let us plot these derivatives, also known as the velocity of the curve.
ax = plt.axes(projection='3d')
# Data for a three-dimensional line
t = np.linspace(0, 15, 1000)
x = np.cos(t)
y = -np.sin(t)
ax.plot3D(x, y, t, 'gray')
# Data for three-dimensional scattered points
tdata = np.linspace(0, 15, 1000)
xdata = np.cos(tdata)
ydata = -np.sin(tdata)
ax.scatter3D(xdata, ydata, tdata, c=tdata);
ax.view_init(50,75)
Now we can take the derivatives of the x and y components again.
ax = diff(cos(t), t)
ay = diff(-sin(t), t)
ax
ay
This results in an x acceleration of and a y acceleration of . Now let us plot the acceleration of this path using the second derivatives.
ax = plt.axes(projection='3d')
# Data for a three-dimensional line
t = np.linspace(0, 15, 1000)
x = -np.sin(t)
y = -np.cos(t)
ax.plot3D(x, y, t, 'gray')
# Data for three-dimensional scattered points
tdata = np.linspace(0, 15, 1000)
xdata = -np.sin(tdata)
ydata = -np.cos(tdata)
ax.scatter3D(xdata, ydata, tdata, c=tdata);
ax.view_init(50,75)