Reader small image

You're reading from  Hands-On ROS for Robotics Programming

Product typeBook
Published inFeb 2020
PublisherPackt
ISBN-139781838551308
Edition1st Edition
Tools
Concepts
Right arrow
Author (1)
Bernardo Ronquillo Japón
Bernardo Ronquillo Japón
author image
Bernardo Ronquillo Japón

Bernardo Ronquillo Japn is an Internet of Things (IoT) and robotics expert who has worked for top technology companies since 1995, including Instituto de Astrofsica de Canarias, Gran Telescopio Canarias, Altran, and Alestis Aerospace. Using his skills and experience, he founded The Robot Academy, where he develops open source hardware and software solutions for engineers and makers: Social Robot IO (2015), for the stimulation of children with autistic spectrum disorder; Robot JUS (2016), which helps engineers get deeper technical insights with the Robot Operating System (ROS) when using low-complexity hardware; and IIoT All-in-One (2018) as an industrial IoT training package for assisting companies in their digital transformation process.
Read more about Bernardo Ronquillo Japón

Right arrow

Unit Testing of GoPiGo3

After finishing the assembly of the hardware, in this chapter, you will get familiar with how GoPiGo3 works using the JupyterLab environment, a friendly interface that takes the structure of a notebook composed of human-readable paragraphs followed by Python code snippets. You will produce two versions of each test program: the JupyterLab notebook and the pure Python script.

Using these programming tools, you will test each sensor/actuator individually and check that they're working properly while learning about the technology behind each of them.

We will be covering the following topics:

  • Getting started with Python programming under the user-friendly environment Jupyterlab
  • Testing the robot perception: distance sensor, line follower, and 2D
  • Testing the robot actuation: motors and encoders

If you follow the practical exercises, you'll learn...

Technical requirements

The code for the first section, Getting started with Python and Jupyterlab, is included within the image of DexterOS, the custom operating system supplied by the manufacturer of GoPiGo3. In Chapter 1, Assembling the Robot, we explained how to get this image and burn it to an SD card. This was explained in the Quick hardware testing section in the Getting started with DexterOS sub-section.

The code for this chapter is in the GitHub repository of the book, located at https://github.com/PacktPublishing/Hands-On-ROS-for-Robotics-Programming/tree/master/Chapter2_Unit_Tests. At the beginning of the Unit testing of sensors and drives section, we explain how to clone the code locally in the Raspberry Pi.

Getting started with Python and JupyterLab

JupyterLab is a very extensive tool in the Python community because it lets you write a program as if you were solving a mathematics problem in a school class. That is to say, you write the heading, then the problem statement and the initial data. After this declaration, you write a paragraph explaining the operation that you are going to perform, and then you write the Python line(s) that perform such operation in a code cell. For every operation you repeat the same steps:

  1. A human-readable paragraph explaining the next operation, which is formatted with the well-known markdown syntax https://commonmark.org/help/.
  2. A code cell with the lines of Python that perform the operation.
  3. Repeat steps 1 and 2 for every code snippet that perform a single operation. The final one will provide the solution to the problem..

Here's a self-explaining...

Unit testing of sensors and drives

In this section, we will run some simple scripts in Python by using Jupyter Notebooks. From a terminal in your laptop, clone the book repository and go into the Chapter2_Unit_Tests folder to access the files for this chapter:

$ git clone https://github.com/PacktPublishing/Hands-On-ROS-for-Robotics-Programming
$ cd Hands-On-ROS-for-Robotics-Programming/Chapter2_Unit_Tests

For completeness, we have included the notebooks used in the previous section inside the lessons_GettingStarted folder.

Quick start with sensors and motors

To enter the Python environment of your robot, switch on the red board and connect to the GoPiGo Wi-Fi network from your laptop. Then, visit the following URL in the browser...

Summary

In this chapter, we have familiarized ourselves with the GoPiGo3 Python environment by running simple programs that allow us to test robot sensors and actuators. We have checked them one by one in what is formally known as unit testing. This has served two goals: getting started with Python programming and functionally validating your robot hardware.

Next, we will leave the robot for one chapter, and we will discuss the core software concepts of ROS that we will later use to program GoPiGo3.

Questions

  1. If you have this sequence of Python commands, what will GoPiGo3 do?
my_gopigo.drive_cm(10)
my_gopigo.turn_degrees(90)

A) It will drive 10 cm forward and then turn 90º to the right
B) It will drive 10 cm forward and then turn 90º to the left
C) It will turn 90º

  1. What is the battery level required for GoPiGo3 to work properly?

A) Slightly above 9V is enough.
B) 5V, the same that the Raspberry Pi needs.
C) There is no minimum. If the voltage is low, the robot will drive slowly.

  1. Which set of commands will make GoPiGo3 draw a right angle arc 60 cm in diameter?

A) gpg.orbit(90, 60)
B) gpg.orbit(90, 30)
C) gpg.orbit(180, 30)

  1. What combination of the six sensor signals of the line follower does not correspond to GoPiGo3 being to the right of the black line? (w: white, b: black)

A) b-b-b-b-w
B) w-b-b-b-w
C) b-b-b-w-w

  1. If you have a histogram of an image that...

Further reading

lock icon
The rest of the chapter is locked
You have been reading a chapter from
Hands-On ROS for Robotics Programming
Published in: Feb 2020Publisher: PacktISBN-13: 9781838551308
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime

Author (1)

author image
Bernardo Ronquillo Japón

Bernardo Ronquillo Japn is an Internet of Things (IoT) and robotics expert who has worked for top technology companies since 1995, including Instituto de Astrofsica de Canarias, Gran Telescopio Canarias, Altran, and Alestis Aerospace. Using his skills and experience, he founded The Robot Academy, where he develops open source hardware and software solutions for engineers and makers: Social Robot IO (2015), for the stimulation of children with autistic spectrum disorder; Robot JUS (2016), which helps engineers get deeper technical insights with the Robot Operating System (ROS) when using low-complexity hardware; and IIoT All-in-One (2018) as an industrial IoT training package for assisting companies in their digital transformation process.
Read more about Bernardo Ronquillo Japón