Pycon2013 : Application of Python in Robotics

38
PyCon2013 Application of Python in Robotics Lentin Joseph www.lentinjoseph.com

description

Application of python in Robotics. Sample codes https://github.com/lentin/Sample_Codes

Transcript of Pycon2013 : Application of Python in Robotics

Page 1: Pycon2013  : Application of Python in Robotics

PyCon2013

Application of Python in Robotics

Lentin Josephwww.lentinjoseph.com

Page 2: Pycon2013  : Application of Python in Robotics

PyCon2013

About Speaker

• Former Robotics Engineer @ASIMOV Robotics

• Founder of www.technolabsz.com• Robotics, Machine Vision for last 3 years• Python and GNU/Linux for last 5 years • Website : www.lentinjoseph.com

Page 3: Pycon2013  : Application of Python in Robotics

PyCon2013

Agenda

• Introduction to Robotics• Designing an intelligent ball tracking robot• Block Diagram explanations• Technology explanations• Role of Python• Robot demos

Page 4: Pycon2013  : Application of Python in Robotics

PyCon2013

Robotics in a Nutshell

• What is Robotics

• What is a Robot

• Types of Robot

Page 5: Pycon2013  : Application of Python in Robotics

PyCon2013

Robotics and Robot

• Robotics deals with design, construction, operation and application of robots

• Robot is a machine build for doing real world functions

Page 6: Pycon2013  : Application of Python in Robotics

PyCon2013

Types of Robots

Manipulators Mobile Robots Hybrid Robots

Page 7: Pycon2013  : Application of Python in Robotics

PyCon2013

Designing a ball tracking robot

Page 8: Pycon2013  : Application of Python in Robotics

PyCon2013

What this Robot Can do??• It will track coloured objects like balls

Add-on :• It can respond to human voice commands

using Artificial Intelligence

• It can detect obstacles

Page 9: Pycon2013  : Application of Python in Robotics

PyCon2013

What are the Features

• Locomotion• Image Processing capability• Speech synthesis and recognition• Basic Artificial Intelligence• Obstacle avoidance

Page 10: Pycon2013  : Application of Python in Robotics

PyCon2013

Block Diagram

Arduino

Raspberry Pi Camera

Motor Control board

Motors

Speaker and Mic

Ultrasonic sound sensors

Page 11: Pycon2013  : Application of Python in Robotics

PyCon2013

How this components look like??

Page 12: Pycon2013  : Application of Python in Robotics

PyCon2013

Block Diagram Explanation

Arduino

Raspberry Pi Camera

Motor Control board

Motors

Speaker and Mic

Ultrasonic sound sensors

Page 13: Pycon2013  : Application of Python in Robotics

PyCon2013

Motors• DC Geared Motor

• Specification• 12 volt• 60 rpm

Page 14: Pycon2013  : Application of Python in Robotics

PyCon2013

Block Diagram

Arduino

Raspberry Pi Camera

Motor Control board

Motors

Speaker and Mic

Ultrasonic sound sensors

Page 15: Pycon2013  : Application of Python in Robotics

PyCon2013

Motor Driver• Name: MotoMama• L298 H-Bridge• 2 Motor output port• Arduino Compatible• Zigbee, Bluetooth

ready• LED Indicators

Page 16: Pycon2013  : Application of Python in Robotics

PyCon2013

Block Diagram

Arduino

Raspberry Pi Camera

Motor Control board

Motors

Speaker and Mic

Ultrasonic sound sensors

Page 17: Pycon2013  : Application of Python in Robotics

PyCon2013

Arduino• Opensource hardware• AtMega 328

micro-controller• GPIO and Analog pins• USB Compatible• 5volt supply• Easy programming

interface

Page 18: Pycon2013  : Application of Python in Robotics

PyCon2013

Block Diagram

Arduino

Raspberry Pi Camera

Motor Control board

Motors

Speaker and Mic

Ultrasonic sound sensors

Page 19: Pycon2013  : Application of Python in Robotics

PyCon2013

Ultra Sonic Sound Sensor• Obstacle detection• Compatible with

Arduino• Detect collision up to 2

cm to 3 m• TTL Compatible

Page 20: Pycon2013  : Application of Python in Robotics

