How to Program Remote Control for GoPiGo with Python and Raspberry Pi, Robotics Part 4

29.9K views
•
August 25, 2015
by
sentdex
YouTube video player
How to Program Remote Control for GoPiGo with Python and Raspberry Pi, Robotics Part 4

TL;DR

Program remote control for a Raspberry Pi-powered GoPiGo by opening a Tkinter window, capturing keyboard events, and assigning robot functions to key presses. Part 4 expands the earlier forward-and-back script to support forward, backward, left, right, rotate, stop, distance sensing, and servo movement. Read on for the remote-desktop setup and core Python event-handling steps.

Transcript

what's going on everybody Welcome to part four of our robotics with the raspberry Pine tutorial Series in this part we're going to build on our last script uh our last script from tutorial 3 was the following it just basically moved our our robot forward and back we can run that again real quick just a really simple script that just ran it forward ... Read More

Key Insights

  • 🤖 The tutorial introduces the concept of creating a user-controlled scenario for a Raspberry Pi-powered robot.
  • 😫 It explains the process of setting up a remote desktop connection to access the Raspberry Pi's GUI interface.
  • 👻 The code provided allows users to control the robot's movements using keyboard inputs.

Explore YouTube Video Summarizer or Get YouTube Transcript Extractor

Questions & Answers

Q: How do you program remote control for a GoPiGo with Python and Raspberry Pi?

Create a Tkinter window and use bind_all to send each keyboard event to a key_input function. That function reads the key symbol, converts it to lowercase, and can use conditional statements to trigger GoPiGo movement and accessory functions.

Q: How can you access the Raspberry Pi desktop remotely from Windows?

Install xrdp on the Raspberry Pi, then open Remote Desktop Connection from the Windows Start menu. Enter the Raspberry Pi’s local IP address and log in with its account credentials to load the desktop.

Q: What should you try if the xrdp package cannot be found?

Run an update and an upgrade through the Raspberry Pi package manager, then try installing xrdp again. The tutorial notes that package discovery may still fail for a different reason if this does not resolve it.

Q: What robot controls are covered in Robotics with Python Raspberry Pi and GoPiGo Part 4?

The tutorial covers moving forward, backward, left, and right, as well as rotating and stopping. It also covers reading the distance sensor and moving the servo.

Q: How does the Python program detect keyboard input?

It creates a Tkinter window and binds all key events to the key_input function. The Tkinter main loop keeps the window running and tracks key presses while that window is active.

Q: How does the key_input function identify which key was pressed?

The function receives the keyboard event and reads its key symbol. It converts that symbol to lowercase so capitalization does not interfere, then the script can evaluate it with conditional statements.

Q: What is the servo range used in the GoPiGo remote-control script?

The script defines servo_range as the values 2, 3, 4, 5, 6, 7, and 8. These values are set near the top of the program for use by the later servo-control code.

Q: Can you follow the tutorial without a distance sensor or servo?

Yes. If the robot lacks a distance sensor or servo, omit the corresponding code; the tutorial says everything else will still work.

Summary & Key Takeaways

  • The tutorial builds on the previous scripts and adds user-controlled scenarios to the robot's functionality.

  • It explains how to set up a remote desktop connection to access the Raspberry Pi's GUI interface.

  • The tutorial covers controlling the robot to move forward, backward, left, right, rotate, stop, measure distance, and move a servo.


Read in Other Languages (beta)

Share This Summary 📚

Explore More Summaries from sentdex 📚