• 987 words

Path Follower: Arduino+Rasp on ROS

We've created a path follower and maze solver robot car with, arduino, raspberry, ROS, Vrep and a bunch of other stuff

A natural shrub maze
Photo by Karolina Kołodziejczak / Unsplash

Without considering the headaches and insomnia that the university gave me in this exams session, due to the overwork I did, I’m here to tell you about one of our 4 projects of this semester that we successfully delivered, the Intelligent systems and Robotics laboratory’s one. I and my group have chosen this course and put it in our study plan because seemed something we could have fun with. In the project, we basically learned python 3 and its OOP paradigm, V-REP, and other robotic simulation tool and we also made a little written exam on Prolog: a very particular language that I hate from the deep of my heart. So when the time of choosing a project arrived, I tried to join my knowledge of Arduino with all the things we did in the course in order to build something to deliver that could follow the project’s requirements of the course.
You can find all the developed code in my repo.

Where everything started

Everything started from this video I stepped on. At the end of it, I and my teammate Gianluca were too enthusiastic about the idea of creating a robot like that… so we went for it. We decided to go with Arduino, a board that I’ve already used in the past, and we bought this car kit on Amazon to have something to start with.

Parts used

There is an “as known as” in this paragraph’s title for a specific reason. This is not a guide to building the car we built, as I always said, this is just a blog where I talk about my projects, my hobbies, and my accomplishments. I always like to share what I do, but this time I didn’t have the necessary time to write down the steps done to get the stuff working. For example, all the raspberry configuration and the installation of mate, Pyswip for prolog, ROS, arduino_rosserial, CouchDB, and tons of other stuff, haven’t been an easy task. Of course, I’ll leave you some resources where I got some hints but the rest is up to you.

Let’s go to the list of the stuff we used:

  1. An Arduino car kit that includes lots of stuff as you can see in the link I put above
  2. A Raspberry
  3. A power bank to power the Raspberry
  4. A Buzzer and a resistor to play some notes

Building the car

We started with building physically the car:

Coding

Then I decided to go straight to the Arduino code leaving at the end the Python ROS code of Raspberry. So here I was trying to set up properly the sensors:

And here I and Gianluca could finally make the 90° curves work (this was the hardest part because we stressed the architecture of this car considering that performing 90° curves with only three sensors and a 4 wheel car is not easy task honestly).

Then we took this code we wrote in Arduino and we split the logic into multiple functions. I set up a ROS node on it (through the rosserial_arduino library) and we made publish the Arduino node the sensors reading and subscribed to some raspberry’s call for those split functions. So we set up a ROS node on the Raspberry too with the official ROS library in Python and subscribed to Arduino in order to get sensors reading and to publish signals in order to make it execute those split functions. This isn’t the best approach. It would have been better to build directly all the code in Python on the Raspberry, but for lack of time, we ended up doing it in this way.

And this is the final result:

Curiosity: the way we resolved the “maze” is the same as the first video we saw. It’s basically a depth-first visit of a tree, from left to right (so we give precedence to a left turn if we have one, otherwise we go straight, otherwise we turn right).

Problems

For all of you that are thinking to build this thing (or a similar one), I’d tell you to not buy our kit. We’ve been very limited to the intrinsic structure of our car and here I collect the three main problems we encountered.

  • Our vehicle has 4 wheels and having bought it as a kit, we couldn’t in any way adjust it to use just 2 of them like in the V-REP simulation. Why 2 wheels are better? Because rotating in the curves with two wheels, let you rotate without going to touch any new black line with the sensors.
  • The grip of the wheels, sometimes, is missing (even on the board, where the surface is somehow rough) because it’s actually a problem of weight balance on the machine.
  • There are only three sensors on the car and this limited us a lot! The algorithm to handle this situation wouldn’t have been so complicated if we had 2 more sensors.

To solve all these problems we came up with an algorithm full of timers and this is the reason why you see it a little bit glitchy during the run on the path.

Resources

Some useful resources about ROS and the configuration of the raspberry follow:

Conclusion

I hope you liked this little robotic work. In general, as always, we could have done better than this. Especially the ROS python code could have been improved a lot. Sadly I had too much stuff going on and I had to close this project soon, so this is what we accomplished at the end.

Keep rocking 🤘