Reader small image

You're reading from  Python Robotics Projects

Product typeBook
Published inMay 2018
Reading LevelIntermediate
PublisherPackt
ISBN-139781788832922
Edition1st Edition
Languages
Concepts
Right arrow
Author (1)
Prof. Diwakar Vaish
Prof. Diwakar Vaish
author image
Prof. Diwakar Vaish

Prof. Diwakar Vaish is a robotics scientist and the inventor of Manav (India's first indigenous humanoid robot), the world's first mind-controlled wheelchair, brain cloning, and the world's cheapest ventilator. He has also been a guest lecturer at over 13 IITs and various other institutions. He is the founder of A-SET Robotics, a leading robotics research company based in New Delhi.
Read more about Prof. Diwakar Vaish

Right arrow

Chapter 8. Making Your Own Area Scanner

Motors are amazing things; they come in all shapes and sizes. Primarily, they can be considered the backbone of most robots. However, nothing is perfect in this world. There must be some drawbacks to these motors as well. By now, you might have figured out some by yourself. In the previous chapter, when we made the car turn, you might have seen that the angle of turn was never really the same. Also when the vehicle was given the command to go straight, it really would not do so. Rather it would try to run slight, toward one side. 

Say hello to the first problem—precision. The motors are exceptionally simple to control, but the problem with these motors come when we have to rotate the motors only till a specific angle. If you need to rotate the motor of your robotic vehicle only by 90 degrees, then how would you do it? The first and foremost thing that might come to your mind would be to fiddle with the timings of the motors. You might be right here...

Servo motor


So, let me introduce you to servo motor. Servo motor is basically a motor with a few added components. Now to understand what those added components, let's first go through this example. Let's say that you want to go to London. Now to see how you have to go there and what would be the route to reach London, the first thing you need to know is that where exactly you are now. If you don't know where you are currently, it is impossible to calculate a route. Similarly, if we want to reach a certain position of motor, we need to know where the shaft of the motor is standing right now. To do this, we use a potentiometer. A potentiometer is basically a variable resistor that essentially has a shaft that when rotated changes the value of resistance. A variable resistor looks like this:

When the value of resistor change, then the output voltage from the resistor will also change. The interesting thing is that if the input voltage to the potentiometer is well known, then the output voltage...

Lists


All right then, we are quite sure on how to use the servo and have a controlled motion as per our needs. Now it's time to move forward and understand another concept that we would be using greatly. It's named arrays. If you have programmed in any other language, you must be familiar with it. But we need to understand a few basics concepts of it, which will make our lives a lot easier. So, let's get started.

First things, first. Arrays in Python are not named arrays, rather it is named as lists. List is basically a data structure that can store multiple elements at the same time. The only limitation being is that the elements must be of the same data type. Such as if you are storing integers, then all the values should be int. Similarly, if you are storing a character, then every element of the list should be char. To define a list, all you need to do is name the list such as we have done by doing myList; the name of the list could be anything next we need to tell the compiler that it...

Looking around 


Okay then enough of movie quotes. We can talk about many other functions that we can use over lists, but what we have done is enough for now. We will see the rest of them as the need arise. But for now let's take the things a step further in robotics. You might have seen a rotating object on top of many autonomous cars. The production cars generally don't tend to have primarily due to its high price, but research purpose cars are always loaded with it.

So what is this device? It's named LIDAR; it is an acronym for Light Detection and Ranging. I know bad acronym. There is a reason for LIDAR to be very common. It gives distance reading of the areas around it in a very precise way. However, buying it for our projects would slightly overkill as a good one would cost you close $500 to $10,000. If you still think that it's in your budget, then you would be very lucky! But for those who don't want to buy it. I have a good news for you. Today, we are going to build our own LIDAR scanner...

LIDAR on an autonomous vehicle 


Remember the last time we made autonomous car. It was cool, and surely it might be something you can show off to your friends. However, now what we are about to make is surely cooler than anything we have ever done till now.

We are going to put this area scanner over our robotic vehicle. But wait, didn't we scan the area earlier using the same sensor and turning the car to other sides. We did it and it worked fine, almost fine. I bet sometimes it wasn't as accurate as you thought it would be. But that's not the real problem. The main problem is that it was not seamless. It has to stop in between check for spaces and then move in either direction. What we are going to do now is something that is a step ahead. So before doing any more explanation, let's go ahead and make this new robotic vehicle and then you be the judge to decide whether it is cooler. 

So, to make it, you need to mount the area scanner on the vehicle. It's advisable that you set it up at the...

Summary


Professional laser scanners are super expensive, so, in this chapter, we went on to build an alternative by ourselves and mounted it on our vehicle. In the next chapter, we will cover topics such as vision processing, and object detection, object tracking, which will enable us to do basic vision processing and to make the car move in the direction of a specific object such as a ball.

 

lock icon
The rest of the chapter is locked
You have been reading a chapter from
Python Robotics Projects
Published in: May 2018Publisher: PacktISBN-13: 9781788832922
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime

Author (1)

author image
Prof. Diwakar Vaish

Prof. Diwakar Vaish is a robotics scientist and the inventor of Manav (India's first indigenous humanoid robot), the world's first mind-controlled wheelchair, brain cloning, and the world's cheapest ventilator. He has also been a guest lecturer at over 13 IITs and various other institutions. He is the founder of A-SET Robotics, a leading robotics research company based in New Delhi.
Read more about Prof. Diwakar Vaish