Semi-autonomous Car for Smart City is a four wheeler which is remotely controlled but with a real experience of driving a real car.
The carrier consist of numerous GROVE sensors and Raspberry Pi to control the car with any distance of separation(between the driver and the car) with Samsung Artik IoT Cloud.
Building the Car:
1. Building the Chassis:
Assemble the chassis kit with the chassis building kit(as in the picture).
Your built Chassis kit can be one like -
https://www.google.co.in/search?q=remote+car+chassis&newwindow=1&safe=active&biw=1280&bih=598&source=lnms&tbm=isch&sa=X&ved=0ahUKEwj8lrLNuc_PAhWKtY8KHZxpDPAQ_AUICCgB#imgrc=_
https://www.microsoft.com/en-us/store/p/media-beamer/9wzdncrdcbxb
2. Live Streaming:
The car is fitted a phone. I have used a Windows Phone with 'Media Beamer' App installed in it. Other phone users can get a App with similar capabilities.
Put on Wifi in the phone. And click -> start -> Camera. It gives an IP Address of a link in which the live stream of the phone camera runs. Enter the IP Address on the Laptop(or any mobile device) to get the front view as positioned from the chassis.
3. Raspberry Pi:
* Setup the Raspberry Pi with Raspbian Setup installed.
https://www.raspberrypi.org/downloads/raspbian/
* Connections in Raspberry Pi
Setting Up Ultra Sound :
The ultrasound Module is connected to the Rpi and power up the Board. Connect a wifi module to it.
import RPi.GPIO as gpio
import time
def distance(measure='cm'):
try:
gpio.setmode(gpio.BOARD)
gpio.setup(12, gpio.OUT)
gpio.setup(16, gpio.IN)
gpio.output(12, False)
while gpio.input(16) == 0:
nosig = time.time()
while gpio.input(16) == 1:
sig = time.time()
tl = sig - nosig
if measure == 'cm':
distance = tl / 0.000058
elif measure == 'in':
distance = tl / 0.000148
else:
print('improper choice of measurement: in or cm')
distance = None
gpio.cleanup()
return distance
except:
distance = 100
gpio.cleanup()
return distance
if __name__ == "__main__":
print(distance('cm'))
Ensure that the Connection Pins are same as that entered in the code.
Here is how the ultrasound sensor estimates the distance.
Samsung Artik Cloud:
1) Device
2) Application
3) Manifest and Connected Device:
import RPi.GPIO as gpio import
time import sys import
Tkinter as tk
from sensor import distance
def init():
gpio.setmode(gpio.BOARD)
gpio.setup(7, gpio.OUT)
gpio.setup(11, gpio.OUT)
gpio.setup(13, gpio.OUT)
gpio.setup(15, gpio.OUT)
def forward(tf):
gpio.output(7, False)
gpio.output(11, True)
gpio.output(13, True)
gpio.output(15, False)
time.sleep(tf)
gpio.cleanup()
def reverse(tf):
gpio.output(7, True)
gpio.output(11, False)
gpio.output(13, False)
gpio.output(15, True)
time.sleep(tf)
gpio.cleanup()
def turn_left(tf):
gpio.output(7, True)
gpio.output(11, True)
gpio.output(13, True)
gpio.output(15, False)
time.sleep(tf)
gpio.cleanup()
def turn_right(tf):
gpio.output(7, False)
gpio.output(11, True)
gpio.output(13, False)
gpio.output(15, False)
time.sleep(tf)
gpio.cleanup()
def pivot_left(tf):
gpio.output(7, True)
gpio.output(11, False)
gpio.output(13, True)
gpio.output(15, False)
time.sleep(tf)
gpio.cleanup()
def pivot_right(tf):
gpio.output(7, False)
gpio.output(11, True)
gpio.output(13, False)
gpio.output(15, True)
time.sleep(tf)
gpio.cleanup()
def key_input(event):
init() print 'Key:', event.char
key_press = event.char
sleep_time = 0.030
if key_press.lower() == 'w':
forward(sleep_time)
elif key_press.lower() == 's':
reverse(sleep_time)
elif key_press.lower() == 'a':
turn_left(sleep_time)
elif key_press.lower() == 'd':
turn_right(sleep_time)
elif key_press.lower() == 'q':
pivot_left(sleep_time)
elif key_press.lower() == 'e':
pivot_right(sleep_time) else: pass
curDis = distance('cm')
print('curdis is',curDis)
if curDis < 20:
init()
reverse(2)
command = tk.Tk()
command.bind('<KeyPress>', key_input)
command.mainloop()
Setup up manifest and create actions and rules.
For tutorial visit - https://developer.artik.cloud/documentation/tutorials/
Scope:
1. To access areas which are non-accessible by human beings.
2. Crazy electronic car.
3. Secure goods transporter.
And much more…
Comments