Skip to content

Commit 0567206

Browse files
authored
Porting to WBToolbox v.5.0 (#63)
* cleanup * migration to wb5.0 * new yoga controller under testing * almost working yoga demo * working yoga in simulation * added compatibility with matlab 2017b * updated readme * bugfix after testing on iCubGenova04 * models ported to WBT5 * updated simulink GUI
1 parent 36366c7 commit 0567206

File tree

160 files changed

+52369
-70336
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

160 files changed

+52369
-70336
lines changed

.gitattributes

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,3 @@
22
*.mdl -crlf -diff -merge
33
*.mat -crlf -diff -merge
44
*.mlx -crlf -diff -merge
5-

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,3 @@ slprj/
4343
##---------------------------------------------------
4444
*.sublime-project
4545
*.sublime-workspace
46-

CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
1818
include(RegisterMdl)
1919
initialize_mdl_set(NAME WHOLE_BODY_CONTROLLERS)
2020

21-
add_subdirectory(torque-controllers)
21+
add_subdirectory(controllers)
2222

2323
# ============================
2424
# EXPORT AUTOGENERATED SOURCES
@@ -73,4 +73,4 @@ add_custom_command(TARGET copy-autogenerated-models
7373
POST_BUILD
7474
COMMAND ${CMAKE_COMMAND} -E copy_directory "${CMAKE_BINARY_DIR}/autogenerated" "${AUTOGENERATED_WBC_SOURCE_DIR}/autogenerated"
7575
COMMENT "Copying generated files to ${AUTOGENERATED_WBC_SOURCE_DIR}/autogenerated"
76-
)
76+
)

README.md

Lines changed: 62 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,42 @@
11
# whole-body-controllers
22

3-
Simulink-based whole body controllers for humanoid robots.
3+
Simulink-based whole-body controllers for humanoid robots.
44

55
## Dependencies
66

7-
This repository depends upon the following Software/repositories:
7+
This repository depends upon the following Software:
88

