# Robotic Mechanics and Modeling/Kinematics/Additional Examples of 1-D Kinematics

## Example 1 (Spring '20 - Team 1)

You are driving along the road at ${\displaystyle 30\mathrm {m} /\mathrm {s} }$ , when you notice a duck start to cross the road ${\displaystyle 100\mathrm {m} }$  ahead of you, so you start to decelerate. How long will it take you to come to a complete stop? After ${\displaystyle 3\mathrm {s} }$  of decelerating the duck flys away so you accelerate back to ${\displaystyle 30\mathrm {m/s} }$  at ${\displaystyle 12\mathrm {m/s^{2}} }$ . Once you reach ${\displaystyle 30\mathrm {m/s} }$ , how far have you travled in total since first seeing the duck?

For the first part of this problem, to find the time it would take for the car to come to a complete stop. We will need two kinematic equations to solve this. Equation 1 will be used to find the acceleration necessary to come to a complete stop. Equation 2 will be used to find the time.

Equation 1: ${\displaystyle v_{f}^{2}=v_{i}^{2}+2a(x_{f}-x_{i})}$

The initial velocity, final velocity and total distance traveled are given. We will set the final position equal to the total distance traveled and the initial position to zero. We can manipulate Equation 1 and plug in the given values to find the acceleration. An example on how to set this up in IPython (JupyterLab) is shown below.

%reset -f
from sympy import symbols
x_f,x_i,v_f,v_i,a = symbols('x_f x_i v_f v_i a')
a=(v_f**2-v_i**2)/(x_f-x_i)

a=a.subs(v_f,0)
a=a.subs(v_i,30)
a=a.subs(x_f,100)
a=a.subs(x_i,0)
a


The acceleration is calculated to be ${\displaystyle -9\mathrm {m/s^{2}} }$ . We will now use this value in Equation 2 in order to find the time taken to come to a complete stop.

Equation 2: ${\displaystyle v_{f}=v_{i}+at}$

We can manipulate Equation 2 and plug in the given values to find the time. An example on how to set this up in IPython (JupyterLab) is shown below.

%reset -f
from sympy import symbols
t,v_f,v_i,a = symbols('t v_f v_i a')
t=(v_f-v_i)/a

t=t.subs(v_f,0)
t=t.subs(v_i,30)
t=t.subs(a,-9)
round(t,2) # rounds answer to 2 decimal places


It takes ${\displaystyle 3.33\mathrm {s} }$  for the car to come to a complete stop.

Now we will solve the second part of this problem. First the car decelerates at ${\displaystyle -9\mathrm {m/s^{2}} }$ , for ${\displaystyle 3\mathrm {s} }$  . We can use Equation 3 to find the distance traveled for this portion.

Equation 3: ${\displaystyle x_{f}=x_{i}+v_{i}t+{\frac {1}{2}}at^{2}}$

%reset -f
from sympy import symbols
x_f,x_i,v_i,a,t = symbols('x_f x_i v_i a t')
x_f=x_i+v_i*t+1/2*a*t*t

x_f=x_f.subs(x_i,0)
x_f=x_f.subs(v_i,30)
x_f=x_f.subs(a,-9)
x_f=x_f.subs(t,3)
x_f


The car travels ${\displaystyle 49.5\mathrm {m} }$  during this time. We use Equation 1 to calculate the velocity after the car has traveled this distance and just before it begins to accelerate again.

%reset -f
from sympy import symbols
x_f,x_i,v_f,v_i,a = symbols('x_f x_i v_f v_i a')
v_f=(v_i**2+2*a*(x_f-x_i))**.5

v_f=v_f.subs(v_i,30)
v_f=v_f.subs(a,-9)
v_f=v_f.subs(x_f,49.5)
v_f=v_f.subs(x_i,0)
v_f


This velocity is found to be ${\displaystyle 3\mathrm {m/s} }$  . Next we use Equation 2 to find the time it takes to accelerate from ${\displaystyle 3\mathrm {m/s} }$  to ${\displaystyle 30\mathrm {m/s} }$  at ${\displaystyle 12\mathrm {m/s^{2}} }$ .

%reset -f
from sympy import symbols
t,v_f,v_i,a = symbols('t v_f v_i a')
t=(v_f-v_i)/a

t=t.subs(v_f,30)
t=t.subs(v_i,3)
t=t.subs(a,12)
round(t,2) # rounds answer to 2 decimal places


This time is calculated to be ${\displaystyle 2.25\mathrm {s} }$  Finally we can calculate the total distance traveled using Equation 3.

%reset -f
from sympy import symbols
x_f,x_i,v_i,a,t = symbols('x_f x_i v_i a t')
x_f=x_i+v_i*t+1/2*a*t*t

