This article opens a series of lessons in which we will try to understand using the capabilities of modern physical simulators and software platforms to facilitate the development and debugging of software when creating complex robotic systems.
We will use Gazebo 3D as a simulator, and the human-like DARwIn-OP package, which we will force to play football, will be used as a universal robotic platform.
DARwIn-OP in the simulator Gazebo')
To learn lessons, use code examples, and write your own algorithms, you do not need to purchase expensive equipment or software. All software is free, and debugging and demonstration of algorithms will be carried out in the simulator. The finished project will be ported to a real robot to demonstrate the results.
Gazebo 3D , developed by the non-profit organization OSRF (Open Source Robotics Foundation), has several advantages compared with other robotic simulators. First, it is free and has open source. Secondly, it is very popular among the global robotic community and is the official simulator of the DARPA competition. Thirdly, Gazebo integrates perfectly with the ROS software platform (Robot Operating System), which means that the virtual robot management program developed by you in Gazebo and ROS will be relatively easy to transfer to a real robot.
PR2 robot in Gazebo simulatorIn this tutorial we will learn how to install the latest version of Gazebo, connect it to the
ROS software platform, load the physical model of the DARwin robot and make it walk. At the end, we will set up a simple remote control system for the movement of the robot from the keyboard. In parallel, we will master the ROS infrastructure.
ROS installation
The first and most laborious step is the installation of ROS and Gazebo. To install ROS, we need a PC with Linux (for example, Ubuntu 15.04). If you are a Windows or Mac OS user, you can use a virtual machine, for example, Virtual Box with the installation of Linux Ubuntu. I just want to note that I was not able to set up normal 3D support under the virtual machine, Gazebo either crashed or worked with brakes. Therefore, as a workout, you can use a virtual machine, but for real development, it is advisable to still use Linux.
ROS can be installed in two ways. The first method is relatively simple - this is the installation of ready-made Debian packages. This method is suitable if you have installed Ubuntu Saucy (13.10) or Trusty (14.04), or, for example, Debian Wheezy. The second method is more complicated and confusing - this is installation from source. With it, you can install ROS in more recent versions of Ubuntu or other Linux distributions.
The installation example below was carried out in Linux Ubuntu 15.04.
So let's get started!
Open bash terminal through the program menu or by pressing the key combination ctrl + alt + t. First you need to install the utilities for booting and initializing ROS. If you are using Ubuntu or Debian, this can be done by adding a link to packages.ros.org in the repository.
$ sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list' $ wget https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -O - | sudo apt-key add - $ sudo apt-get update $ sudo apt-get install python-rosdep python-rosinstall-generator python-wstool python-rosinstall build-essential
CommentYou can do the same with the pip package manager, but for Ubuntu users, the first option is preferable.
$ sudo apt-get install python-pip $ sudo pip install -U rosdep rosinstall_generator wstool rosinstall
Initialize rosdep. Rosdep is a command line tool for installing ROS system dependencies.
$ sudo rosdep init $ rosdep update
Now let's start building ROS packages using the catkin utility. Catkin is a set of macros for building and managing ROS infrastructure.
Create a directory to install ROS and download the key packages.
$ mkdir ~/workspace/ros -p $ cd ~/workspace/ros
The rosinstall_generator command creates a list of packages required for the ROS installation, as parameters the minimum installation of ros_comm, basic desktop or full desktop_full can be specified. The desktop_full installation includes the Gazebo 2.0 version. This version is outdated, the current version is 5.x. Therefore, we will select the desktop configuration, and install Gazebo separately.
$ rosinstall_generator desktop --rosdistro indigo --deps --wet-only --tar > indigo-desktop-wet.rosinstall
After the list of packages for installation is generated in the indigo-desktop-wet.rosinstall file, we will use the wstool utility to initialize the workspace and load the packages.
$ wstool init src indigo-desktop-wet.rosinstall
CommentIf for some reason the installation was interrupted, you can resume the process with the following command.
$ wstool update -t src
After installation, you can find the downloaded packages in the src directory.Now let's move to the ros root directory and execute the rosdep command to install the system dependencies for the downloaded packages.
$ cd ~/workspace/ros $ rosdep install --from-paths src --ignore-src --rosdistro indigo -y
After successfully installing all dependencies, you can finally compile the packages using the catkin build automation system. This is done with the catkin_make_isolated command or with the catkin_make command. Catkin_make_isolated should be used if part of your packages use CMake (another popular build automation system), and part catkin, if all packages use catkin, you should use catkin_make. The base repository has a mixed type, so we use the catkin_make_isolated command.
$ ./src/catkin/bin/catkin_make_isolated --install -DCMAKE_BUILD_TYPE=Release
In order for the ROS infrastructure to work, you need to set up environment variables and prescribe all the necessary paths. To do this, run the setup.bash script.
$ source ~/workspace/ros/install_isolated/setup.bash
This command will set up environment variables for the current bash console only. If you want to add ROS environment variables to bash by default, you can write the source command to the .bashrc file. This file is executed when opening a new bash console.
$ echo "source ~/workspace/ros/install_isolated/setup.bash" > ~/.bashrc
Congratulations! At this point, the ROS installation is complete, let's execute a few commands to check the correctness of the work.
To list the available commands for managing the ROS infrastructure, type ros in the console and press the Tab key two times. Since all ROS commands start with the prefix ros, bash will display their names as a result of auto-completion.
List of ROS commands. All commands begin with the prefix rosLet's run something, such as simple remote control. First we need an object that we want to control, let it be a turtle from the turtlesim. So, we start the turtlesim server using the rosrun command. To do this, open a new console and execute the command.
$ rosrun turtlesim turtlesim_node
A window with a bug will appear on the screen. Now let's launch the telecontrol module, to do this, open a new console and execute the command.
$ rosrun turtlesim turtle_teleop_key
And now use the arrow keys to try to move the turtle. For example, like this.
Turtle telecontrol exampleSo, we have just built a distributed system for telecontrol, where turtlesim and teleop are independent processes communicating through the ros_comm middleware. The turtlesim and teleop processes can be located on one or on different PCs connected to a network. You can display the relationship of these processes using the rqt_graph utility.
$ rosrun rqt_graph rqt_graph
The rqt_graph utility is used to display the topology of a distributed robot control system.In rqt_graph, various processes (nodes) of our control system are circled in ovals, and rectangles are data types (topics) used to transfer information between processes. Arrows indicate the direction of data transfer. Thus, we see that the teleop node publishes the cmd_vel topic, which contains the robot’s specified speed, and the turtlesim is subscribed to this topic.
You can look at the contents of the topic using the rostopic command. The list parameter will display all active topics on the system, and the echo command will display the contents of the specified topic. To display the contents of cmd_vel, do not forget to steer a turtle from a nearby console, otherwise the data will not be transmitted.
$ rostopic list $ rostopic echo /turtle1/cmd_vel
Content / turtle1 / cmd_vel - set linear and angular velocity of the turtleAfter the successful installation of ROS, let's proceed to the installation of the Gazebo simulator.
Install gazebo
Gazebo we will not compile from source, but simply install the latest version using the Ubuntu package manager. To do this, we will connect the repository with Gazebo, add the key and install it.
$ sudo sh -c 'echo "deb http://packages.osrfoundation.org/gazebo/ubuntu `lsb_release -cs` main" > /etc/apt/sources.list.d/gazebo-latest.list' $ wget http://packages.osrfoundation.org/gazebo.key -O - | sudo apt-key add - $ sudo apt-get update $ sudo apt-get install gazebo5 libgazebo-dev
Now you need to configure the rosdep configuration so that the system ignores the dependency of the packages on the older version of Gazebo, which is part of ROS Indigo, and would use the latest version that we just installed. To do this, we will go to the rosdep configuration files directory, create a local.yaml file, in which we will specify to ignore the gazebo package. Next, go to the sources.list.d directory and add the script you just created to the 10-local.list list. Next, run the update command in order for the new configuration to take effect.
$ cd /etc/ros/rosdep $ sudo bash -c 'echo "gazebo: { ubuntu: { vivid: [] } }" > local.yaml' $ cd ./sources.list.d $ sudo bash -c 'echo "yaml file:///etc/ros/rosdep/local.yaml" > 10-local.list' $ rosdep update
At the final stage, it is necessary to install the connecting packages Gazebo simulator with the ROS infrastructure, as well as packages describing the 3D model and the DARwIn-OP robot controllers. To simplify this process, we have prepared a small script that will load all the necessary dependencies.
Go to the working directory and download the script from our repository on github.
$ cd ~/workspace $ git clone https://github.com/robotgeeks/ros_gazebo_darwin.git
Next, go to the ros_gazebo_darwin directory, as described earlier, initialize the catkin workspace and load the packages listed in the indigo-gazebo-darwin.rosinstall file.
$ cd ~/workspace/ros_gazebo_darwin $ wstool init src indigo-gazebo-darwin.rosinstall
Next, we compile and install the newly downloaded packages.
$ catkin_make install
Now add the environment variables and paths for our workspace. To do this, run the following commands.
$ source ~/workspace/ros_gazebo_darwin/install/setup.bash $ echo "source ~/workspace/ros_gazebo_darwin/install/setup.bash" > ~/.bashrc
Fine! The installation of Gazebo and the DARwIn-OP model was successfully completed, let's run the result as soon as possible.
Work in the simulator Gazebo
Finally, after much suffering, it is time to launch a simulator with a model of a robot. To do this, use the roslaunch command to execute the darwin_gazebo.launch script.
$ roslaunch darwin_gazebo darwin_gazebo.launch
The result of the script execution should be the launch of the Gazebo window and the loading of the 3D model of the robot with the corresponding virtual controllers and sensors. To start the simulation, you need to press the play button located at the bottom of the window on the virtual timer panel.
Gazebo simulator with a loaded robot model DARwIn-OP. (Don't forget to click on the play button marked red)Now we will open a new console and launch the robot motion control program. It converts speed commands from Cartesian coordinates to the movement of servomotors located in the legs, torso and arms of a robot.
$ roslaunch darwin_gazebo darwin_walker.launch
Finally, in the third console, launch the telecontrol program. Its task is to read commands from the keyboard, convert them to a given speed and transfer to the motion control program.
$ roslaunch darwin_control darwin_teleop.launch
Telecontrol robot DARwIn-OP in the simulator GazeboThose who are interested in how the structure of our telecontrol system looks like can use the rqt_graph utility to graphically display the processes and channels of communication launched by ROS.
$ rosrun rqt_graph rqt_graph
As you can see, compared with the example of turtlesim, this control system is much more complicated and has more elements. This number of elements is due to the fact that the Darwin-OP model has 24 virtual servomotors that are controlled by the darwin_walker and walker programs, receiving the set speed from the darwin_teleop program.
The device control system robot DARwIn-OP in the simulator GazeboSummarize. In this lesson, we learned how to install and compile ROS Indigo from source code. We did this for educational purposes, to get a little closer with the device of the ROS system and its commands, as well as to connect the latest version of the Gazebo 3D simulator. Next, we uploaded a model of a humanoid robot DARwIn-OP, produced by Robotis, and set up a simple control system. Thanks to the ROS capabilities, our systems can work on one or several PCs connected to a network.
In the next lesson we will continue to get acquainted with the possibilities of ROS, we will try to add new objects to the virtual world of the robot, for example, a ball and a goal. We will write our own program to recognize the ball and control movement at a given point and, of course, will make a shot on goal!
See you!
Sources:
www.ros.orgwww.gazebosim.orgwww.generationrobots.com/en/content/83-carry-out-simulations-and-make-your-darwin-op-walk-with-gazebo-and-ros