PyCon2013

Block Diagram

Arduino

Raspberry Pi Camera

Motor Control board

Motors

Speaker and Mic

Ultrasonic sound sensors

Page 21: Pycon2013  : Application of Python in Robotics

PyCon2013

Raspberry Pi• Mini Computer• Running GNU/Linux• Specification:

• 700Mhz Processor• 512 MB of RAM• USB Ports• GPIO Pins• Ethernet• Audio Jack

Page 22: Pycon2013  : Application of Python in Robotics

PyCon2013

Block Diagram

Arduino

Raspberry Pi Camera

Motor Control board

Motors

Speaker and Mic

Ultrasonic sound sensors

Page 23: Pycon2013  : Application of Python in Robotics

PyCon2013

How it Works??Grabbing frames

from cameraProcess Each

frameFind position of ball in the frame

If ball is left side of the image, calculate

how much pixels from center, send

this control signals to arduino and vice

versa

Arduino ProcessComands from

Raspberry Pi and sent commands to motor driver

Motor controller board sent PWM

to MotorsMotors

Page 24: Pycon2013  : Application of Python in Robotics

PyCon2013

Grab frames and Process??

• What is a Digital Image• What is Digital Image Processing• How to do color detection using Image

processing• What is the role of python in image

processing• Which library used for image processing

Page 25: Pycon2013  : Application of Python in Robotics

PyCon2013

Open Computer Vision(Open-CV)

• Developed by Intel maintaining by Willogarage , Itseez

• Designed to do real time computer vision• Written in C++ ,support for C,C++,Python,

Java

Page 26: Pycon2013  : Application of Python in Robotics

PyCon2013

How colour tracking code works??

• Colour tracker uses Python wrapper of Open CV

Grabbing frames from

cameraSmoothing BGR->HSV

ThresholdFinding momentsFinding centroid of moments

Compare center pixel of images

and centroid

Send the left and right offset from center to arduino

Page 27: Pycon2013  : Application of Python in Robotics

PyCon2013

How colour tracking code works??

• Demo Code

Page 28: Pycon2013  : Application of Python in Robotics

PyCon2013

How to send commands to arduino??

• Python Serial Port Communication

• >>import serial• >>ser=serial.Serial(‘/dev/ttyUSB0’,57600)• >>ser.write(“L60”)• >>print ser.read();• >>ser.close()

Page 29: Pycon2013  : Application of Python in Robotics

PyCon2013

Working of Arduino Firmware

Initialize Serial Communication

Receive Control Signal from Rpi

NodeSplit Direction

and Value

Scale the value and sent to motor

controller

Receive Distance data from

Ultrasound sensor

Stop rover if obstacle

Page 30: Pycon2013  : Application of Python in Robotics

PyCon2013

Working of Ping Sensor

Page 31: Pycon2013  : Application of Python in Robotics

PyCon2013

How to do communication between nodes??

• What is Robotic Operating System(ROS)• What is ROS and its concepts• ROS Topics, Nodes, ROS Core, ROS

Package

Page 32: Pycon2013  : Application of Python in Robotics

PyCon2013

Communication between nodes??

• Two Nodes• Arduino node and Raspberry Pi node

ROS MasterRaspberry Pi

NodeArduino Node

Camera Arduino

Publish Topic Subscribe Topic

Page 33: Pycon2013  : Application of Python in Robotics

PyCon2013

Speech Processing and AI

• Speech Synthesis : Festival and Pyfestival• Speech Recognition : GStreamer ,Pocket

Sphinx• Artificial Intelligence: AIML and PyAIML• GUI :Qt and PyQT

Page 34: Pycon2013  : Application of Python in Robotics

PyCon2013

Some of the projects !!

Page 35: Pycon2013  : Application of Python in Robotics

PyCon2013

Demo

Page 36: Pycon2013  : Application of Python in Robotics

PyCon2013

Reference●www.opencv.org●www.ros.com●www.arduino.cc

Page 37: Pycon2013  : Application of Python in Robotics

PyCon2013

Questions

Page 38: Pycon2013  : Application of Python in Robotics

PyCon2013

Thanks

Lentin Joseph

www.lentinjoseph.comwww.technolabsz.com