Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Arrow up icon
GO TO TOP
Hands-On ROS for Robotics Programming

You're reading from   Hands-On ROS for Robotics Programming Program highly autonomous and AI-capable mobile robots powered by ROS

Arrow left icon
Product type Paperback
Published in Feb 2020
Publisher Packt
ISBN-13 9781838551308
Length 432 pages
Edition 1st Edition
Tools
Concepts
Arrow right icon
Author (1):
Arrow left icon
Bernardo Ronquillo Japón Bernardo Ronquillo Japón
Author Profile Icon Bernardo Ronquillo Japón
Bernardo Ronquillo Japón
Arrow right icon
View More author details
Toc

Table of Contents (19) Chapters Close

Preface 1. Section 1: Physical Robot Assembly and Testing
2. Assembling the Robot FREE CHAPTER 3. Unit Testing of GoPiGo3 4. Getting Started with ROS 5. Section 2: Robot Simulation with Gazebo
6. Creating the Virtual Two-Wheeled ROS Robot 7. Simulating Robot Behavior with Gazebo 8. Section 3: Autonomous Navigation Using SLAM
9. Programming in ROS - Commands and Tools 10. Robot Control and Simulation 11. Virtual SLAM and Navigation Using Gazebo 12. SLAM for Robot Navigation 13. Section 4: Adaptive Robot Behavior Using Machine Learning
14. Applying Machine Learning in Robotics 15. Machine Learning with OpenAI Gym 16. Achieve a Goal through Reinforcement Learning 17. Assessment 18. Other Books You May Enjoy

Quick hardware test

To perform a quick test and focus on the hardware at hand, we will use DexterOS, the Raspbian-based distro created by Dexter Industries to allow the user to get started quickly. Details of the operating system are provided at https://www.dexterindustries.com/dexteros/. Instead of having to deal with a full Linux desktop, Dexter Industries has simplified the interface by providing a simple web environment.

