Python Robotics Projects
eBook - ePub

Python Robotics Projects

Build smart and collaborative robots using Python

Prof. Diwakar Vaish

Partager le livre
  1. 340 pages
  2. English
  3. ePUB (adapté aux mobiles)
  4. Disponible sur iOS et Android
eBook - ePub

Python Robotics Projects

Build smart and collaborative robots using Python

Prof. Diwakar Vaish

DĂ©tails du livre
Aperçu du livre
Table des matiĂšres
Citations

À propos de ce livre

Leverage the power of Python to build DIY robotic projectsAbout This Book‱ Design, build, and stimulate collaborative robots‱ Build high-end robotics projects such as a customized personal Jarvis‱ Leverage the power of Python and ROS for DIY robotic projectsWho This Book Is ForIf building robots is your dream, then this book is made for you. Prior knowledge of Python would be an added advantage. What You Will Learn‱ Get to know the basics of robotics and its functions‱ Walk through interface components with microcontrollers‱ Integrate robotics with the IoT environment‱ Build projects using machine learning‱ Implement path planning and vision processing‱ Interface your robots with BluetoothIn DetailRobotics is a fast-growing industry. Multiple surveys state that investment in the field has increased tenfold in the last 6 years, and is set to become a $100-billion sector by 2020. Robots are prevalent throughout all industries, and they are all set to be a part of our domestic lives. This book starts with the installation and basic steps in configuring a robotic controller. You'll then move on to setting up your environment to use Python with the robotic controller. You'll dive deep into building simple robotic projects, such as a pet-feeding robot, and more complicated projects, such as machine learning enabled home automation system (Jarvis), vision processing based robots and a self-driven robotic vehicle using Python.By the end of this book, you'll know how to build smart robots using Python.Style and approachA simple step-by-step guide to help you learn the concepts of robotics using simple to advanced steps. You'll not only learn the concepts of AI, machine learning, and Vision Processing, but also how to practically implement them in your projects.

Foire aux questions

Comment puis-je résilier mon abonnement ?
Il vous suffit de vous rendre dans la section compte dans paramĂštres et de cliquer sur « RĂ©silier l’abonnement ». C’est aussi simple que cela ! Une fois que vous aurez rĂ©siliĂ© votre abonnement, il restera actif pour le reste de la pĂ©riode pour laquelle vous avez payĂ©. DĂ©couvrez-en plus ici.
Puis-je / comment puis-je télécharger des livres ?
Pour le moment, tous nos livres en format ePub adaptĂ©s aux mobiles peuvent ĂȘtre tĂ©lĂ©chargĂ©s via l’application. La plupart de nos PDF sont Ă©galement disponibles en tĂ©lĂ©chargement et les autres seront tĂ©lĂ©chargeables trĂšs prochainement. DĂ©couvrez-en plus ici.
Quelle est la différence entre les formules tarifaires ?
Les deux abonnements vous donnent un accĂšs complet Ă  la bibliothĂšque et Ă  toutes les fonctionnalitĂ©s de Perlego. Les seules diffĂ©rences sont les tarifs ainsi que la pĂ©riode d’abonnement : avec l’abonnement annuel, vous Ă©conomiserez environ 30 % par rapport Ă  12 mois d’abonnement mensuel.
Qu’est-ce que Perlego ?
Nous sommes un service d’abonnement Ă  des ouvrages universitaires en ligne, oĂč vous pouvez accĂ©der Ă  toute une bibliothĂšque pour un prix infĂ©rieur Ă  celui d’un seul livre par mois. Avec plus d’un million de livres sur plus de 1 000 sujets, nous avons ce qu’il vous faut ! DĂ©couvrez-en plus ici.
Prenez-vous en charge la synthÚse vocale ?
Recherchez le symbole Écouter sur votre prochain livre pour voir si vous pouvez l’écouter. L’outil Écouter lit le texte Ă  haute voix pour vous, en surlignant le passage qui est en cours de lecture. Vous pouvez le mettre sur pause, l’accĂ©lĂ©rer ou le ralentir. DĂ©couvrez-en plus ici.
Est-ce que Python Robotics Projects est un PDF/ePUB en ligne ?
Oui, vous pouvez accĂ©der Ă  Python Robotics Projects par Prof. Diwakar Vaish en format PDF et/ou ePUB ainsi qu’à d’autres livres populaires dans Computer Science et Hardware. Nous disposons de plus d’un million d’ouvrages Ă  dĂ©couvrir dans notre catalogue.

Informations

Année
2018
ISBN
9781788837149
Édition
1
Sous-sujet
Hardware

Recognizing Humans with Jarvis

