Autonomous Car – Week 11


Late submission, forgot about it but here it is

Abdiqani: 

This week I have been working on the integration of the car and unity. For most part of the week, I have tried installing a Bluetooth plugin that would allow me to use Bluetooth to send data between the car and unity like this one. 

https://github.com/dhfmzk/UnityBluetoothPlugin

Doing it this way was very difficult and I got advice from Steven to try and use the Unity terminal to receive data instead. I got two script that he had written before that didn’t need to be changed other than to erase some of the code that was not necessary. The first script handles the serial communication system while the other initialized and terminates the serial communication.  

Script 1: 

Script 2: 

The make code is very simple, I just setup some blocks with serial communication. I set up the micro bit in Arduino and tested it, and later on unity and this is how it looks like. 

https://youtu.be/XxWsO2V0wEA

After that I tried to make communication between two micro bits. I got one from Henning and the other was the one from Ghebre’s car. By using the radio block in makecode, I  made a code that would send and receive messages between two micro bits. 

These are the 2 codes, one for car and the other for communication with unity, the only difference is that the one for unity writes to the serial port. The codes set’s both micro bit’s in the same radio group for them to be able to communicate. 

In the video below the micro bit connected to my pc uses serial port while the other only display the text. 

https://youtu.be/rIZbLwyUhCg

Ghebre: 

This week I added one more line sensor to the car, and I displaced all the line sensors from the middle underline to the front of the car. It gives me a better way of observing whether the lines are on the black line or outside of the line. The line sensors are more sensitive.  

I discovered one thing though while the car drives one the floor it gives a signal that says its still on the black line when its off the black tape line. There for, I had to tune the IR sensors so that could give a the right output of either 0 or 1.  

The better way to see if the algorithm works, I bought white and black tape and then I made lines of white-black-white. The algorithm says if all sensors are equal to 1 then drive the car forward, but if the right sensor is on the white tape, then it has to drive slightly to the left and vise versa, but if all sensors are equal to 0 then it has reached it stop line. 

Algorithm for line-sensor 

Function for slight turning 

Planning 

I implemented more functions so the car could have more possibilities of choices, while driving. For instance, while driving the car could sense using all three sensors which covers front, left and right side of the environment, and at the same time the car could follow the line.  

I discovered that PID controller gives the car to drive fast. First, I start by controlling the one motor at a time. That is because when I was trying to maintain all the wheels at the same time it was difficult to understand which wheel is not working properly.  

  • Thinking to implement different Class and subclasses functions. 
  • A class for motor. 
  • Controlling each wheel. 


Leave a Reply