# 2020WinterTeam7

## Contents

## Project Overview

Our goal was to provide our car with particular GPS coordinates, have the car navigate to the destination coordinates by using GPS and RTK2 corrections to achieve centimeter accuracy. We utilized Potential Functions and Gradient descent algorithm to avoid obstacles and find the path through objects.

**Main objectives of adaptive cruise control are:**

1. GPS-RTK Navigation from source to the assigned destination

2. Connecting the two C099-F9P GPS-RTK2 modules using Odin (wifi)

3. Obstacle avoidance

## Team Members

**Chanyang Yim** – Mechanical and Aerospace Engineering Department

**Jiuqi Wang** – Mechanical and Aerospace Engineering Department

**Omid Hasanli** – Electrical and Computer Engineering Department

## Design and Assembly of Donkey

### Camera Mount, GPS Case, and Antenna Base Design

This part includes all the CAD files during the project.

#### Camera Mount

The camera mount contains three parts, the purpose of this design is to let the camera be adjustable with height and angle. The first part is the camera base, which mounts the camera with four bolts and nuts, and can be mounted on the upper stand with one bolt. The second part is the upper stand, this part has many holes on it to make sure the camera can adjust the height. The last part is the stand, the holes mate the holes on the upper stand.

In our design, the first camera mount was not perfect, the camera did not have enough angles to adjust, and the stand was very thin. Therefore, here shows the modified design of our camera mount.

#### GPS Case

The GPS we used is a bare circuit board, which needs protection. A GPS case was designed to protect the GPS from bumps. GPS case contains two parts, GPS cover and GPS base.

#### Antenna Base

Similar to GPS, there was an antenna base to make sure the antenna was stable during operation.

### Jetson Nano case

To house our Jetson Nano, we 3D printed a case taken off of Thingiverse at: https://www.thingiverse.com/thing:3518410

## Autonomous Driving using gradient descent

#### The General Idea

To build potential fields, so that the point that represents the robot is attracted by the goal and repelled by the obstacle region. The robot moves to a lower energy configuration and energy is minimized by following the negative gradient of the potential energy function.

#### Artificial Potential Field Methods

##### The Attractive Potential

– Uatt is the “attractive” potential --- move to the goal

##### The Repulsive Potential

– Urep is the “repulsive” potential --- avoid obstacles

##### Total Potential Function

– Uatt is the “attractive” potential --- move to the goal – Urep is the “repulsive” potential --- avoid obstacles

#### Gradient Descent

#### Final Result

#### Python Code

def GPSPathFinder(initial_location, final_location, obstacles_location_1, obstacles_location_2):

steps =[0.0, 0.0] steps[0] = round_down(((final_location[0] - initial_location[0])/100), 10) steps[1] = round_down(((final_location[1] - initial_location[1])/100), 10)

a1 = [0.0, 0.0] a1[0] = round_down(((obstacles_location_1[0] - initial_location[0]) / steps[0]), 10) a1[1] = round_down(((obstacles_location_1[1] - initial_location[1]) / steps[1]), 10) a2 = [0.0, 0.0] a2[0] = round_down(((obstacles_location_2[0] - initial_location[0]) / steps[0]), 10) a2[1] = round_down(((obstacles_location_2[1] - initial_location[1]) / steps[1]), 10)

initial_loc = [0.0 , 0.0] cur_loc = initial_loc final_loc = [100.0, 100.0] mu = [a1, a2] sigma = [[50.0, 0.0], [0.0, 50.0]] u, v = sp.symbols('u v') w = (np.power(final_loc[0]-u, 2) + np.power(final_loc[1]-v,2))/20000 + \ 1e4 * (1/(sp.det(sp.Matrix(sigma))*2*np.pi) ) * sp.exp(-(1/2) * np.transpose([(u-mu[0][0]),(v-mu[0][1])]).dot( np.linalg.pinv(sigma).dot([(u-mu[0][0]),(v-mu[0][1])]))) + \ 1e4 * (1/(sp.det(sp.Matrix(sigma))*2*np.pi) ) * sp.exp(-(1/2) * np.transpose([(u-mu[1][0]),(v-mu[1][1])]).dot( np.linalg.pinv(sigma).dot([(u-mu[1][0]),(v-mu[1][1])])))

dx = sp.diff(w, u) dy = sp.diff(w, v) dz = sp.lambdify([u,v],w,'numpy')

x = list(np.arange(0.0, 104.0, 4.0)) y = list(np.arange(0.0, 104.0, 4.0)) x, y = np.meshgrid(x, y) z = dz(x,y)

fig1 = plt.figure() ax = fig1.add_subplot(projection='3d') ax.plot_wireframe(x, y, z, rstride=1, cstride=1, alpha = 0.5) ax.scatter(initial_loc[0],initial_loc[1], dz(initial_loc[0], initial_loc[1]),c = 'b',marker = '*',alpha = 0.8)

ax.text(initial_loc[0],initial_loc[1], dz(initial_loc[0], initial_loc[1]), " Source", color='red') ax.scatter(final_loc[0],final_loc[1], dz(final_loc[0], final_loc[1]),c = 'r',marker = '*',alpha = 0.8) ax.text(final_loc[0],final_loc[1], dz(final_loc[0], final_loc[1]), " Goal", color='blue') p = [] while not(cur_loc == final_loc) : if (cur_loc[0] > final_loc[0] or cur_loc[1] > final_loc[1]) : break dX = round_down(dx.evalf(subs = {u : cur_loc[0], v : cur_loc[1]}), 10) dY = round_down(dy.evalf(subs = {u : cur_loc[0], v : cur_loc[1]}), 10) d = sp.sqrt(dX**2 + dY**2) alpha = round_down(1/d, 10) cur_loc = list(cur_loc - (alpha * np.array([dX, dY],dtype ='float'))) cur_loc = [round_down(inx, 10) for inx in cur_loc] ax.scatter(cur_loc[0],cur_loc[1],float(w.evalf(subs = {u : cur_loc[0], v : cur_loc[1]})),c = 'g',marker = '*',alpha = 0.8) p.append(cur_loc) for i in p: print(i[0]) i[0] = (i[0] * steps[0]) + initial_location[0] i[1] = (i[1] * steps[1]) + initial_location[1] plt.show() return p

## Challenges

We had a lot of trouble with our GPS-Odin module. Odin (WiFi and Bluetooth) on the C099-F9P was programmed factory default on rover Bluetooth and was in silent mode that wouldn't allow us to communicate with it through AT-Commands. Therefore, connecting two GPS, one as Rover and the other as Base station to transmit correction signals took almost 2 weeks of work.

Also, programming the Artificial potential fields faced with lots of wired errors as the Sympy library still has some unknown bugs and figuring them out required extensive searching through the internet.

## Conclusion

Our car is capable of correcting its direction to move towards a specified GPS location using RTK2 corrections from base GPS-RTK within 1-10cm and avoiding larger objects. From our demo, we can see that the system is not robust enough to fully navigate to multiple locations while avoiding objects.

## Project Links

## Resources

- Robotic Motion Planning: http://www.cs.cmu.edu/~motionplanning/lecture/Chap4-Potential-Field_howie.pdf
- Autonomous and Mobile Robotics: https://www.dis.uniroma1.it/~oriolo/amr/slides/MotionPlanning3_Slides.pdf