Introduction: Beginner's Self-Driving Robotic Vehicle With Collision Avoidance

Hello! Welcome to my beginner-friendly Instructable on how to make your own self-driving robotic vehicle with collision avoidance and GPS Navigation. Above is a YouTube video demonstrating the robot. It is a model to demonstrate how a real autonomous vehicle works. Please note that my robot will very likely look different from your final product.

For this build you will need:

- OSEPP Robotic Functional Kit (includes bolts, screwdrivers, cables, etc.) ($98.98)

- Arduino Mega 2560 Rev3 ($40.30)

- HMC5883L Digital Compass ($6.99)

- HC-SR04 Ultrasonic Sensor ($3.95)

- NEO-6M GPS and Antenna ($12.99)

- HC-05 Bluetooth Module ($7.99)

- USB Mini B Cable (You may have this lying around) ($5.02)

- An Android smartphone

- Six AA batteries, 1.5 Volts each

- Any rod-like non-magnetic material (like aluminum) you would like to recycle

- Double-sided tape

- A hand drill

Step 1: Assembling the Robot's Chassis and Mobility

Explanation: It's not a vehicle if it doesn't budge! The most basic robotic vehicle requires wheels, motors, and a chassis (or the "body" of the robot). Instead of acquiring each of these parts separately, I highly suggest buying a kit for a starter robotic vehicle. For my project, I used the OSEPP Robotic Functional Kit because it came with a plethora of parts and available tools, and I felt a tank configuration was best for the stability of the robot, as well as simplifying our programming by requiring only two motors.

Procedure: It would not be helpful to you if I simply repeated the assembly manual, which you can find here (you also have the option of a triangular tank configuration). I would just advise to keep all cables as close to the robot as possible and away from the ground or the wheels, particularly for the cables from the motors.

If you would like a budget option over buying an expensive kit, you could also recycle an old, working RC car and use the motors, wheels, and chassis from that, but I am not sure how compatible the Arduino and its code be to those particular parts. It's a better bet to pick the kit by OSEPP.

Step 2: Incorporating Arduino

Explanation: Because this is a beginner's guide, I would like to quickly explain what Arduino is for any readers who may be unfamiliar with its use in electronics. An Arduino is a type of microcontroller, which means it does exactly that -- controlling the robot. You can write instructions in code on your computer that will be translated to a language that the Arduino can understand, then you can upload those instructions into Arduino, and the Arduino will immediately begin attempting to execute those instructions when it's turned on. The most common Arduino is the Arduino Uno, which is included in the OSEPP kit, but you will need the Arduino Mega for this project because this is a larger scale project than what the Arduino Uno is capable of. You can use the kit's Arduino Uno for other fun projects.

Procedure:The Arduino can be attached to the robot by using zip-ties or screwing in spacers onto the base of the robot.

We would like the Arduino to control the motors of our robot, but the motors cannot connect to the Arduino directly. Therefore, we need to attach our motor shield (which came from our kit)on top of the Arduino to be able to form a connection with the motor cables and the Arduino. The pins coming from the bottom of the motor shield should fit right into the "holes" of the Arduino Mega. The cables extending from the motors fit into slots on the motor shield like the image above. These slots are opened and closed by spinning a screwdriver into a + shaped indent at the very top of the slot.

Next, the Arduino needs voltage in order to work. The OSEPP Robotic Functional Kit should have come with a battery holder fit for six batteries. After inserting six batteries into the holder, insert the wires extending from the battery holder into the slots on the motor shield meant for voltage.

Step 3: Adding Bluetooth Control

Procedure: After the Arduino is figured out, adding the Bluetooth module is as easy inserting the four prongs of the Bluetooth module into the four-holed slot on the motor shield, as shown above.

Incredibly simple! But we're not done. The Bluetooth module is only half of the actual Bluetooth control. The other half is setting up the remote app on our Android device. We will be using the app developed by OSEPP that is meant for the robot assembled from the Robotic Functional Kit. You could use a different remote app on your device, or you could even make your own, but for our purposes, we don't want to reinvent the wheel. OSEPP also has instructions on how to install their app, which cannot be installed from the Google Play store. You can find those instructions here. The layout of the remote you install may look different from the tutorial, and that is fine.

Step 4: Adding Collision Avoidance

Explanation: Now that the robot is mobile, it is now capable of running into walls and large objects, which can potentially damage our hardware. Therefore, we are incorporating our ultrasonic sensor at the very front of the robot, just like you see in the image above.

Procedure: The OSEPP Robotic Functional Kit includes all the parts you see there, except for the ultrasonic sensor. When you assembled the chassis by following the instruction manual I had linked, you should have already built this holder for the ultrasonic sensor. The sensor can simply by popped into the two holes of the holder, but you should hold the the sensor in place with a rubber band to prevent it falling off the holder. Insert a cable that fits all four prongs on the sensor and connect the other end of the cable to the column 2 of pins on the motor shield.

