[PYTHON] GoPiGo3 of the old man

GoPiGo3 The photo is from Official Page

Click here for the video that is actually moving

■ Trigger

I was interested and bought a Raspberry Pi, but the electrical system was weak and I couldn't use it at all. Since it is a software-related job, I may touch UNIX servers, but I have only knowledge of ls and cp. I happened to see a robot operated by a PlayStation 3 controller, and when I was looking for a kit that I could make myself, I came up with this.

The video I found GoPiGo Example: PS3 Controller (by youTube) I wanted to do this!

■ Product features

Dexter produces robots for education, researchers and enthusiasts in Washington, USA. (GoPiGo was fundraised by Kickstarter and became a hot topic in Japan)

Because GoPiGo is made for the purpose of teaching materials for computer education using Raspberry Pi

――Even children can easily assemble. --You can use it immediately. --No specialized knowledge is required.

There are features such as.

The introductory video also shows how children are actually playing. GoPiGo3 Robot for Education

In addition, as for the product, an all-in-one package with an SD card containing Raspberry Pi and OS is on sale, and all you have to do is prepare AA batteries (8). It's perfect for a slumped father.

The ultimate goal is to make a radio-controlled car using a PS3 controller.

■ Products

I bought the product at "Robotshop" which is cheaper than Amazon. Cheaper shopも見つけたのですが、不安があって専門ショップにしました。(不幸なことにこの不安は的中しました・・・)

Besides that, I bought a rechargeable AA battery, a charger, and a mini router for outside use.

List of purchased products

Product shop Amount of money
GoPiGo3 Beginner Starter Kit Robot shop 27,940
Panasonic Eneloop AA Rechargeable Battery 4 Pack BK-3MCC/4SA x 2 set anazon 2,650
Panasonic Quick Charger AA / AAA Black BQ-CC73AM-K amazon 2,049
RAVPower Wi-Fi SD card reader RP-WD009 amazon ¥5,099(Timesale+coupon)
Team microSDHC card 16GB amazon 550
Total 38,292

