Book Image

Hands-On ROS for Robotics Programming

By : Bernardo Ronquillo Japón
Book Image

Hands-On ROS for Robotics Programming

By: Bernardo Ronquillo Japón

Overview of this book

Connecting a physical robot to a robot simulation using the Robot Operating System (ROS) infrastructure is one of the most common challenges faced by ROS engineers. With this book, you'll learn how to simulate a robot in a virtual environment and achieve desired behavior in equivalent real-world scenarios. This book starts with an introduction to GoPiGo3 and the sensors and actuators with which it is equipped. You'll then work with GoPiGo3's digital twin by creating a 3D model from scratch and running a simulation in ROS using Gazebo. Next, the book will show you how to use GoPiGo3 to build and run an autonomous mobile robot that is aware of its surroundings. Finally, you'll find out how a robot can learn tasks that have not been programmed in the code but are acquired by observing its environment. You'll even cover topics such as deep learning and reinforcement learning. By the end of this robot programming book, you'll be well-versed with the basics of building specific-purpose applications in robotics and developing highly intelligent autonomous robots from scratch.
Table of Contents (19 chapters)
1
Section 1: Physical Robot Assembly and Testing
5
Section 2: Robot Simulation with Gazebo
8
Section 3: Autonomous Navigation Using SLAM
13
Section 4: Adaptive Robot Behavior Using Machine Learning

Running the simulation and plotting the results

To run this simulation scenario, we follow the standard approach of first launching a Gazebo environment—part of the cartpole_description package with the model of the robotand, afterward, we will start the training process:

T1 $ roslaunch cartpole_description main.launch

The result in the Gazebo window should be similar to the following screenshot. Although this is a 3D environment, the model itself behaves like a 2D model, since the cart pole can only slide along the direction of the guide:

For the training process, we have the launch file in the other ROS package, that is, cartpole_v0_training:

T2 $ conda activate gym
T2 $ (gym) roslaunch cartpole_dqn start_training.launch

Be aware that before running the launch file, you have to activate the gym Python environment, which is where you installed OpenAI Gym.

You...