Robot running with Arduino and python

I made a robot like this

I wanted something to study computer vision, so I made a robot like this. It is linked to a YouTube video, so please click on the image. You can see how it works.

https://www.youtube.com/watch?v=hIaIxOBjJzQ

Control this robot using python over Wi-Fi. This is an attempt to acquire camera images, RGB-D images, etc., analyze the images, and move them.

Robot side details

In making the robot, I disassembled and modified a robot vacuum cleaner like Roomba as a base and used it. It is a low-priced robot vacuum cleaner sold in Nitori. If it's so cheap, it's okay to disassemble and remodel it. On top of that is a robot arm, an Arduino, an RGB-D camera, and a small PC with an Intel Atom processor that controls the hardware installed in the robot. Arduino uses MEGA 2560 because it wants to control a lot of servos. UNO, which I often see, is a little insufficient, and I wonder if it's heartbreaking considering future expansion. The small PC has a model number of DG-M01IW, and it has a battery that lasts for 13 hours even though it is the size of a paperback book. Built-in. It's the best match for this robot, and I bought 2 of them.

The software on the robot side is roughly divided into firmware-like software that is installed on Arduino and server-like software that configures an HTTP server that is installed on a PC (Windows 10).

Arduino Arduino also needs power. It uses a 7.2V battery that is available for radio control.

The servo control that supports the robot arm and RGB-D camera is PWM control by Arduino. For the motor used to move the robot, an I2C-controlled motor controller was externally attached, and a circuit was built to control the motor of the robot vacuum cleaner via I2C. This allows the robot to move back and forth, left and right, and rotate.

Serial communication with PC is performed by UART. On the Arduino side, we have prepared the following protocols for control and information acquisition.

By issuing the above protocol from the PC through the Serial port, it is possible to freely control the servo and acquire information. For example, by transmitting ʻa0 + 90, servo # 0 can be moved to an angle of + 90 °, or by m + 255 + 255`, the left and right moving motors can be rotated in the forward direction. Of course, such details such as servo speed control are done on the Arduino side.

PC (DG-M01IW) The PC has a built-in battery, so it runs without an external battery. The basic OS uses the pre-installed Windows 10 Home as it is. Arduino, RGB-D camera, camera at the tip of the robot arm, etc. are connected via USB. In addition, since Bluetooth and Wi-Fi are naturally built-in, Wi-Fi-based network control is possible only with this PC.

Communication with Arduino is done using UART Serial communication. On the PC side, the following tasks are the main tasks.

Depending on the URL accepted on the HTTP server side, the camera image is returned and the servo is controlled via Arduino. For example, return image / jpeg for a GET request for http: // ..../ sensor / color, or for a GET request forhttp: // ..../ arm0? cmd = ... Moves the robot arm according to the cmd parameter.

In short, it is the job of the PC to interpret the request received by HTTP, send a command to Arduino as it is, and return the image / depth information. This PC is small enough to be mounted on a robot and is battery-powered, so it does not perform calculations that increase the CPU load as much as possible. In this area, I think that it is a job that can be done even with Raspberry Pi, but unexpectedly the bandwidth around USB becomes a problem, especially for RGB-D cameras, Raspberry Pi is heavy.

After a lot of trial and error, I implemented the HTTP server in C ++. The reason is as follows.

In fact, if the OS is based on Linux, I think it would be easier and quicker to make it even if it was based on C / C ++. Especially around HTTP. However, it was a little troublesome to install Linux on a mini PC equipped with an Intel Atom processor (*), so I gave up and developed it based on Windows 10. (But thanks to that, I could use Visual Studio for debugging etc. and it might have been easier as a result)

*: Just because I couldn't find a Linux distribution that supports 32-bit EFI booting w I didn't want to have a hard time around here ... I thought. I really wanted to include Ubuntu.

Image analysis logic

Up to this point, the robot can be controlled completely wirelessly via the Wi-Fi network, and the side that controls the robot by image analysis is not tied to any OS type or language.

My main PC is Mac Book Air Mid 2012, so I definitely want to go there with a Mac. So, I think about using numpy, OpenCV 2.x, (+ TensorFlow), etc. based on python. Requests is available for HTTP relations.

Currently, it is like searching for a red object and chasing it with the method described in Qiita: "Let's recognize red objects with python". I'm building logic. Eventually, I plan to bring it to the point where it can be autonomously grasped by the robot arm.

I would like to make full use of the method of clustering images using the depth data obtained from the RGB-D camera and the point cloud processing using the Point Cloud Library. I've implemented various logics of this kind based on C ++ / Objective-C, but I'm impressed with the destructive power of python + numpy every day. I wish I had moved to python + numpy earlier w

From now on, while porting the logic implemented so far to python, I plan to utilize these to increase the depth of robot control. I would like to write those articles when I get some results.

Recommended Posts

Robot running with Arduino and python
Try running Google Chrome with Python and Selenium
Programming with Python and Tkinter
Encryption and decryption with Python
Python and hardware-Using RS232C with Python-
Try running Python with Try Jupyter
python with pyenv and venv
Works with Python and R
Communicate with FX-5204PS with Python and PyUSB
Shining life with Python and OpenCV
Install Python 2.7.9 and Python 3.4.x with pip.
Neural network with OpenCV 3 and Python 3
AM modulation and demodulation with python
[Python] font family and font with matplotlib
Scraping with Node, Ruby and Python
Scraping with Python, Selenium and Chromedriver
Scraping with Python and Beautiful Soup
JSON encoding and decoding with python
Hadoop introduction and MapReduce with Python
[GUI with Python] PyQt5-Drag and drop-
Reading and writing NetCDF with Python
I played with PyQt5 and Python3
Reading and writing CSV with Python
Multiple integrals with Python and Sympy
I tried running prolog with python 3.8.2.
Coexistence of Python2 and 3 with CircleCI (1.0)
Easy modeling with Blender and Python
Sugoroku game and addition game with python
FM modulation and demodulation with Python
[Machine learning] Try running Spark MLlib with Python and make recommendations
Linking Python and Arduino to display IME On / Off with LED
Manipulability ellipsoid of arm and mobile robot is drawn with python
Communicate between Elixir and Python with gRPC
Data pipeline construction with Python and Luigi
Calculate and display standard weight with python
Monitor Mojo outages with Python and Skype
FM modulation and demodulation with Python Part 3
[Automation] Manipulate mouse and keyboard with Python
Passwordless authentication with RDS and IAM (Python)
Python installation and package management with pip
Using Python and MeCab with Azure Databricks
POST variously with Python and receive with Flask
Capturing images with Pupil, python and OpenCV
Fractal to make and play with Python
A memo with Python2.7 and Python3 on CentOS
Use PIL and Pillow with Cygwin Python
Create and decrypt Caesar cipher with python
CentOS 6.4 with Python 2.7.3 with Apache with mod_wsgi and Django
Reading and writing JSON files with Python
Dealing with "years and months" in Python
[Beginner] Installing Python and running programs (Windows)
I installed and used Numba with Python3.5
Tweet analysis with Python, Mecab and CaboCha
Linking python and JavaScript with jupyter notebook
Traffic monitoring with Kibana, ElasticSearch and Python
FM modulation and demodulation with Python Part 2
Encrypt with Ruby (Rails) and decrypt with Python
Easily download mp3 / mp4 with python and youtube-dl!
Operate home appliances with Python and IRKit
Clean python environment with pythonz and virtualenv
Practice web scraping with Python and Selenium