99
- [Matlab/Simulink](https://it.mathworks.com/products/matlab.html), default version **R2017b**
10-
- [WB-Toolbox](https://github.com/robotology/WB-Toolbox)
10+
- [WB-Toolbox](https://github.com/robotology/WB-Toolbox) and [blockfactory](https://github.com/robotology/blockfactory)
1111
- [Gazebo Simulator](http://gazebosim.org/), default version **9.0**
1212
- [gazebo-yarp-plugins](https://github.com/robotology/gazebo-yarp-plugins)
13-
- [icub-gazebo](https://github.com/robotology/icub-gazebo) and [icub-gazebo-wholebody](https://github.com/robotology-playground/icub-gazebo-wholebody) to access iCub models.
13+
- [icub-gazebo](https://github.com/robotology/icub-gazebo), [icub-gazebo-wholebody](https://github.com/robotology-playground/icub-gazebo-wholebody) and [icub-models](https://github.com/robotology/icub-models) to access iCub models.
1414
- [codyco-modules](https://github.com/robotology/codyco-modules) (Optional, for using [home positions](https://github.com/robotology/codyco-modules/tree/master/src/modules/torqueBalancing/app/robots) and [wholeBodyDynamics](https://github.com/robotology/codyco-modules/tree/master/src/devices/wholeBodyDynamics) device).
1515

16-
**NOTE:** it is suggested to install `whole-body-controllers` and most of its dependencies (namely, `codyco-modules`,`icub-gazebo`,`icub-gazebo-wholebody`, `gazebo-yarp-plugins` and `WB-Toolbox` and their dependencies) using the [robotology-superbuild](https://github.com/robotology/robotology-superbuild) (enable `ROBOTOLOGY_USES_GAZEBO`, `ROBOTOLOGY_ENABLE_DYNAMICS`, `ROBOTOLOGY_USES_MATLAB` options).
17-
1816
## Installation and usage
1917

20-
- clone the repository on your pc by running on a terminal `git clone https://github.com/robotology/whole-body-controllers`, or dowload the repository.
18+
**NOTE:** it is suggested to install `whole-body-controllers` and most of its dependencies (namely, `codyco-modules`,`icub-gazebo`,`icub-gazebo-wholebody`, `icub-models`, `gazebo-yarp-plugins`, `blockfactory` and `WB-Toolbox` and their dependencies) using the [robotology-superbuild](https://github.com/robotology/robotology-superbuild) (enable `ROBOTOLOGY_USES_GAZEBO`, `ROBOTOLOGY_ENABLE_DYNAMICS`, `ROBOTOLOGY_USES_MATLAB` options).
19+
20+
- Otherwise, clone the repository on your pc by running on a terminal `git clone https://github.com/robotology/whole-body-controllers`, or dowload the repository.
2121

2222
- set the environmental variable `YARP_ROBOT_NAME` in the `.bashrc` file to be the name of the robot you want to control. List of supported robot names:
2323

2424
| Robot Names | Associated URDF Model |
2525
|:-------------:|:-------------:|
2626
| iCubGenova02 | [model.urdf](https://github.com/robotology/icub-models/blob/master/iCub/robots/iCubGenova02/model.urdf) |
2727
| iCubGenova04 | [model.urdf](https://github.com/robotology/icub-models/blob/master/iCub/robots/iCubGenova04/model.urdf) |
28-
| iCubGazeboV2_5 |[model.urdf](https://github.com/robotology/icub-models/blob/master/iCub/robots/iCubGazeboV2_5/model.urdf)|
28+
| iCubGazeboV2_5|[model.urdf](https://github.com/robotology/icub-models/blob/master/iCub/robots/iCubGazeboV2_5/model.urdf)|
2929
| icubGazeboSim |[model.urdf](https://github.com/robotology/yarp-wholebodyinterface/blob/master/app/robots/icubGazeboSim/model.urdf) |
3030

31-
- to use the Simulink controllers, it is required to add the [matlab-wbc](library/matlab-wbc) folder to the Matlab path. There are two different possible ways to add the folder to the path:
32-
- directly add the folder to the Matlab path;
33-
- run **only once** the [startup.m](config/startup.m) script. In this case, it is required to **always** start matlab from the folder where the `pathdef.m` file is (usually `~/Documents/MATLAB`). For further information see also the [WBToolbox documentation](https://robotology.github.io/wb-toolbox/mkdocs/install/#matlab).
31+
- to use the Simulink controllers, it is **required** to add the [matlab-wbc](library/matlab-wbc) folder to the Matlab path. There are two different possible ways to add the folder to the path:
32+
- manually add the folder to the Matlab path;
33+
- run **only once** the [startup_WBC.m](config/startup_WBC.m) script. In this case, it is required to **always** start matlab from the folder where the `pathdef.m` file is (usually `~/Documents/MATLAB`). For further information see also the [WBToolbox documentation](https://robotology.github.io/wb-toolbox/mkdocs/install/#matlab).
34+
35+
**Note**: to use any function inside the package [matlab-wbc/+wbc](library/matlab-wbc/+wbc), add the `wbc` prefix to the function name when the function is invoked, i.e.
36+
37+
`[outputs] = wbc.myFunction(inputs)`.
3438

35-
**Note**: to use any function inside the package [matlab-wbc/+wbc](library/matlab-wbc/+wbc), add the `wbc` prefix to the function name when the function is invoked, i.e. `[outputs] = wbc.myFunction(inputs)`. More information can be found in the [Matlab documentation](https://it.mathworks.com/help/matlab/matlab_oop/scoping-classes-with-packages.html).
39+
More information on packages can be found in the [Matlab documentation](https://it.mathworks.com/help/matlab/matlab_oop/scoping-classes-with-packages.html).
3640

3741
## Troubleshooting
3842

@@ -42,57 +46,71 @@ Please refer to the [WBToolbox troubleshooting documentation](https://robotology
4246

4347
- **config**: a collection of scripts for correctly configure this repo. [[README]](config/README.md)
4448

45-
- **torque-controllers**: Simulink torque controllers for balancing and walking of humanoid robots. [[README]](torque-controllers/README.md)
49+
- **controllers**: Simulink whole-body position and torque controllers for balancing of humanoid robots. [[README]](controllers/README.md)
4650

4751
- **doc**: guidelines on how to create/use Simulink models for control. [[README]](doc/README.md)
4852

4953
- **library**: a library of functions/scripts used by the controllers. [[README]](library/README.md)
5054

5155
- **utilities**: Simulink models for debugging sensors on the real robot. [[README]](utilities/README.md)
5256

53-
## Interesting features
54-
55-
### Automatic generation of c++ code from Simulink
56-
57-
There is the possibility to generate c++ code from the Simulink models using [Simulink coder](https://www.mathworks.com/products/simulink-coder.html) (**available only for the [momentum-based-yoga](torque-controllers/momentum-based-yoga)**). The repositiory that contains the generated c++ code is named [autogenerated-whole-body-controllers](https://github.com/robotology-playground/autogenerated-whole-body-controllers). Documentation on how to generate the code is available in the repository [wiki](https://github.com/robotology-playground/autogenerated-whole-body-controllers/wiki/How-to-generate-code-from-a-Simulink-model).
57+
### Available controllers
5858

59-
### Static GUI for Simulink
60-
61-
When used for controlling real platforms, heavy Simulink models may violate the user-defined simulation time step, see also [this issue](https://github.com/robotology/wb-toolbox/issues/160). It seems a source of delay is the run-time update of the Simulink interface. For this reason, a [static GUI for running the models](library/matlab-gui) has been developed. **Available only for [momentum-based-yoga](torque-controllers/momentum-based-yoga) and [momentum-based-standup](torque-controllers/momentum-based-standup)**. If you want to run Simulink with the static GUI, just run the [start{$SIM_NAME}WithoutSimulinkGui](torque-controllers/momentum-based-yoga/startYogaWithoutSimulinkGui.m) script.
59+
- [fixed-base-joints-control](controllers/fixed-base-joints-control/README.md)
60+
- [floating-base-balancing-position-control](controllers/floating-base-balancing-position-control/README.md)
61+
- [floating-base-balancing-torque-control](controllers/floating-base-balancing-torque-control/README.md)
6262

63-
## Where do I find new features and legacy repos?
63+
### Matlab functions library
6464

65-
#### Available controllers
65+
- [matlab WBC library](library/matlab-wbc)
6666

67-
- [impedance-control](https://github.com/robotology/whole-body-controllers/tree/master/torque-controllers/impedance-control)
68-
- [momentum-based-standup](https://github.com/robotology/whole-body-controllers/tree/master/torque-controllers/momentum-based-standup)
69-
- [momentum-based-yoga](https://github.com/robotology/whole-body-controllers/tree/master/torque-controllers/momentum-based-yoga)
70-
- [utilities](https://github.com/robotology/whole-body-controllers/tree/master/utilities)
67+
## Additional features
7168

72-
#### Matlab functions library
69+
### Automatic generation of c++ code from Simulink
7370

74-
- [matlab library](library/matlab-wbc)
71+
There is the possibility to generate c++ code from the Simulink models using [Simulink coder](https://www.mathworks.com/products/simulink-coder.html) (**available only for the [floating-base-balancing-torque-control](controllers/floating-base-balancing-torque-control)**). The repositiory that contains the generated c++ code is named [autogenerated-whole-body-controllers](https://github.com/robotology-playground/autogenerated-whole-body-controllers). Documentation on how to generate the code is available in the repository [wiki](https://github.com/robotology-playground/autogenerated-whole-body-controllers/wiki/How-to-generate-code-from-a-Simulink-model).
7572

76-
#### Active Forks (new features)
73+
### Static GUI for Simulink
7774

78-
- [force-parametrization](https://github.com/ahmadgazar/whole-body-controllers)
79-
- [PhRI-standup](https://github.com/Yeshasvitvs/wholeBodyControllers)
75+
When used for controlling real platforms, heavy Simulink models may violate the user-defined simulation time step, see also [this issue](https://github.com/robotology/wb-toolbox/issues/160). It seems a source of delay is the run-time update of the Simulink interface. For this reason, a [static GUI for running the models](library/matlab-gui) has been developed. If you want to run Simulink with the static GUI, run the [startModelWithStaticGui](controllers/floating-base-balancing-torque-control/startModelWithStaticGui.m) script.
8076

81-
#### Legacy
77+
## Where do I find legacy materials?
8278

83-
Official legacy repositories are: [mex-wholebodymodel](https://github.com/robotology/mex-wholebodymodel) and [WBI-Toolbox-controllers](https://github.com/robotology-playground/WBI-Toolbox-controllers). **Note**: these legacy repos contain undocumented/outdated code, and duplicated or not tested matlab functions. They also contain original code that has been tested on the robot in the past and then never used again, or code that will be ported in the main repository in the future.
79+
Official legacy repositories are: [mex-wholebodymodel](https://github.com/robotology/mex-wholebodymodel) and [WBI-Toolbox-controllers](https://github.com/robotology-legacy/WBI-Toolbox-controllers). **Note**: these legacy repos contain undocumented/outdated code, and duplicated or not tested matlab functions. They also contain original code that has been tested on the robot in the past and then never used again, or code that will be ported in the main repository in the future.
8480

85-
- [exploit friction and walking controller](https://github.com/robotology-playground/WBI-Toolbox-controllers/tree/whole-body-controllers-legacy/controllers/legacy)
86-
- [seesaw controller and integration-based-ikin](https://github.com/robotology-playground/WBI-Toolbox-controllers/tree/whole-body-controllers-legacy/controllers/legacy)
81+
- [exploit friction and walking controller](https://github.com/robotology-legacy/WBI-Toolbox-controllers/tree/whole-body-controllers-legacy/controllers/legacy)
82+
- [seesaw controller](https://github.com/robotology-legacy/WBI-Toolbox-controllers/tree/whole-body-controllers-legacy/controllers/legacy)
8783
- [automatic gain tuning](https://github.com/robotology/mex-wholebodymodel/tree/master/controllers/torqueBalancingGainTuning)
8884
- [elastic joints control](https://github.com/robotology/mex-wholebodymodel/tree/master/controllers/torqueBalancing_JE)
89-
- [walkman control](https://github.com/robotology-playground/WBI-Toolbox-controllers/tree/whole-body-controllers-legacy/controllers/legacy/torqueBalancing-walkman) and [walkman control-matlab](https://github.com/robotology/mex-wholebodymodel/tree/master/controllers/torqueBalancingWalkman)
85+
- [walkman control](https://github.com/robotology-legacy/WBI-Toolbox-controllers/tree/whole-body-controllers-legacy/controllers/legacy/torqueBalancing-walkman) and [walkman control-matlab](https://github.com/robotology/mex-wholebodymodel/tree/master/controllers/torqueBalancingWalkman)
9086
- [joint-space control and centroidal transformation](https://github.com/robotology/mex-wholebodymodel/tree/master/controllers/torqueBalancingJointControl)
9187

92-
#### Associated repositories
93-
94-
- [matlab-multi-body-sim](https://github.com/gabrielenava/matlab-multi-body-sim)
95-
96-
### Mantainers
97-
98-
Gabriele Nava ([@gabrielenava](https://github.com/gabrielenava))
88+
## Citing this work
89+
90+
If you are using this code for your research activity and you're willing to cite it, you may add the following references to your bibliography:
91+
92+
```
93+
@INPROCEEDINGS{Nava_etal2016,
94+
author={G. Nava and F. Romano and F. Nori and D. Pucci},
95+
booktitle={2016 IEEE/RSJ International Conference on Intelligent Robots and Systems (IROS)},
96+
title={Stability analysis and design of momentum-based controllers for humanoid robots},
97+
year={2016},
98+
pages={680-687},
99+
doi={10.1109/IROS.2016.7759126},
100+
month={Oct},
101+
}
102+
```
103+
104+
```
105+
@article{Nori_etal2015,
106+
author="Nori, F. and Traversaro, S. and Eljaik, J. and Romano, F. and Del Prete, A. and Pucci, D.",
107+
title="iCub whole-body control through force regulation on rigid non-coplanar contacts",
108+
year="2015",
109+
journal="Frontiers in {R}obotics and {A}{I}",
110+
volume="1",
111+
}
112+
```
113+
114+
## Mantainers
115+
116+
Gabriele Nava ([@gabrielenava](https://github.com/gabrielenava))

cmake/CreateAutogeneratedCodeTargets.cmake.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ add_executable(${CODER_MAIN}
1919
"${CMAKE_CURRENT_BINARY_DIR}/driver.cpp"
2020
)
2121

22-
target_link_libraries(${CODER_MAIN} PUBLIC ${MDL_NAME}_LIB)
22+
target_link_libraries(${CODER_MAIN} PUBLIC ${MDL_NAME}_LIB)

cmake/RegisterMdl.cmake

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ function(initialize_mdl_set)
2525
FULL_DOCS "Array with the path of the folders to export containing autogenerated code.")
2626
endfunction()
2727

28-
2928
function(register_mdl)
3029

3130
# ===============
@@ -63,4 +62,4 @@ function(register_mdl)
6362
# Register the mdl by appending its name to the global property
6463
set_property(GLOBAL APPEND PROPERTY ${SETNAME} ${AUTOGENSOURCES_ABSPATH})
6564

66-
endfunction()
65+
endfunction()

config/README.md

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
11
# Configuration scripts
22

3-
A collection of scripts used for correctly configure the repo.
4-
5-
- [export_WBC.m](export_WBC.m): run this script once. Then, digit the Matlab version in which you want to export the Simulink models. All models in the repo will be exported in that version. By default, Simulnk models in this repo are written using Matlab 2017b. **Remember: you cannot export a model in a Matlab version newer than the one you are using**!
6-
7-
- [startup.m](startup.m): run this script once. Then, the path to the `matlab-wbc` folder will be permanently added to the `pathdef.m` file, which is saved inside the Matlab `userpath`. In order to have the `matlab-wbc` folder inside the Matlab path, it is required to start Matlab from the folder where the `pathdef.m` file is (in general, `~/Documents/MATLAB`).
8-
9-
10-
3+
A collection of scripts used for configuring the repo.
114

5+
- [export_WBC.m](export_WBC.m): run this script. Then, digit the Matlab version in which you want to export the Simulink models. All models in the repo will be exported to that version. By default, Simulnk models in this repo are written using Matlab 2017b. **Remember: you cannot export a model in a Matlab version newer than the one you are using**!
126

7+
- [startup_WBC.m](startup_WBC.m): run this script. Then, the path to the `matlab-wbc` folder will be **permanently** added to your `pathdef.m` file, which will be saved inside the Matlab `userpath`. In order to have the `matlab-wbc` folder inside the Matlab path, it is **required** to start Matlab from the folder where the `pathdef.m` file is (i.e., from the folder that the `userpath` is pointing, usually `~/Documents/MATLAB`).

config/startup.m renamed to config/startup_WBC.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
%% startup.m
1+
%% startup_WBC.m
22
%
3-
% Run this script only once to permanently add the matlab-wbc folder to your MATLAB path.
3+
% Run this script once to permanently add the matlab-wbc library to your MATLAB path.
44

55
fprintf('\n## whole-body-controllers ##\n');
6-
fprintf('\nAdding "matlab-wbc" to pathdef.m...\n\n');
6+
fprintf('\nAdding "matlab-wbc" library to pathdef.m...\n\n');
77

88
% path to whole-body-controllers
99
pathToWBC = pwd;

controllers/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
add_subdirectory(floating-base-balancing-torque-control)

controllers/README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Controllers
2+
3+
Simulink controllers for humanoid robots.
4+
5+
## List of available controllers:
6+
7+
- **fixed-base-joints-control** [[README]](fixed-base-joints-control/README.md)
8+
- **floating-base-balancing-position-control** [[README]](floating-base-balancing-position-control/README.md)
9+
- **floating-base-balancing-torque-control** [[README]](floating-base-balancing-torque-control/README.md)
10+
11+
## Usage
12+
13+
See corresponding READMEs, and check the [documentation](https://github.com/robotology-playground/whole-body-controllers/tree/master/doc) of the repo.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
## Module description
2+
3+
This module implements a simple torque control balancing strategy. The robot is assumed to have its `base_link` fixed on a pole. Input torques are the `gravity toruqes` which allow to perform **gravity compensation**. Optionally, it is also possible to move each controlled joint in order to track a desired joints trajectory.
4+
5+
### Compatibility
6+
7+
The folder contains the Simulink model `jointsControl.mdl`, which is generated by using Matlab R2017b.
8+
9+
### Supported robots
10+
11+
Currently, supported robots are: `iCubGenova04`, `iCunGenova02`, `icubGazeboSim`, `iCubGazeboV2_5`.
12+
13+
## Module details
14+
15+
### Configuration file
16+
17+
At start, the module calls the initialization file `initJointsControl.m`. Once opened, this file contains some configuration variables. Please follow the instruction inside the script to properly configure your simulation.
18+
19+
### Robot and demo specific configurations
20+
21+
The gains and references for a specific robot (specified by the variable `YARP_ROBOT_NAME`) or a specific demo can be found in the folder `app/robots/YARP_ROBOT_NAME`.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
% CONFIGJOINTSCONTROL configures all the options associated to the
2+
% joints controller.
3+
%
4+
5+
%% --- Initialization ---
6+
7+
% Default behaviour: gravity compensation. If Config.MOVE_JOINTS = true,
8+
% the robot will also move all actuated joints following a sine trajectory
9+
Config.MOVE_JOINTS = false;
10+
11+
% Max unsigned difference between two consecutive (measured) joint positions,
12+
% i.e. delta_jointPos = abs(jointPos(k) - jointPos(k-1)) [rad]
13+
Sat.maxJointsPositionDelta = 15*pi/180;

0 commit comments

Comments
 (0)