You can include multiple ultrasonic sensors, provided you have the hardware to hold them in place.

Step 5: Adding a GPS and Compass

Explanation: We have almost completed our robot! This is the most difficult part of assembling our robot. I would like to first explain the GPS and the digital compass. The Arduino refers to the GPS to collect satellite data of the robot's current location, in terms of latitude and longitude. This latitude and longitude is put into use when paired with readings from the digital compass, and these numbers are put into a series of mathematical formulas in the Arduino to calculate what movement the robot should make next to reach its destination. However, the compass is thrown off in the presence of ferrous materials, or materials containing iron and are therefore magnetic.

Procedure: To mitigate any potential interference from ferrous components of our robot, we will be taking our rod-like aluminum and bend it into a long V-shape, like in the image above. This is to create some distance from ferrous materials on the robot.

Aluminum can be bent by hand or using a basic hand tool. The length of your aluminum does not matter, but make sure the resulting V-shape aluminum is not overly heavy.

Use the double-sided tape to stick the GPS module, the GPS antenna, and the digital compass onto the aluminum fixture. VERY IMPORTANT: The digital compass and the GPS antenna should be placed at the very apex of the aluminum fixture, as shown in the image above. Also, the digital compass should two arrows in an L-shape. Make sure the x-arrow points to the front of the robot.

Drill holes on both ends of the aluminum so a nut can be screwed though the aluminum and a hole on the robot chassis.

Plug the digital compass cable into the Arduino Mega, in the small "outlet" right below the voltage slot on the motor shield. Connect the a cable from the spot on the GPS labeled "RX" to pin TX314 on the Arduino Mega (not on the motor shield), another cable from the spot labeled "TX" to pin RX315, another cable from "VIN" on the GPS to the 3V3 pin on the motor shield, and a final cable from "GND" on the GPS to the GND pin on the motor shield.

Step 6: Bringing It All Together With Code

Procedure: It is time to give our Arduino Mega the code I have already prepared for you. You can download the Arduino application for free here. Next, download each of the files I have below (I know it looks like a lot, but most of these are very tiny files). Now, open MyCode.ino, the Arduino application should open, then at the top click Tools, then Board, and finally Arduino Mega or Mega 2560. After that, at the top, click Sketch, then Show Sketch Folder. This will open the file location of MyCode.ino on your PC. Click and drag all the other files you've downloaded from this Instructable into the MyCode.ino file. Go back to the Arduino application and click on the checkmark at the top right so the program can translate the code into machine language the Arduino can understand.

Now that you have all the code ready, connect your PC to the Arduino Mega using your USB Mini B cable. Go back to the Arduino Application with MyCode.ino open and click on the rightward arrow button at the top right of the screen to upload the code into the Arduino. Wait until the application tells you the upload is complete. At this point, your robot is done! Now we need to test it.

Turn on the Arduino by using the switch on the motor shield, and open the OSEPP remote app on your Android device. Make sure the Bluetooth module on the robot is flashing a blue light, and select the Bluetooth connection upon opening the app. Wait for the app to say it has connected to your robot. On the remote, you should have the standard left-right-up-down controls on your left, and A-B-X-Y buttons on the right. With my code, the X and Y buttons don't do anything, but the A button is to save the robot's current latitude and longitude, and the B button is for the robot to begin moving to that saved location.Make sure the GPS has a blinking red light when using the A and B buttons. This means the GPS has connected to satellites and is collecting data, but if the light is not flashing, simply take the robot outside with direct view of the sky and wait patiently. The circles at the bottom are meant to be joysticks, but are not used in this project. The middle of the screen will log info about the robot's movements, which was useful during my testing.

Thank you so much to OSEPP, as well as lombarobot id and EZTech on YouTube for providing me the groundwork for writing code for this project. Please support these parties:

OSEPP

EZTech Channel

lombarobot id channel


Step 7: Optional Expansion: Object Detection

In the beginning of this Instructable, I mentioned that the image of my robotic vehicle you saw at the very beginning will look different from your finished product. In particular, I'm referring to the Raspberry Pi and camera that you see above.

These two components work together to detect stop signs or red stop lights in the robot's path and stop temporarily, which make the robot a closer model to a real autonomous vehicle. There are several difference applications of the Raspberry Pi that can apply to your vehicle. If you would like to work on your robotic vehicle further by including the Raspberry Pi, I highly recommend purchasing Rajandeep Singh's course on building a self-driving, object-detecting vehicle. You can find his complete course on Udemy here. Rajandeep did not ask me to shout out his course; I simply feel he his a wonderful instructor who will engage you in autonomous vehicles.

Thank you very much for reading my Instructable!