Self driving robots is a very interesting area, as it includes many areas of knowledge.

  • Mechanics, you have to build the physical robot
  • Electronics you need to put electronic components together
  • Programming, logics needs to be built
  • Linux we need a small server (Raspberry PI) to host our programs
  • Machine learning to tech it to recognize
  • Message buss (similar to Kafka) to make sensors and controls units losly connected (Microservices/IOT Internet of things)

This project is using a cam jam/edukit 3 as a base and it contains

  • 2 Motors
  • Motor battery box
  • Motor driver board (to raspberry pi)
  • 1 HC-SR04 ultrasonic distance sensor
  • connector board

I have complemented this with a few more HC-SR04 sensors and a camera, more cables and more connection boards and ducktejp and dubbelsidig tejp

I have used the camjam box as the housing of my robot car, its not a butifull thing but as it is a box it is convenient to store things like battery, raspberry pi etc, a very simple first robot car

Used dubbelsidig tejp to fix the motor battery box under the box

On top of the batter box and added the front wheel and fixed it with dubbelsidig tejp

I attached the motors in the rare in same way and connected the wheels

Drilled a small hole for cables to the inside of the box, and used tejp to fixate the cables on the underside

Drilled 2 holes for the from sensor, it is possible to drill holes on the right and left from sides for the side sensors as well, I put mine on top for now

Peached everything together I will show some connection diagrams as well later.

Now we are ready to do some coding

I have used Robot Operating System ROS2 and python programming

  • One ros node that collect distance information and push the result on message queue (in ros world a message queue is called a topic)
  • A ros node is a micro series running independently but is sharing integration with queue and request response integration for communication between nodes.
  • My distance node generates a number of messages into multiple topics
  • frontdistance topic contains distance collected by from sensor
  • leftdistance topic contains distance collected by left sensor
  • rightdistance topic contains distance collected by right sensor
  • distance topic contains the lowest distance from any of the sensor
  • direction topic contain suggestion to avoid collision, if left side is to close then it sugest to turn right etc.

I have a second node called auto drive subscribing to direction events and is turning in the suggested direction

I will complement with a speed node that change speed dependent on how close we are.

You can find the code for this project on GitHub

So far it is doing ok, it hits the walls now and then, but is improving

Leave a Reply

Your email address will not be published. Required fields are marked *