Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add repo matlab-whole-body-simulator #689

Merged
merged 9 commits into from
Apr 25, 2021
26 changes: 26 additions & 0 deletions cmake/Buildmatlab-whole-body-simulator.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Copyright (C) Fondazione Istituto Italiano di Tecnologia
# CopyPolicy: Released under the terms of the LGPLv2.1 or later, see LGPL.TXT
include(YCMEPHelper)
include(FindOrBuildPackage)

find_or_build_package(yarp-matlab-bindings QUIET)
find_or_build_package(WBToolbox QUIET)
find_or_build_package(icub-models QUIET)

set(matlab-whole-body-simulator_DEPENDS "")
list(APPEND matlab-whole-body-simulator_DEPENDS yarp-matlab-bindings)
list(APPEND matlab-whole-body-simulator_DEPENDS WBToolbox)
list(APPEND matlab-whole-body-simulator_DEPENDS icub-models)

ycm_ep_helper(matlab-whole-body-simulator TYPE GIT
STYLE GITHUB
REPOSITORY dic-iit/matlab-whole-body-simulator.git
TAG master
COMPONENT dynamics
FOLDER src
DEPENDS ${matlab-whole-body-simulator_DEPENDS})

# Metadata for conda package generation
# If we do not set the package name, by default the repo name would be used
# so in this case osqp-matlab-cmake-buildsystem that is not descriptive of the
# generated artifact that is contained in the conda package
1 change: 1 addition & 0 deletions cmake/RobotologySuperbuildLogic.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ if(ROBOTOLOGY_ENABLE_DYNAMICS)
find_or_build_package(YARP_telemetry)
if(ROBOTOLOGY_USES_MATLAB)
find_or_build_package(osqp-matlab)
find_or_build_package(matlab-whole-body-simulator)
endif()
endif()

Expand Down
6 changes: 3 additions & 3 deletions cmake/template/addPathsToUserEnvVariables.ps1.in
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ Add-ValueToUserEnvVariable CMAKE_PREFIX_PATH $ROBOTOLOGY_SUPERBUILD_INSTALL_PREF
# Setup the path of blockfactory plugins
Add-ValueToUserEnvVariable BLOCKFACTORY_PLUGIN_PATH $ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX"\@BLOCKFACTORY_PLUGIN_PATH_DIRECTORY@\blockfactory";

# Setup to find resources in URDF and SDF files
# Setup to find resources in URDF and SDF files
Add-ValueToUserEnvVariable ROS_PACKAGE_PATH $ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX"\share"
Add-ValueToUserEnvVariable AMENT_PREFIX_PATH $ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX"\share"
Add-ValueToUserEnvVariable GAZEBO_MODEL_PATH $ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX"\share\gazebo\models"
Expand Down Expand Up @@ -74,10 +74,10 @@ Add-ValueToUserEnvVariable PYTHONPATH $ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX"@ROB
@endcmakeif ROBOTOLOGY_USES_PYTHON

@cmakeif ROBOTOLOGY_USES_MATLAB
Add-ValueToUserEnvVariable YARP_DATA_DIRS $ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX"\share\RRbot";
Add-ValueToUserEnvVariable GAZEBO_MODEL_PATH $ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX"\share\RRbot\robots";
Add-ValueToUserEnvVariable MATLABPATH $ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX"\mex";
Add-ValueToUserEnvVariable MATLABPATH $ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX"\mex\+wbc\simulink";
Add-ValueToUserEnvVariable MATLABPATH $ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX"\share\WBToolbox";
Add-ValueToUserEnvVariable MATLABPATH $ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX"\share\WBToolbox\images";
@endcmakeif ROBOTOLOGY_USES_MATLAB


3 changes: 2 additions & 1 deletion cmake/template/removePathsFromUserEnvVariables.ps1.in
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,10 @@ Remove-ValueFromUserEnvVariable PYTHONPATH $ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX
@endcmakeif ROBOTOLOGY_USES_PYTHON