If you buy it in small pieces, it will cost you unexpectedly. If you put out a little more [you can buy this] (https://store.dji.com/jp/product/mavic-mini?vid=84651&set_country=JP&gclid=CjwKCAiAqqTuBRBAEiwA7B66hR991-h2lsQAJI9OGVM5HLF8T5vs7knJwGv3eNNFW9_TVCLUg3RK.

In addition to this, a mouse, keyboard, and monitor are available for the Raspberry PI. A PC is required for program development.

■ About GoPiGo3 Starter Kit

The GoPiGo3 Starter Kit is available in ** "Beginner" ** and ** "Advanced" **. The only difference is that the OS is "Dexter OS" or "Raspian for Robots".

Dexter OS is based on Raspian (Stetch Lite) and is operated from a browser. It comes with a "Bloxter" (like Scratch) that allows you to create programs just by operating the screen without knowing the OS mechanism or commands.

I bought this this time, but I can't log in with SSH (described later), so I can use the lessons provided, but it's not suitable for programming. After all, I decided to download and use the OS image provided for advanced users.

For advanced users, it is "Raspian for Robots", and the libraries required for GoPiGo3 are already installed, and SSH connection and VNC connection are possible. The PS3 controller sample that I was aiming for is also included here, so I should have purchased this from the beginning.

OS difference os比較.png

The contents of the kit are the same for both "beginner" and "advanced".

Included in the GoPiGo3 Starter Kit

  1. GoPiGo basic set (main body)
  2. Raspberry PI 3B (not +)
  3. USB memory card (8GB)
  4. Servo set
  5. Distance sensor set
  6. SD card (8G) with OS image

If you buy 2 to 6 in bulk, it will be more expensive than the starter kit, so if you don't have any extra Raspberry PI, I recommend this one. However, if you already have a Raspberry PI 3B and you want to get it yourself, I think the basic set is enough. This is much cheaper (13,306).

■ Actual purchase

I received a reception email when placing an order, a shipping email the next day, and the product arrived the day after. (Haya!) DSC_1522.JPG (Contents of the box)

DSC_1519.JPG (Cats are also curious about the box that arrived)

DSC_1529.JPG Empty USB memory that you do not know when to use

DSC_1532.JPG Infrared distance sensor with decoration on both eyes (sensor is in the middle)

DSC_1533.JPG Power supply

DSC_1535.JPG Dexter OS SD card (I used it by copying it to another 16GB SD card because it is less in 8G)

DSC_1536.JPG Raspberry PI 3B

DSC_1541.JPG Basic kit

DSC_1542.JPG Basic kit contents

DSC_1563.JPG RedBord(Arduino)

DSC_1547.JPG wheel

DSC_1548.JPG Acrylic mounting parts

DSC_1549.JPG Motor mounting parts

DSC_1550.JPG Rear wheel parts

DSC_1551.JPG Spare parts (full)

DSC_1552.JPG Controller parts

DSC_1558.JPG Motor with distance sensor

DSC_1554.JPG Motor connection cable, battery band, power cable

DSC_1555.JPG Battery box (for 8 AA batteries)

DSC_1556.JPG Acrylic board (bottom)

DSC_1557.JPG Acrylic board (top)

DSC_1526.JPG Other than that, I bought everything

Acrylic parts are numbered and stickers are attached to make it easier to make. In addition, the parts were grouped into parts by function, and there were plenty of spare parts. (It's safe) Includes driver with DEXTER logo However, unfortunately it is not easy to make, and it is made in USA. I saw such a bent washer (spacer?) For the first time.

It's for children, so I think it's designed so that it can be handled roughly.

■ Assembly

In particular, ** there is no Japanese manual **, so you will need to refer to the Dexter website (English) when assembling. --Tutorials & Documentation --Plenty of photos and easy to understand Assembly instructions

As it is an educational kit, it is designed so that even children can make it, and it is very easy to assemble.

However, I am often confused because the explanation on the Dexter website and the actual product content (especially how to organize parts) are different. It's a common pattern where documents aren't catching up with products. I assembled it with my son, but the assembly itself took about 30 minutes.

DSC_1560.JPG (Assembled photo 1)

DSC_1565.JPG (Assembled photo 2)

■ (1) Connection with beginner option (Dexter OS)

** Only access from the browser **. The procedure is simple.

  1. Turn on the power
  2. Wait for a while (wait for the Wifi lamp to turn green)
  3. Connect to "GoPiGo" in the Wifi connection list of your PC
  4. The browser will start automatically and the following screen will be displayed. If the browser doesn't start, start it manually and enter "mygopigo.com" in the URL. Note) In the case of Internet Explorer, there is a bug that sometimes the button does not work. Please use something other than IE.

(screen)

  1. Select Drive and click the button

(screen)

GoPiGo works! Really impressed!

■ Trouble 1

Trouble occurred here. The motor on the right side doesn't work. I checked the connections and cables, but it seems that the motor is initially defective. I requested the shop to exchange it.

(The shop contacted me to return the main unit for replacement, but when I told him that I was in a hurry, I was asked to send only the ** motor ** (defective parts). No need to return the item) We also sell parts It was very helpful to have the support unique to the shop.

■ Trouble 2

The point of connection is to connect to GoPiGo as the Wifi connection destination of the PC. Actually, GoPiGo3 itself is functioning as a Wifi spot, and I didn't understand it at first, so I was worried a lot.

Also, I put the Raspberry PI screen on the monitor and tried to log in, but I don't know the password for the standard user pi. In addition, I didn't know the root password, so I was in trouble because I couldn't proceed from the login prompt. This Blogを見つけて、Wifiの接続先を変えることに気づき、ようやく画面を出すことができました!

It was good until the screen came out, but I didn't understand how to use Bloxter and I couldn't find a sample PS3 controller, so I gave up using Dexter OS and set up the advanced option (Raspian for Robots). I decided to challenge.

■ (2) Connection with advanced option (Raspbian for Robots)

If you purchased the advanced option from the beginning, insert the SD card and boot. If you purchased the base kit, you need to make an SD card with the OS image.

procedure

  1. Download the OS image from gitHUB.
  2. Unzip the zip file.
  3. Format the SD card. I used DiskFormat32 as the format. Trouble here. An error will occur if the SD card cannot be written. I cleared the read attribute with the diskpart command referring to here.
  4. Use Win32 Disk Imager to write the OS image.

Just set up Wifi before assembling. procedure

  1. Connect your SD card, mouse, keyboard and monitor to your Raspberry PI.
  2. Power on the Raspberry PI.
  3. Wait for a while and the desktop will appear.
  4. Make Wifi connection settings from the desktop screen.

Assemble GpPiGo3. (Assembly is the same as before)

After assembling, turn on the power of GoPiGo3, wait for a while, and the Wifi lamp will glow white. There are two connection methods.

・ SSH connection

Install the SSH client (I used TeraTerm) and log in. You can connect with the host name ** [email protected] ** and enter with the password ** robots1234 **.

SSH1.png (Screen 1) SSH2.png (Screen 2) SSH3.png (Screen 3)

・ VNC connection Open "dex.local" in your browser, select VNC, enter the password robots1234 and the desktop will be displayed.

vnc.png (VNC screen)

I was surprised to learn that VNC can be done with a browser. Also, both can be connected by "dex.local" instead of the IP address, so you do not have to check the IP. Great!

Launch the GoPiGo3 Control Panel on your desktop and verify that GoPiGo3 works.

vnc2.png (Test screen)

■ PlayStation 3 controller connection

** Make connection settings before assembling. ** **

Set while looking here. [PS3 Control with GoPiGo] (https://www.dexterindustries.com/GoPiGo/projects/python-examples-for-the-raspberry-pi/raspberry-pi-ps3-control-with-gopigo-robot-example/)

After completing the settings and restarting, press the PS button and the recognition of biuetooth will end in an instant. Unlike the PlayStation connection, the LED goes off, but you can rest assured that it is connected. ls /dev/input/js0 If there is, it is a success.

■ Trouble 3

Control from PS3 that I wanted to do the most. An error occurs when the connection is set and executed! .. ** I was pretty disappointed. ** ** However, I regained my mind that I could study Python and decided to track it.

(result)

It turns out that the receiving part of PS3 controller data does not work in the sample. (For unknown reasons)

I reviewed the receiving part with reference to this. ■ RC with Raspberry Pi (3): Read the input of dualshock3 with Python https://www.usagi1975.com/30jul170722/

Also, the sample provided was a script for GoPiGo2. Looking at the example, I rewrote it for GoPiGo3. The resulting code is below

ps3.py


#!/usr/bin/python3
import struct
import gopigo3
import easygopigo3 as easy
import time

device_path = "/dev/input/js0"

# unsigned long, short, unsigned char, unsigned char
EVENT_FORMAT = "LhBB";
EVENT_SIZE = struct.calcsize(EVENT_FORMAT)

try:
  GPG = easy.EasyGoPiGo3()
except Exception as e:
  print("GoPiGo3 cannot be instanstited")
  print(e)
  exit()

with open(device_path, "rb") as device:
  event = device.read(EVENT_SIZE)
  while event:
    (ds3_time, ds3_val, ds3_type, ds3_num) = struct.unpack(EVENT_FORMAT, event)
    print( "{0}, {1}, {2}, {3}".format( ds3_time, ds3_val, ds3_type, ds3_num ) )
 
    if ds3_val == 1 and ds3_type== 1 and ds3_num==13:
        GPG.forward()
        print "F"
    if ds3_val == 1 and ds3_type == 1 and ds3_num == 14:
        GPG.backward()
        print "B"
    if ds3_val == 1 and ds3_type == 1 and ds3_num == 16:
        GPG.right()
        print "R"
    if ds3_val == 1 and ds3_type == 1 and ds3_num == 15:
        GPG.left()
        print "L"
    if ds3_val == 1 and ds3_type == 1 and ds3_num == 0:
        GPG.stop()
        print "STOP"

    event = device.read(EVENT_SIZE)

Click here to see how it actually works

■ Conclusion

■ Reference resources

There are not many resources written in Japanese about GoPiGo. The content is so rich that it is very helpful. It is a reference resource. Thanks!


Articles written in Japanese

■ [Run gopigo3 with ROS] (https://qiita.com/cut0ter/items/0326f5dee89456e47001) I am running GoPiGo with ubuntu mate + ros.

■ [Let's make a remote watching robot using the robot "GoPiGo" that moves with Raspberry Pi (1) Development preparation] (https://codezine.jp/article/detail/9829) How many articles are properly written in Japanese about GoPiGo?

■ [Let's make GOPIGO] (http://masaaki1.blogspot.com/2016/10/gopigo.html) This is a blog for those who purchased directly from Dexter Industries in the United States. What was written and what I wanted to do was close to me and helpful.

■ [Making a "drawing robot" starting from 10 years old] (https://qiita.com/ykoga/items/3362beb26fc640913645) The taste of giving a fun robot lecture to children is wonderful.

■ [Assembly of Dexter Industries GoPiGo, a junk room for crafts and small items] (http://junkroom2cyberrobotics.blogspot.com/2016/03/dexter-industries-gopigo.html) Those who have assembled not only GoPiGo but also GrovePi. Great.

■ [I played with GoPiGo2] (https://www.slideshare.net/mainya/go-pigo2) Those who are well organized on slides.

■ [Days of tkumada_] (https://tkamada.blogspot.com/2015/10/gopigo.html) The red base is Arudino. I did not know.


Shops
■ [Roboshop Co., Ltd.] (https://www.robotshop.com/jp/ja/) Japanese subsidiary of US robotshop. It is wonderful that there is a large selection and shipping is fast

■ [GoPiGo3 Beginner Starter Kit: Robotshop Store --18,829 yen] (http://viptoycimall.xyz/index.php?main_page=product_info&products_id=41826) The base kit is cheaper than 10,000. I'll buy another daddy!

■ [Sales of the first robot / car development kit] (https://spectrum-tech.co.jp/products/robotcar.html) It is a company that sells GoPiGo as a system. I think it's a good place to look, so I hope it becomes a business.


Dexter Site
■[GoPiGo3 Tutorials & Documentation] (https://www.dexterindustries.com/gopigo3-tutorials-documentation/) Resources are summarized here. The difficulty is that it is old

■ PS3 controller [PS3 Control with GoPiGo] (https://www.dexterindustries.com/GoPiGo/projects/python-examples-for-the-raspberry-pi/raspberry-pi-ps3-control-with-gopigo-robot-example/) The connection procedure is as follows, but the sample does not work on GoPiGo3.

■[Assemble the GoPiGo Servo Kit] (https://www.dexterindustries.com/GoPiGo/get-started-with-the-gopigo3-raspberry-pi-robot/6-attach-the-servo-kit-gopigo3-raspberry-pi-robot/) There is no actual kit content and description at all. Please update as soon as possible.

■[Dexter Industries GoPiGo3 Documentation!] (https://gopigo3.readthedocs.io/en/master/index.html) It looks like an API doc.

■[Raspberry Pi, Java, and the GoPiGo3 - Part 1: Setting up the GoPiGo3] (https://www.omnijava.com/2018/05/06/raspberry-pi-java-and-the-gopigo3-part-1-setting-up-the-gopigo3/) Although it is an English blog, it explains carefully about login. The sample posted here was actually included. Great.

Recommended Posts

GoPiGo3 of the old man
The beginning of cif2cell
The meaning of self
the zen of Python
The story of sys.path.append ()
Revenge of the Types: Revenge of types
Align the version of chromedriver_binary
10. Counting the number of lines
The story of building Zabbix 4.4
Towards the retirement of Python2
[Apache] The story of prefork
Compare the fonts of jupyter-themes
About the ease of Python
Get the number of digits
Explain the code of Tensorflow_in_ROS
Reuse the results of clustering
Calculate the number of changes
Change the theme of Jupyter
The popularity of programming languages
Change the style of matplotlib
Visualize the orbit of Hayabusa2
About the components of Luigi
Connected components of the graph
Filter the output of tracemalloc
About the features of Python
Simulation of the contents of the wallet
The Power of Pandas: Python
How to output the output result of the Linux man command to a file
Test the version of the argparse module
Find the definition of the value of errno
The day of docker run (note)
Plot the spread of the new coronavirus
The story of Python and the story of NaN
Get the number of views of Qiita
[Python] The stumbling block of import
Japanese translation of the e2fsprogs manual
The story of participating in AtCoder
Change the background of Ubuntu (GNOME)
Is the probability of precipitation correct?
I investigated the mechanism of flask-login!
Understand the contents of sklearn's pipeline
The world of control engineering books
Step into the darkness of msync
Take the execution log of Celery
Existence from the viewpoint of Python
Calculation of the number of Klamer correlations
About the return value of pthread_mutex_init ()
Combine the overlap of one-dimensional intervals
Get the attributes of an object
Solve the delay of interferometer observation
Distinguishing the agari shape of mahjong
Python-Simulation of the Epidemic Model (Kermack-McKendrick Model)
Change the Python version of Homebrew
Power the brushless motor of Oriental motor
The power of combinatorial optimization solvers
Get the first element of queryset
About the basic type of Go
See the contents of Kumantic Segumantion
Process the result of% time,% timeit
About the upper limit of threads-max
Analyzing the age-specific severity of coronavirus