You can access it by connecting to the Wi-Fi access point called GoPiGo (a password won't be needed). This way, you will be connected directly to the robot with your laptop. Before installing it, let's review the resources we have available.

Resources

There are at least three sites/repositories that you will manage while working with the robot:

Getting started with DexterOS

After going through stages 1 and 2 of the Putting it all together section, you should go through the steps at https://www.dexterindustries.com/dexteros/get-dexteros-operating-system-for-raspberry-pi-robotics/, where you can download the image file of the operating system and follow the instructions to burn a micro SD card with the Etcher app (https://www.balena.io/etcher/). Follow these steps to get started with DexterOS:

  1. Once you have placed the card in the slot of the Raspberry Pi, switch the GoPiGo board on and connect to the Wi-Fi network it creates (its SSID is GoPiGo, without a password).
  1. After that, go to to http://mygopigo.com or http://10.10.10.10 to gain access to the robot's enviroment, where the landing page looks as follows. You can find the step-by-step procedure at https://edu.workbencheducation.com/cwists/preview/26657x:

Be aware that if you keep your laptop's internet connection (wired), then you should connect to the robot IP address http://10.10.10.10. If you need help, you can visit the DexterOS forum at https://forum.dexterindustries.com/c/DexterOS.

From this point on, as you saw on the landing page, you can do the following:

  • DRIVE: thereby moving the robot in all directions with a basic control panel.
  • LEARN: by following the guided tutorials in Bloxter—one of the languages of choice—or Python using Jupyter Lab notebooks.
  • Code in Bloxter: the visual programming language based on the open source Blockly by Google (https://github.com/google/blockly).
  • Code in Python: the main environment that we will use to develop our training in robotics.

Next, we will start coding with Bloxter.

Coding with Bloxter

Of the available programming languages, Bloxter gives you the opportunity to learn about robotics without the complexities of typing out code. Using a visual interface, you can arrange and connect blocks and quickly develop basic programs to control GoPiGo3. Let's get started:

  1. By clicking LEARN in the landing page and then clicking Lessons in Bloxter, you can access the available lessons, as shown in the following screenshot:
  1. Select the one you prefer, taking into account that they are ordered by increasing difficulty:

You are encouraged to complete the LEARN section for the Bloxter part before starting Chapter 2, Unit Testing of GoPiGo3. The lessons are easy to follow, and they teach you more about GoPiGo3 than what you could get by simply reading the documentation.

Calibrating the robot

Follow these steps to calibrate the robot:

  1. Get back to the main page, http://mygopigo.com/, and click on the upper right-hand icon of the landing page. A help screen will pop up with two buttons, one for calibration and another for checking the battery status, as shown in the following screenshot:
  1. Check the vital signs by clicking Check Vital Signs:
  1. Now, click the former button, Test the precision of your robot and calibrate it. You will see the following screen:
  1. Adjust the dimensions so they match those of your robot:
    • Wheel Diameter: Mark a distance of 2 meters on the floor and click the Drive 2m button. If GoPiGo3 arrives just at the finish line, 66.5 mm is OK. If it does not arrive, you should increase the diameter a bit; if it goes past the finish line, you should reduce it. Test this again. By trial and error, you will find the diameter that best fits your own robot.
    • Distance between wheels: This procedure is very similar, with the only difference, that, in this case, the robot will rotate about itself when you press Spin a full rotation. If GoPiGo3 gives a complete turn of 360°, 117 mm is OK. If it does not complete the turn, you should reduce the distance; if it turns more than 360°, you should increase it instead. Test this again. By trial and error, you will be able to adjust this distance, just like in the case of the wheel diameter.

Driving the robot

To drive the robot, follow these steps:

  1. Close the help window and select the DRIVE item on the main page.
  2. By clicking this button, you gain access to a panel where there are controls to move the robot forward/backward and rotate it right/left. Go ahead and check that GoPiGo3 moves as expected.
  3. Whenever you need to stop the motion, press the spacebar of the keyboard:

Next, we will check the sensors.

Checking the sensors

Follow these steps to check the sensors:

  1. Go back to the main page and click Code in Bloxter.
  2. On the right-hand side of the screen, you will see a sliding window, where you can indicate what port you have connected to each sensor. For the purposes of our example, we have set this arrangement:
    • The distance sensor plugged to I2C-1, the I2C on the left-hand side of GoPiGo3
    • The line follower to I2C-2, the I2C on the right-hand side
    • The IMU sensor to AD1 (on the left-hand side)
  1. As soon as you select a port in DexterOS, you will be able to make a selection for each drop-down menu that appears, which is all about the real-time data coming from the sensors, as shown in the following screenshot:
  1. Check all three—that is, the distance sensor, line follower, and IMU—to provide readings. In the distance sensor, you may obtain an error unknown message. Don't worry about that; the sensor isn't damaged, it's just a software bug. When we use Python in the next chapter, you will definitely obtain good readings.
  1. Finally, let's take a look at the data of the more complex sensor, the IMU. After setting its connection to AD1, the window will prompt you—when you select either Inertial Measurement Unit or Inertial Measurement Unit (data)—to spin the robot in the air for 3 seconds to calibrate its orientation. This way, we obtain the absolute orientation reference by combining Earth's gravity and magnetic fields. Then, if we select Inertial Measurement Unit from the drop-down list, we will see the Euler angles that were reported in real time. If they've been calibrated properly, we should find the following:
    • All three angles of the Euler heading (yaw, roll, and pitch) are zero when GoPiGo3 is on a horizontal surface and facing east. In this situation, the Z axis (painted in the sensor) is pointing South.
    • In this position, if you rotate GoPiGo3 with your hands over 90° around the Z axis, then the roll angle will be 90° and the X axis will be pointing up (to the cenith).
    • Getting back to the original position, if you rotate GoPiGo3 with your hands +90° around the X axis, the pitch angle will be 90° and the Y axis will be pointing south.

The physical position of the IMU in GoPiGo3 can be seen in the following image:

We will learn how to use the Pi Camera in the next chapter, when we make use of Python to program the robot.

Shutting down the robot

To finish your first journey with GoPiGo3, just long-press the black button of GoPiGo's red board. After a few seconds, the red LED will stop blinking, meaning that the shutdown process has completed.

You have been reading a chapter from
Hands-On ROS for Robotics Programming
Published in: Feb 2020
Publisher: Packt
ISBN-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.
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 $19.99/month. Cancel anytime