Skip to content

Latest commit

 

History

History
185 lines (137 loc) · 6.64 KB

how-to-use-plugins-with-ergoCub.md

File metadata and controls

185 lines (137 loc) · 6.64 KB

How to use gz‐sim‐yarp‐plugins with ergoCub

This document explains how to install and use ergoCub in the Modern Gazebo (gz-sim) simulator through gz-sim-yarp-plugins.

Note

For the time being this guide will provide operative instructions only for Linux distributions; instructions will also be provided for Windows and macOS in the future.

Note that some features of the ergocub model (mainly the depth sensors and the hands) are not supported, see #137 for more details.

Table of Contents

Installation

The easiest ways to setup an environment with everything we need is to follow only one of the following two options:

Conda environment

Install a conda distribution

If you do not have one, please install a conda distribution. We suggest to use the minimal miniforge distribution, which uses conda-forge packages by default.

To install miniforge, please follow the instructions in install-miniforge documentation.

Create an environment

Then create the following environment with all the packages needed:

conda create -n ergocub-gz libgz-sim-yarp-plugins ergocub-software

Once you did this, you can activate it with:

conda activate ergocub-gz

Installation via robotology-superbuild

robotology-superbuild is a meta repository that is able to download and compile a plethora of software from the robotology organization.

First of all, we have to configure the superbuild such that it will download and install the software we need. It is possible to do this by enabling the appropriate options: in particular, we need to enable the ROBOTOLOGY_ENABLE_CORE profile with ROBOTOLOGY_USES_GZ option and disable the ROBOTOLOGY_USES_GAZEBO one.

Follow the source installation guide to install the required software.

World creation

In Modern Gazebo the preferred way to initialize the simulator is by providing a World: an SDF file that contains everything we need to simulate our scenario.

In a directory of your choice, create a file called ergocub-world.sdf and fill it by copy-pasting the following content:

<?xml version="1.0"?>

<sdf version="1.11">
    <world name="tutorial_controlboard">
        <physics name="1ms" type="ignored">
            <max_step_size>0.001</max_step_size>
            <real_time_factor>1.0</real_time_factor>
        </physics>
        <plugin
            filename="gz-sim-physics-system"
            name="gz::sim::systems::Physics">
        </plugin>
        <plugin
            filename="gz-sim-user-commands-system"
            name="gz::sim::systems::UserCommands">
        </plugin>
        <plugin
            filename="gz-sim-sensors-system"
            name="gz::sim::systems::Sensors">
        </plugin>
        <plugin
            filename="gz-sim-scene-broadcaster-system"
            name="gz::sim::systems::SceneBroadcaster">
        </plugin>
        <plugin
            filename="gz-sim-contact-system"
            name="gz::sim::systems::Contact">
        </plugin>

        <!-- YARP CLOCK -->
        <plugin
            filename="gz-sim-yarp-clock-system"
            name="gzyarp::Clock">
        </plugin>

        <light type="directional" name="sun">
            <cast_shadows>true</cast_shadows>
            <pose>0 0 10 0 0 0</pose>
            <diffuse>0.8 0.8 0.8 1</diffuse>
            <specular>0.2 0.2 0.2 1</specular>
            <attenuation>
                <range>1000</range>
                <constant>0.9</constant>
                <linear>0.01</linear>
                <quadratic>0.001</quadratic>
            </attenuation>
            <direction>-0.5 0.1 -0.9</direction>
        </light>

        <model name="ground_plane">
            <static>true</static>
            <link name="link">
                <collision name="collision">
                    <geometry>
                        <plane>
                            <normal>0 0 1</normal>
                            <size>100 100</size>
                        </plane>
                    </geometry>
                </collision>
                <visual name="visual">
                    <geometry>
                        <plane>
                            <normal>0 0 1</normal>
                            <size>100 100</size>
                        </plane>
                    </geometry>
                    <material>
                        <ambient>0.8 0.8 0.8 1</ambient>
                        <diffuse>0.8 0.8 0.8 1</diffuse>
                        <specular>0.8 0.8 0.8 1</specular>
                    </material>
                </visual>
            </link>
        </model>

        <include>
            <uri>model://ergoCub/robots/ergoCubGazeboV1_1</uri>
        </include>

    </world>
</sdf>

Run the simulation

To run the simulation, open a terminal, navigate to the folder containing the world file (otherwise prefix the world filename with the path to it) and execute the following command:

gz sim ergocub-world.sdf

The simulator should open in a paused state with ergoCub in place. To start the simulation just click on the play button on the bottom left.

image

Gazebo + YARP = ❤️

Things get interesting when gz-sim-yarp-plugins are used to connect the Gazebo simulation via to YARP devices able to interact with it.

For example, one could use yarpmotorgui to control the robot joints.

To do this, we need three terminals:

  1. In the first one, start a yarp server by executing:
yarp server
  1. In the second terminal, launch the simulator by executing:
gz sim ergocub-world.sdf

and start the simulation; 3. In the third one launch the yarpmotorgui by executing:

yarpmotorgui --robot ergocubSim

Then click Ok on the panel asking which robot parts to control and finally you should be able to control each joint of the ergoCub robot: image