Robotics with Python | Understanding Raspberry Pi

Contents

Introduction

Robotics: the futuristic field of work in which machines can be mistaken for a man. Robotics is, and it will be for a long time, one of the most life-changing fields of information technology. It is believed that the field of robotics will be one of those that will have the most severe impact on humans in the long term. The only uncertainty left in the air is whether this impact will bring a positive change to the world or an inevitable regret.. Nowadays, there are more than five hundred programming languages, but nevertheless, when it comes to robotics, only a few possess the computational power.

The best programming languages ​​in use today are (may be subject to change) Python, C ++ and Java. This article will talk about the use of Python for robotics in the fourth industrial revolution.

gettyimages-1184804468-789x432-1168138

Source: IoT World Today

General description: What is python?

Python is a popular high-level programming language that can be used to create scripts and develop applications for desktop computers., World Wide Web, machine learning, data science and much more. Python's father is Guido Van Rossum. Python is a
versatile language and is used by many organizations and platforms around the world.

Examples of companies and corporations using Python include, among others, Google, Netflix, Instagram, Facebook.

Robotics and basic disciplines.

In simple terms, robotics is a specialized study that involves the combination of science techniques, engineering, electronics and art. The impact of robotics is growing as more companies try to gain a competitive advantage in the workplace. The fields that make up robotics are known as the “core disciplines”. Robotics is said to be made up of four (4) main disciplines. These are Electrical Engineering, Mechanical Engineering, Computer Science and Arts. Let's have a brief discussion on each basic discipline. It is crucial to know that to be involved in the field of robotics, you don't need to be an expert in all the basic disciplines; a basic understanding of arts and electrical engineering will suffice.

1. Electric engineering: Electrical Engineering is the specialized study of active electronic circuits such as refrigerators, transistors, etc. together with other relevant electrical interconnections. Electrical interconnections can refer to circuits, test plates, Arduinos and any electrical connections that when put together form a working system. It is interesting to know that there is a difference between electrical and electronic systems.

Will see, electrical systems use electrical current or electricity to power an output device, like a light bulb or a doorbell. Now, with electronics, the functionality of these electrical systems goes one step further. Having said that, with electronics, we can be allowed to alter the current flow that the bulb receives, which gives us the ability to “attenuate” O “lighten” the light bulb.

2. Mechanical Engineering: The Discipline of Mechanical Engineering in its most complex form will combine knowledge of Physical Sciences (Physics), Math, Materials Science and Design. Mechanical Engineering focuses on taking the design plans of an object and turning it into a real product. Mechanical engineering, when combined with electronics, is called "mechatronics". The main goal of mechatronics is to make an operating system much more sophisticated and optimized by integrating artificial intelligence into it..

3. computer's science: Following what we have commented up to this point, we can create a robot that has physical form, but nevertheless, the robot will not be functional. This is mainly because our robot is in a form “static”. It will stay that way until an internal instruction is received. The discipline of computer science is what provides each part of the robot with the instructions to perform a certain task. Instructions will need to be integrated into a microcontroller by programming.

4. Letters: Each object is attractive in its own way, and Robots must be no different if they are to live among humans in the future. This discipline focuses solely on creating an aesthetically pleasing robot. The robot must be integrated into the environment and must be entertaining. A Robot must not fail to attract an audience of few beings.

The brain of a robot

The brain of a robot is what controls it. Robots can be controlled externally, for instance, via a joystick or controller and are called “brainless robots”. Conversely, some robots can be controlled from within, using a microcontroller that is the center of all activity.

A microcontroller is like a central processing unit in that it is also responsible for monitoring and controlling all machine activity.; and differs in size, price and processing power. But nevertheless, microcontrollers are designed to accommodate lower-level hardware. When you select a microcontroller to buy, it is recommended that you choose one that contains an internal flash or has EEPROM (programmable and electrically erasable read-only memory). To maximize your knowledge of the microcontroller, you must also identify what architecture it is based on. May be based on Von Neumann architecture or Harvard architecture.

5505123-5856887

Source: Cool Wallpaper- WallpaperDog

Understanding the Raspberry Pi

The Raspberry Pi is a small computer the size of a bank card. This laptop runs on a build of Raspbian on a Linux operating system. It is interesting to know that “Raspbian” It is a special version of the Linux operating system that was specifically designed for the Raspberry Pi. The Raspberry Pi is built on the Broadcom processor. There are several types or variants of the Broadcom processor that are available for purchase., as BCM2835, BCM2836, BCM2837, etc. A Broadcom processor can be called “System processor on a chip”. One will find that from one generation to another, specifications will vary, as the number of integrated ARM processors, the graphics card, the set of instructions that the chip follows and much more.

The main aspect of the Raspberry Pi that will allow us to enjoy the field of robotics are the GPIO pins found on the raspberry pi. GPIO stands for General Purpose Input Output Pins. These GPIO pins serve as a means for us to integrate components with the Raspberry Pi. Total, there is 40 (forty) general purpose input and output pins, and they all have different functionalities. A brief explanation of the general purpose of these pins is as follows:

  • the red pins are used as power plugs, that will turn on any component or device to which a connection is made. The power for these pins comes directly from the Raspberry Pi itself.
  • the black pins They have the same functionality as the red pins, namely, power pins.
  • the pink pins serve as serial peripheral pins. These pins can be used to connect the raspberry pi to external microcontrollers like an Arduino.
  • the blue pins allow us to have multiple slave devices connected to the Raspberry Pi, thus establishing larger connections and communications.
  • the green pins They are in charge of carrying out the instructions of the Raspberry Pi.

At the conclusion of this article, now i will show and discuss a short python script that has the potential to turn an LED light on and off, making sure the bulb is connected to the GPIO pins on the Raspberry Pi.

# First we will need to make sure that the Python Library is installed on our
# Raspberry Pi. We will also need to make sure that we have a secure Internet
# Connection established

$ sudo apt-get install python-rpi.gpio python3-rpi.gpio
# We begin by importing the necessary packages
# First we import the Raspberry Pu GPIO Package
# Thereafter we import the sleep method from the time package

import RPi.GPIO as GPIO
from time import sleep
# We configure our system and script to temporarily
ignore all warnings
GPIO.setwarnings(False)
# We configure the pins on our Raspberry Pi, hence utilizing the physical
# GPIO pin numbering

GPIO.setmode(GPIO.BOARD)
# We are using pin number 8 and we are setting it to be the output pin
# the initial current level in this pin is low

GPIO.setup(8, GPIO.OUT, initial=GPIO.LOW)
# Now, in order to blink a bulb, we will need to allow current to pass
# Temporarily and thereafter cut all current flow. This is done as follows
# The use of a while loop tells us that our program will run forever

while True:
# Step 1: Turn on the LED bulb
 GPIO.output(8, GPIO.HIGH) # We set output pin number 8 to high current

to sleep (1.5) # We stop all activity during 1.5 seconds

# Step 2: Turn off the LED bulb
 GPIO.output(8, GPIO.LOW) # We set output pin number 8 to a low current
 sleep(1.5) # We stop all activity for 1.5 seconds
# Therefore through the constant running of this script, we will see the 
# LED bulb on the Raspberry Pi turning on and off itself, thereby blinking

This article provides an introduction to robotics: there are several more concepts that I recommend reading. This concludes my article on “Understanding of robotics – with Python”.

Thanks for your time.

The media shown in this article is not the property of DataPeaker and is used at the author's discretion.

Subscribe to our Newsletter

We will not send you SPAM mail. We hate it as much as you.