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

## Example 1 (Spring '20 - Team 1)[edit | edit source]

You are driving along the road at , when you notice a duck start to cross the road ahead of you, so you start to decelerate. How long will it take you to come to a complete stop? After of decelerating the duck flys away so you accelerate back to at . Once you reach , 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:

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 . We will now use this value in Equation 2 in order to find the time taken to come to a complete stop.

Equation 2:

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 for the car to come to a complete stop.

Now we will solve the second part of this problem. First the car decelerates at , for . We can use Equation 3 to find the distance traveled for this portion.

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,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 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 . Next we use Equation 2 to find the time it takes to accelerate from to at .

```
%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 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 , distance which was already traveled by the car. Thus, the total distance traveled by the car is found to be .

## Example 2 (Spring '20 - Team 2)[edit | edit source]

Assume a ball is thrown up into the air at an initial velocity of . Neglecting drag, the time taken for the ball to reach 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 is

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 to reach the speed of .

## Example 3 (Spring '20 - Team 3)[edit | edit source]

A bus notices nobody at its next stop and nobody has requested one, therefore it does not stop, but slows down to as it passes the stop. You, 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 until it stops while you run towards it at a constant . 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 behind the bus stop, you have a constant velocity of and a zero acceleration. A second equation must be constructed for the buses motion. It starts at a distance of from the bus stop, it has a constant velocity of and has an acceleration of 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 . The second equation, for the bus, comes out to . 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 . 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.