@cmakeif ROBOTOLOGY_USES_MATLAB
Remove-ValueFromUserEnvVariable YARP_DATA_DIRS $ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX"\share\RRbot";
Remove-ValueFromUserEnvVariable GAZEBO_MODEL_PATH $ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX"\share\RRbot\robots";
Remove-ValueFromUserEnvVariable MATLABPATH $ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX"\mex";
Remove-ValueFromUserEnvVariable MATLABPATH $ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX"\mex\+wbc\simulink";
Remove-ValueFromUserEnvVariable MATLABPATH $ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX"\share\WBToolbox";
Remove-ValueFromUserEnvVariable MATLABPATH $ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX"\share\WBToolbox\images";
@endcmakeif ROBOTOLOGY_USES_MATLAB

5 changes: 4 additions & 1 deletion cmake/template/setup.bat.in
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ set "CMAKE_PREFIX_PATH=%CMAKE_PREFIX_PATH%;%ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX
rem Setup BlockFactory plugins path
set BLOCKFACTORY_PLUGIN_PATH=%ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX%\@BLOCKFACTORY_PLUGIN_PATH_DIRECTORY@\blockfactory

rem Variables to find resources in URDF and SDF files
rem Variables to find resources in URDF and SDF files
set "ROS_PACKAGE_PATH=%ROS_PACKAGE_PATH%;%ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX%\share"
set "AMENT_PREFIX_PATH=%AMENT_PREFIX_PATH%;%ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX%\share"
set "GAZEBO_MODEL_PATH=%GAZEBO_MODEL_PATH%;%ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX%\share\gazebo\models;%ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX%\share\iCub\robots;%ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX%\share"
Expand Down Expand Up @@ -41,6 +41,9 @@ set "PYTHONPATH=%PYTHONPATH%;%ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX%\@ROBOTOLOGY_
@endcmakeif ROBOTOLOGY_USES_PYTHON