x_f=x_f.subs(x_i,49.5)
x_f=x_f.subs(v_i,3)
x_f=x_f.subs(a,12)
x_f=x_f.subs(t,2.25)
round(x_f,2)


Notice, we set the initial position to be the ${\displaystyle 49.5\mathrm {m} }$ , distance which was already traveled by the car. Thus, the total distance traveled by the car is found to be ${\displaystyle 86.62\mathrm {m} }$ .

## Example 2 (Spring '20 - Team 2)

Assume a ball is thrown up into the air at an initial velocity of ${\displaystyle 10{m}/{s}}$ . Neglecting drag, the time taken for the ball to reach ${\displaystyle 6{m}/{s}}$  is determined by the following code

# Clearing Variables and Initializing Symbols
from sympy import symbols
x_f, x_i, v_c, a_c, t, v_f, = symbols('x_f,x_i,v_c,a_c,t,v_f')  # Initializing variables

# 1D Kinematics Equations Problem

# Part Ia:
time = (v_f - v_c) / a_c
time = time.subs(v_f, 6)
time = time.subs(v_c, 10)
time = time.subs(a_c, -9.81)

print(time)


The time required by the ball to decelerate to ${\displaystyle 6{m}/{s}}$  is ${\displaystyle 0.41{s}}$

The distance traveled is found by the following equation.

# Part Ib:
x_f = x_i + v_c * t + (1 / 2) * a_c * t * t
x_f = x_f.subs(x_i, 0)
x_f = x_f.subs(v_c, 10)
x_f = x_f.subs(a_c, -9.81)
x_f = x_f.subs(t, time)

print(x_f)


The distance traveled is ${\displaystyle 3.26m}$  to reach the speed of ${\displaystyle 6{m}/{s}}$ .

## Example 3 (Spring '20 - Team 3)

A bus notices nobody at its next stop and nobody has requested one, therefore it does not stop, but slows down to ${\displaystyle 2\;\mathrm {m} }/{\mathrm {s} }$  as it passes the stop. You, ${\displaystyle 15\;\mathrm {m} }$  away, who needs to catch this bus to make their way to school, makes eye contact with the driver as soon as it passes the stop. The bus begins to slow down at ${\displaystyle 1\;\mathrm {m} }/{\mathrm {s^{2}} }$  until it stops while you run towards it at a constant ${\displaystyle 3\;\mathrm {m} }/{\mathrm {s} }$ . How long is the time between when you make eye contact with the driver to when you catch up to the bus?

%reset -f
from sympy import symbols
x_f, x_i, v_c, a_c, t = symbols('x_f x_i v_c a_c t')
x_f = x_i + v_c*t+1/2*a_c*t*t
x_f


We know that we need two equations for this, one each to describe the motion of the bus, and one to describe you, frantically running towards it. We need to set a zero point which we will choose as the bus stop. That means that you start ${\displaystyle -15\;\mathrm {m} }$  behind the bus stop, you have a constant velocity of ${\displaystyle 3\;\mathrm {m} }/{\mathrm {s} }$  and a zero acceleration. A second equation must be constructed for the buses motion. It starts at a distance of ${\displaystyle 0\;\mathrm {m} }$  from the bus stop, it has a constant velocity of ${\displaystyle 2\;\mathrm {m} }/{\mathrm {s} }$  and has an acceleration of ${\displaystyle -1\;\mathrm {m} }/{\mathrm {s^{2}} }$  It is important to understand that since the bus is decelerating, it is accelerating in the negative direction if you choose to have the direction in which the bus and you are moving is in the positive direction.

The first equation, for you, comes out to ${\displaystyle x=-15\;\mathrm {m} +3t\;(\mathrm {m} }/{\mathrm {s} )+0t^{2}\;(\mathrm {m} }/{\mathrm {s^{2}} )}$ . The second equation, for the bus, comes out to ${\displaystyle x=0\;\mathrm {m} +2t\;(\mathrm {m} }/{\mathrm {s} )-1t^{2}\;(\mathrm {m} }/{\mathrm {s^{2}} )}$ . If you set these equal to each other and bring all of the variables to one side you get an equation which equal zero in a quadratic form such that ${\displaystyle 0=-t^{2}-t+15}$ . We can then plug this in python, solve for the determinant to make the debugging easier later if need be and use the quadratic formula to solve.

import cmath
a = -1
b = -1
c = 15
# calculate the discriminant
d = (b**2) - (4*a*c)
# find two solutions
sol1 = (-b-cmath.sqrt(d))/(2*a)
sol2 = (-b+cmath.sqrt(d))/(2*a)
print('The solution are {0} and {1}'.format(sol1,sol2))


This revels two completely real solutions. In this case, because one of them is negative, and we know that time cannot be negative, it takes you about 3.405 seconds to catch up with the bus.