By now we have understood in the last chapter how multiple layers of conditions can be clubbed together to get the functionality that is desired. We have just completed the first step in making Jarvis work for you. Now, it's time to make it even more capable.
In this chapter, we will make it control more electronics at your home, which can be controlled autonomously without you telling anything to the system. So without delay, let's get straight into it and see what we have in our bucket.

Turn on the light Jarvis

One of the basic functionalities of a smart home is to turn on the lights for you whenever you are around. It is one of the most basic things that any system can do for you. We will start off by turning on the light as soon as you come inside the room, thereafter, we will make the system more and more intelligent.
So, the first thing we need to do is recognize whether you are in a room or not. There are multiple ways to do that. One important characteristic of life is the presence of movement. You may say plants don't move, well they do; they grow, don't they? So detecting movement can be a key step in detecting whether someone is there or not!
This step will not be so difficult for you, as we have already interfaced this sensor previously. We are talking about the good old PIR sensor. So the sensor will sense any movement in the area. If there is any movement, then Jarvis will switch on the lights. I am sure this is something you can do by yourself by now. You can still refer to the code and the circuit diagram here:
Now upload the following code:
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
PIR = 24
LIGHT = 23
GPIO.setup(DOPPLER,GPIO.IN)
GPIO.setup(BUZZER,GPIO.OUT)
While True:
if GPIO.input(PIR) == 1:
GPIO.output(LIGHT,GPIO.HIGH)
if GPIO.input(PIR) == 0:
GPIO.output(LIGHT,GPIO.LOW)
In the preceding code, we are simply turning on the light as soon as the motion is detected, but the problem is that it will only switch on the light for the time the motion is there. What does that mean? Simple, while there is some movement, will keep the lights on and as soon as the movement stops, it will switch off the light.
This can be a very good code for a person who wants to lose weight, but for most of us, it will be annoying. So, let's include a small loop, which we have used in the previous chapter and make this a little better:
import RPi.GPIO as GPIO
import time

GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)

PIR = 24
LIGHT = 23
TIME = 5

GPIO.setup(PIR,GPIO.IN)
GPIO.setup(BUZZER,GPIO.OUT)

While True:

If GPIO.input(PIR) == 1:

M = datetime.datetime.now().strftime('%M')
M_final= M + TIME

for M < M_final:

GPIO.output(LIGHT,GPIO.HIGH)
M = datetime.datetime.now().strftime('%M')

if GPIO.input(PIR) == 1:
M_final = M_final + 1



if GPIO.input(PIR) = 0:

GPIO.output(LIGHT, GPIO.LOW)}
So, in this program, all we have done is we have added a for loop, which switches on the light for a set amount of time. How long that time will be can be toggled by changing the value of the variable TIME.
There is one more interesting part in that loop which is as follows:
 if GPIO.input(PIR) == 1
M_final = M_final + 1
Why did we do this you might wonder? Whenever the light will be switched on, it will remain on for 5 minutes. Then, it will switch off and wait for movement to occur. So, essentially, the problem with this code will be that if you are in the room and the light switches on, then for 5 minutes it will see if there is any motion detected or not. There is a chance that you will be in motion when it searches for the motion after 5 minutes. But for most of the time, it won't be the case. So we are detecting the movement using the PIR sensor. Whenever movement is detected, the value of M_final is incremented using the line M_final = M_final + 1, thereby increasing the time until which the light will be switched on.

Understanding motion

By now you must have figured that the PIR sensor is not the most idealistic sensor for us to switch the lights on or off. Mostly because, although the motion is one of the best indicators of presence, there can be times when you might not move at all, for example, while resting, reading a book, watching a movie, and so on.
What do we do now? Well, we can do a little trick. Remember in the last chapter we used our proximity sensor to sense whether a person has crossed a specific area or not? We will implant a similar logic here; but rather than just copy pasting the code, we will improve it and make it even better.
So rather than using one single IR proximity sensor, we will be using two of these things. The mounting will be as shown in the following diagram:
Now it is very evident that whenever a person walks in from the door side to the room side the Sensor 1 will show a lower reading when detecting a body. Then, while he is walking towards the room side, Sensor 2 will show a similar reading.
If first Sensor 1 is triggered and thereafter Sensor 2 is triggered, then we can safely assume that the person is travelling from the door side to the room side. Similarly, if the opposite is happening, then it is understood that the person is walking out of the room.
Now, this is fairly simple. But how do we implement it in a real-life situation? Firstly, we need to connect the circuit as follows:
Once that is done, upload the following code:
import GPIO library
import RPi.GPIO as GPIO
impor...

Table des matiĂšres