icub-tech-iit / ergocub-gazebo-simulations

Repository containing the models and the simulations for ergoCub
BSD 3-Clause "New" or "Revised" License
4 stars 0 forks source link

ergocub-gazebo-simulations

robots

Repository that contains some testing utilities for the ergocub project.

This repo contains a gazebo model, starting from iCub3, and some scripts that can easily modify it and test it in diverse scenarios. The goal of this repo is to gain knowledge about which is the best configuration for the ergoCub in terms of limb length, mass, etc.

Maintained by:

Installation using dependencies compiled from sources

Requirements:

Installation:

git clone https://github.com/icub-tech-iit/ergocub-gazebo-simulations.git
cd ergocub-gazebo-simulations
mkdir build
cd build
ccmake ..
CMAKE_INSTALL_PREFIX             <directory-where-you-downloaded-robotology-superbuild>/build/install
make install -j4

You should now see three new models when you open gazebo from the terminal:

newgazebobots

Finally, add export YARP_ROBOT_NAME=stickBot in your .bashrc.

Installation using dependencies compiled from binary

If you want to use ergocub-gazebo-simulations and you want to install gazebo-yarp-plugins and other dependencies from conda binaries, you can first of all create a new environment (you can skip this step if you already have an environment you want to use):

mamba create -n ergocubsim

Then, you can activate the environment and install the dependencies:

mamba activate ergocubsim
mamba install -c conda-forge -c robotology robotology-distro yarp icub-models gazebo-yarp-plugins gazebo whole-body-controllers walking-controllers cmake ninja whole-body-estimators

Clone this repo and create a build directory on it:

git clone https://github.com/icub-tech-iit/ergocub-gazebo-simulations.git
cd ergocub-gazebo-simulations
mkdir build
cd build

After that, you can install the repo with these commands on Windows:

cmake -GNinja -DCMAKE_INSTALL_PREFIX=%CONDA_PREFIX%\Library ..
ninja install

and with this command on Linux/macOS:

cmake -GNinja -DCMAKE_INSTALL_PREFIX=$CONDA_PREFIX ..
ninja install

You should now see three new models when you open gazebo from the terminal:

newgazebobots

Finally, set the YARP_ROBOT_NAME in your environment to stickBot, via the command:

conda env config vars set YARP_ROBOT_NAME=stickBot

After this, make sure that you re-activate your conda environment before using the simulator and the software that use the simulator.

Usage

Changing robot characteristics

cd scripts
./modify_robot.py # [-c {PATH}] [-r]

The modify_robot script changes the dimensions of the stickbot according to a configuration file. It also performs the installation step, so gazebo gets updated with the newest robot right away.

Flags:

The configuration file

The conf.ini file is a simple configuration file specifying the elements to modify:

[left_arm]
dimension = 0.65
radius = 0.45
density_scale = 1.5

[r_lower_leg]
dimension = 1.5

The upper section (the one inside []) specifies the element to modify, options include torso, right_arm, left_arm, right_leg, left_leg, arms, legs, all, or the name of an individual link (Caution: if a link and its respective limb are both specified, the changes could accumulate!). Sections with other names will be ignored.

For any element you can specify dimension, mass, density, and radius, which will set the specific property for all the valid links. If you want relative scaling you can instead add the _scale suffix and the factor to multiply to the original value. If a config section includes both an absolute and a scaling modifier the absolute one takes precedence. Mass modifications take precendence over density.

Holding Box Experiment

This sandbox uses the worldInterface gazebo yarp plugin. To run it:

cd experiments/hold_box
./hold_box.sh

This experiment creates a StickBot in gazebo with its hands open. Then, a box spawns on top and the robot holds it:

https://user-images.githubusercontent.com/31577366/132519425-fcfe1ce4-3acd-40fd-a878-298949b28ecb.mp4

Instead of closing every window that opens after the test, you can call the cleanup script:

./cleanup.sh

To change the properties of the box being spawned you can call the modify_box script:

./modify_box.py # [-p {X Y Z}] [-d {D W H}] [-m {MASS}] [-r]

After running the test, a new directory called telemetry_data will appear, use the plotTelemetry.m script in MATLAB to plot the results for the specific joints you need:

hold_box_matlab_plot

Flags:

ergocub-holding-bigger-box

Gym-like Movements Experiment

This experiment attaches weights to the stickBot and makes it perform gym-like motions, in order to isolate (to the stickBot's best abilities) the effort to single joints. This sandbox uses the worldInterface gazebo yarp plugin, then before running the script you must append to GAZEBO_MODEL_PATH the /my/workspace/robotology-superbuild/src/GazeboYARPPlugins/tutorial/model path. Then:

cd experiments/gym
./gym_session.sh # {curls lateral_raises front_raises}

The three possible experiments are the following:

Name Stressed Joint Example
curls r_elbow, l_elbow curl
front_raises r_shoulder_pitch, l_shoulder_pitch front-raise
lateral_raises r_shoulder_roll, l_shoulder_roll lateral-raise
twists torso_yaw twists
bends torso_roll bends
extensions torso_pitch extensions

After running the test, a new directory called telemetry_data will appear, use the plotTelemetry.m script in MATLAB to plot the results for the specific joints you need:

lateral_raise_116stickbot_7kg_torque

Walking and Balancing Experiment

These experiments implement walking and balancing, to stress the leg joints.

For running the walking experiment, just run the go_for_a_walk.sh script.

cd experiments/walking
./go_for_a_walk.sh

Gazebo will spawn, and the robot will walk like so:

https://user-images.githubusercontent.com/31577366/153621747-eeae3d75-001b-4086-b8e5-46c2099bb782.mp4

For this to work, WalkingModule needs to be installed in the system.

It is important to mention that the behavior can be unreliable, and the robot may some times fall. For this reason, the script runs Gazebo with a GUI (unlike the other experiments). This way one can run the experiment several times until a successful walk is achieved. Once the robot walks properly, you will have the data available.

The balancing experiment is ran using whole-body-controllers. Particularly, the floating-base-balancing-torque-control demo. You should launch Gazebo, spawn a stickbot and then run the simulink model. From there, you can use the plotTelemetry.m matlab script to visualize the data in the joints of interest.

https://user-images.githubusercontent.com/31577366/154500268-94a402ef-8b72-49fa-be5a-1301de6d4d92.mp4

Feedback and Collaboration

For bugs and feature requests feel free to submit an issue and we will look into it.