@cmakeif ROBOTOLOGY_USES_MATLAB
rem Set YARP and Gazebo related env variables
set "YARP_DATA_DIRS=%YARP_DATA_DIRS%;%ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX%\share\RRbot"
set "GAZEBO_MODEL_PATH=%GAZEBO_MODEL_PATH%;%ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX%\share\RRbot\robots"
rem Configure the Matlab
set "MATLABPATH=%MATLABPATH%;%ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX%\mex;%ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX%\mex\+wbc\simulink;%ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX%\share\WBToolbox;%ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX%\share\WBToolbox\images"
@endcmakeif ROBOTOLOGY_USES_MATLAB
3 changes: 3 additions & 0 deletions cmake/template/setup.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ export PYTHONPATH=${PYTHONPATH:+${PYTHONPATH}:}${ROBOTOLOGY_SUPERBUILD_INSTALL_P
@endcmakeif ROBOTOLOGY_USES_PYTHON

@cmakeif ROBOTOLOGY_USES_MATLAB
# Set YARP and Gazebo related env variables
export YARP_DATA_DIRS=$YARP_DATA_DIRS:${ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX}/share/RRbot
export GAZEBO_MODEL_PATH=$GAZEBO_MODEL_PATH:${ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX}/share/RRbot/robots
# Configure the Matlab path
export MATLABPATH=${MATLABPATH:+${MATLABPATH}:}${ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX}/mex:${ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX}/mex/+wbc/simulink:${ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX}/share/WBToolbox:${ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX}/share/WBToolbox/images
@endcmakeif ROBOTOLOGY_USES_MATLAB
22 changes: 6 additions & 16 deletions cmake/template/startup_robotology_superbuild.m.in
Original file line number Diff line number Diff line change
@@ -1,30 +1,20 @@
%% startup_robotology_superbuild.m
%
% Run this script only once to permanently add the required folders for using
% MATLAB toolbox (e.g. WBToolbox, whole-body-controllers) to your MATLAB path.
% MATLAB toolbox (e.g. WBToolbox, whole-body-controllers, matlab-whole-body-simulator) to your MATLAB path.

fprintf('\nMATLAB Toolbox\n');

installDir = '@YCM_EP_INSTALL_DIR@';
mexDir = [installDir, filesep, 'mex'];
simLibDir = [installDir, filesep, 'mex/+wbc/simulink'];
simLibDir = [installDir, filesep, 'mex/+wbc/simulink'];
shareDir = [installDir, filesep, 'share/WBToolbox'];
imgDir = [shareDir, filesep, 'images'];

if exist(mexDir, 'dir')
addpath(mexDir);
end

if exist(shareDir, 'dir')
addpath(shareDir);
end

if exist(imgDir, 'dir')
addpath(imgDir);
end

if exist(simLibDir, 'dir')
addpath(simLibDir);
for dirPath = {mexDir,simLibDir,shareDir,imgDir}
if exist(dirPath{1}, 'dir')
addpath(dirPath{1});
end
end

fileDir = userpath;
Expand Down
19 changes: 19 additions & 0 deletions conda/multisheller/matlab-whole-body-simulator_activate.msh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
if_(is_set("COMSPEC")).then_([
sys.list_append("YARP_DATA_DIRS", path.join(env("CONDA_PREFIX"), "Library\\share\\RRbot")),
sys.list_append("ROS_PACKAGE_PATH", path.join(env("CONDA_PREFIX"), "Library\\share")),
sys.list_append("AMENT_PREFIX_PATH", path.join(env("CONDA_PREFIX"), "Library\\share")),
sys.list_append("GAZEBO_MODEL_PATH", path.join(env("CONDA_PREFIX"), "Library\\share\\RRbot\\robots"))
]).else_([
sys.list_append("YARP_DATA_DIRS", path.join(env("CONDA_PREFIX"), "share/RRbot")),
sys.list_append("ROS_PACKAGE_PATH", path.join(env("CONDA_PREFIX"), "share")),
sys.list_append("AMENT_PREFIX_PATH", path.join(env("CONDA_PREFIX"), "share")),
sys.list_append("GAZEBO_MODEL_PATH", path.join(env("CONDA_PREFIX"), "share/RRbot/robots"))
])

# For some reason setting two times the same variable inside the same if does not work in command prompt
# As a workaround, we move each GAZEBO_MODEL_PATH set to a separate if
if_(is_set("COMSPEC")).then_([
sys.list_append("GAZEBO_MODEL_PATH", path.join(env("CONDA_PREFIX"), "Library\\share"))
]).else_([
sys.list_append("GAZEBO_MODEL_PATH", path.join(env("CONDA_PREFIX"), "share"))
])
19 changes: 19 additions & 0 deletions conda/multisheller/matlab-whole-body-simulator_deactivate.msh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
if_(is_set("COMSPEC")).then_([
sys.list_remove("YARP_DATA_DIRS", path.join(env("CONDA_PREFIX"), "Library\\share\\RRbot")),
sys.list_remove("ROS_PACKAGE_PATH", path.join(env("CONDA_PREFIX"), "Library\\share")),
sys.list_remove("AMENT_PREFIX_PATH", path.join(env("CONDA_PREFIX"), "Library\\share")),
sys.list_remove("GAZEBO_MODEL_PATH", path.join(env("CONDA_PREFIX"), "Library\\share\\RRbot\\robots"))
]).else_([
sys.list_remove("YARP_DATA_DIRS", path.join(env("CONDA_PREFIX"), "share/RRbot")),
sys.list_remove("ROS_PACKAGE_PATH", path.join(env("CONDA_PREFIX"), "share")),
sys.list_remove("AMENT_PREFIX_PATH", path.join(env("CONDA_PREFIX"), "share")),
sys.list_remove("GAZEBO_MODEL_PATH", path.join(env("CONDA_PREFIX"), "share/RRbot/robots"))
])

# For some reason setting two times the same variable inside the same if does not work in command prompt
# As a workaround, we move each GAZEBO_MODEL_PATH set to a separate if
if_(is_set("COMSPEC")).then_([
sys.list_remove("GAZEBO_MODEL_PATH", path.join(env("CONDA_PREFIX"), "Library\\share"))
]).else_([
sys.list_remove("GAZEBO_MODEL_PATH", path.join(env("CONDA_PREFIX"), "share"))
])
13 changes: 8 additions & 5 deletions doc/cmake-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ All these options are named `ROBOTOLOGY_ENABLE_<profile>` .
|:------------:|:-----------:|:---------------------:|:-------------:|:----:|
| `ROBOTOLOGY_ENABLE_CORE` | The core robotology software packages, necessary for most users. | [`YARP`](https://github.com/robotology/yarp), [`ICUB`](https://github.com/robotology/icub-main), [`ICUBcontrib`](https://github.com/robotology/icub-contrib-common), [`icub-models`](https://github.com/robotology/icub-models) and [`robots-configurations`](https://github.com/robotology/robots-configuration). [`GazeboYARPPlugins`](https://github.com/robotology/GazeboYARPPlugins) and [`icub-gazebo`](https://github.com/robotology/icub-gazebo) if the `ROBOTOLOGY_USES_GAZEBO` option is enabled. [`gym-ignition`](https://github.com/robotology/gym-ignition) if the `ROBOTOLOGY_USES_IGNITION` option is enabled. | `ON` | [Documentation on Core profile.](#core) |
| `ROBOTOLOGY_ENABLE_ROBOT_TESTING` | The robotology software packages related to robot testing. | [`RobotTestingFramework`](https://github.com/robotology/robot-testing-framework), [`icub-tests`](https://github.com/robotology/icub-tests), [`blocktest`](https://github.com/robotology/blocktest) and [`blocktest-yarp-plugins`](https://github.com/robotology/blocktest-yarp-plugins) | `OFF` | [Documentation on Robot Testing profile.](#robot-testing) |
| `ROBOTOLOGY_ENABLE_DYNAMICS` | The robotology software packages related to balancing, walking and force control. | [`iDynTree`](https://github.com/robotology/idyntree), [`blockfactory`](https://github.com/robotology/blockfactory), [`wb-Toolbox`](https://github.com/robotology/wb-Toolbox), [`whole-body-controllers`](https://github.com/robotology/whole-body-controllers), [`walking-controllers`](https://github.com/robotology/walking-controllers), [`matioCpp`](https://github.com/dic-iit/matio-cpp), [`bipedal-locomotion-framework`](https://github.com/dic-iit/bipedal-locomotion-framework), [`YARP_telemetry`](https://github.com/robotology/yarp-telemetry). | `OFF` | [Documentation on Dynamics profile.](#dynamics) |
| `ROBOTOLOGY_ENABLE_DYNAMICS` | The robotology software packages related to balancing, walking and force control. | [`iDynTree`](https://github.com/robotology/idyntree), [`blockfactory`](https://github.com/robotology/blockfactory), [`wb-Toolbox`](https://github.com/robotology/wb-Toolbox), [`whole-body-controllers`](https://github.com/robotology/whole-body-controllers), [`walking-controllers`](https://github.com/robotology/walking-controllers), [`matioCpp`](https://github.com/dic-iit/matio-cpp), [`bipedal-locomotion-framework`](https://github.com/dic-iit/bipedal-locomotion-framework), [`YARP_telemetry`](https://github.com/robotology/yarp-telemetry). Furthermore, [`osqp-matlab`](https://github.com/dic-iit/osqp-matlab-cmake-buildsystem) and [`matlab-whole-body-simulator`](https://github.com/dic-iit/matlab-whole-body-simulator) if `ROBOTOLOGY_USES_MATLAB` option is enabled. | `OFF` | [Documentation on Dynamics profile.](#dynamics) |
| `ROBOTOLOGY_ENABLE_DYNAMICS_FULL_DEPS` | Optional dependencies for [`bipedal-locomotion-framework`](https://github.com/dic-iit/bipedal-locomotion-framework). | [`manif`](https://github.com/artivis/manif), [`qhull`](https://github.com/qhull/qhull), [`casadi`](https://github.com/casadi/casadi). [`CppAD`](https://github.com/coin-or/CppAD). | `OFF` | [Documentation on Dynamics full deps profile.](#dynamics-full-deps) |
| `ROBOTOLOGY_ENABLE_ICUB_HEAD` | The robotology software packages needed on the system that is running on the head of the iCub robot, or in general to communicate directly with iCub low-level devices. | [`icub-firmware`](https://github.com/robotology/icub-firmware), [`icub-firmware-shared`](https://github.com/robotology/icub-firmware-shared), [`diagnostic-daemon`](https://github.com/robotology/diagnostic-daemon). Furthermore, several additional devices are compiled in `YARP` and `ICUB` if this option is enabled. | `OFF` | [Documentation on iCub Head profile.](#icub-head) |
| `ROBOTOLOGY_ENABLE_ICUB_BASIC_DEMOS` | The robotology software packages needed to run basic demonstrations with the iCub robot. | [`icub-basic-demos`](https://github.com/robotology/icub-basic-demos), [`speech`](https://github.com/robotology/speech), [`funny-things`](https://github.com/robotology/funny-things). | `OFF` | [Documentation on iCub Basic Demos profile.](#icub-basic-demos) |
Expand Down Expand Up @@ -237,8 +237,8 @@ This option is set to `OFF` on all platforms as it is still experimental.

### System Dependencies

Different Ignition distributions can be installed alongside.
The projects included in the superbuild might require different distributions.
Different Ignition distributions can be installed alongside.
The projects included in the superbuild might require different distributions.
From the superbuild point of view, we currently do not allow enabling projects that only support a specific Ignition distribution, therefore all required distributions have to be found in the system.

#### Using conda
Expand Down Expand Up @@ -277,10 +277,14 @@ can install some projects that depend on MATLAB, in particular:
* the MATLAB bindings of qpOASES, contained in the [robotology-dependencies/qpOASES](https://github.com/robotology-dependencies/qpOASES) fork,
* The [WB-Toolbox](https://github.com/robotology/WB-Toolbox) Simulink toolbox,
* The [whole-body-controllers](https://github.com/robotology/whole-body-controllers) Simulink-based balancing controllers. Note that whole-body-controllers can be installed and compiled also without MATLAB, but its functionalities are reduced.
* The [matlab-whole-body-simulator](https://github.com/dic-iit/matlab-whole-body-simulator) Simulink-based whole-body dynamics simulator with contacts handling.

To use this software, you can simply enable its compilation using the `ROBOTOLOGY_USES_MATLAB` CMake option.
Once this software has been compiled by the superbuild, you just need to add some directories of the robotology-superbuild install (typically `$ROBOTOLOGY_SUPERBUILD_SOURCE_DIR/build/install`) to [the MATLAB path](https://www.mathworks.com/help/matlab/matlab_env/what-is-the-matlab-search-path.html).
In particular you need to add to the MATLAB path the `$ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX/mex` directory and all the subdirectories `$ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX/share/WBToolbox`.
In particular you need to add to the MATLAB path:
* the `$ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX/mex` directory,
* the `$ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX/share/WBToolbox` directory and all its subdirectories (except the packages which are folder names starting with "+"),
* the library `$ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX/mex/+wbc/simulink`.

#### Start MATLAB from the launcher or the application menu

Expand Down Expand Up @@ -419,4 +423,3 @@ No additional configuration is required to use the software installed by the `R

### Check the installation
Open a terminal, and check that amoung the device listed by `yarpdev --list` the `esdcan` YARP device is listed.

Loading