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 pixi support to build and run IMU test #71

Merged
merged 5 commits into from
Mar 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# GitHub syntax highlighting
pixi.lock linguist-language=YAML

5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,7 @@ build
CMakeLists.txt.user
result.txt
.DS_Store
.vscode
.vscode
.pixi*
.build*
*.mat
9,178 changes: 9,178 additions & 0 deletions pixi.lock

Large diffs are not rendered by default.

26 changes: 26 additions & 0 deletions pixi.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
[project]
name = "icub-tests"
version = "0.0.0"
description = "Set of tests to check the functionalities of a robot"
authors = ["Martina Gloria <martina.gloria@iit.it>"]
channels = ["conda-forge", "robotology"]
platforms = ["linux-64", "win-64", "osx-64"]

[activation]
scripts = ["set_path.sh"]

[tasks]
build_imu_test = {cmd = "cmake -DCMAKE_INSTALL_PREFIX=$CMAKE_INSTALL_PREFIX -S. -B.build -DICUB_TESTS_COMPILES_IMU_TEST=ON"}
compile_imu_test = {cmd = "cmake --build .build", depends_on = ["build_imu_test"]}
install_imu_test = {cmd = "cmake --install .build", depends_on = ["compile_imu_test"]}
imu_sim_test = {cmd = "robottestingframework-testrunner --verbose --suite suites/imu-icubGazeboSim.xml", depends_on = ["install_imu_test"]}
imu_test = {cmd = "robottestingframework-testrunner --verbose --suite suites/imu.xml", depends_on = ["install_imu_test"]}

[dependencies]
robometry = "*"
idyntree = "*"
yarp = "*"
robot-testing-framework = "*"
icub-main = "*"
icub-models = "*"
robotology-distro = ">=2024.2.0,<2024.3"
4 changes: 4 additions & 0 deletions set_path.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export CMAKE_INSTALL_PREFIX=$CONDA_PREFIX
export YARP_DATA_DIRS=$CMAKE_INSTALL_PREFIX/share/yarp:$CMAKE_INSTALL_PREFIX/share/iCub:$PIXI_PROJECT_ROOT/suites
export LD_LIBRARY_PATH=$CMAKE_INSTALL_PREFIX/lib/robottestingframework:$PIXI_PROJECT_ROOT/.build/plugins
export CMAKE_PREFIX_PATH=$CONDA_PREFIX
95 changes: 95 additions & 0 deletions src/imu/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
IMU orientation test
====================

## Prerequisites

If you want to test multiple IMUs at once, the robot must expose in its `yarprobotinterface` configuration file a `multipleanalogsensorsserver` that publishes the orientation measurements for all of available sensors, with a `prefix` that matches exactly the `port` parameter of the test (the default one is `${portprefix}/alljoints/inertials`).

An example of `alljoints-inertials_wrapper.xml` for iCubV2_* models:

```sh
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE devices PUBLIC "-//YARP//DTD yarprobotinterface 3.0//EN" "http://www.yarp.it/DTD/yarprobotinterfaceV3.0.dtd">

<device xmlns:xi="http://www.w3.org/2001/XInclude" name="alljoints-inertials_wrapper" type="multipleanalogsensorsserver">
<param name="period"> 10 </param>
<param name="name"> ${portprefix}/alljoints/inertials </param>

<action phase="startup" level="10" type="attach">
<paramlist name="networks">
<elem name="FirstStrain"> alljoints-inertials_remapper </elem>
</paramlist>
</action>

<action phase="shutdown" level="15" type="detach" />
</device>
```

and `alljoints-inertials_remapper.xml`:

```sh
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE devices PUBLIC "-//YARP//DTD yarprobotinterface 3.0//EN" "http://www.yarp.it/DTD/yarprobotinterfaceV3.0.dtd">


<device xmlns:xi="http://www.w3.org/2001/XInclude" name="alljoints-inertials_remapper" type="multipleanalogsensorsremapper">
<param name="OrientationSensorsNames">
(l_arm_ft r_arm_ft head_imu_0)
</param>
<action phase="startup" level="5" type="attach">
<paramlist name="networks">
<elem name="head_imu"> head_inertial_hardware_device </elem>
<elem name="left_arm_imu"> left_arm_inertial_hardware_device </elem>
<elem name="right_arm_imu"> right_arm_inertial_hardware_device </elem>
</paramlist>
</action>

<action phase="shutdown" level="20" type="detach" />
</device>

```

## Usage

There are essentially two methods to install and run the IMU orientation test, which are going to be described in the following sections. In both cases, after launching the test, a .mat file containing the relevant measurements involved in the test will be generated.

### robotology-superbuild

If you have installed `icub-tests` as a part of the `robotology superbuild` framework with the [Robot Testing profile](https://github.com/robotology/robotology-superbuild/blob/master/doc/cmake-options.md#robot-testing) activation, i.e. by enabling the `ROBOTOLOGY_ENABLE_ROBOT_TESTING` CMake option of the superbuild, this test, like the others, is already available.

In this case, after compiling and being sure that `yarpserver` is up, you can run:

```sh
cd robotology-superbuild/src/icub-tests
robottestingframework-testrunner --suite suites/imu.xml
```

Otherwise, if you want to launch the test in a simulation environment, in a shell open a `gazebo` environment and import, for example, your iCub model. After that, open a separated shell, and:

```sh
#set YARP_ROBOT_NAME env variable with the name of the model you imported in gazebo
#example:
export YARP_ROBOT_NAME=iCubGazeboV2_7
cd robotology-superbuild/src/icub-tests
robottestingframework-testrunner --suite suites/imu-icubGazeboSim.xml
```

### pixi

If you want to run the test without depending on the whole robotology-superbuild, you can use `pixi`. First of all, be sure to have [`pixi`](https://pixi.sh/#installation) installed. Then, clone `icub-tests` and run the test as a pixi task:

```sh
git clone https://github.com/robotology/icub-tests
cd icub-tests
pixi run imu_test
```

In simulation, instead, import your model in `gazebo` and then run:

```sh
#set YARP_ROBOT_NAME env variable with the name of the model you imported in gazebo
#example:
export YARP_ROBOT_NAME=iCubGazeboV2_7
cd icub-tests
pixi run imu_sim_test
```
27 changes: 12 additions & 15 deletions src/imu/imu.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,21 @@
*
* The purpose of this test is to evaluate the accuracy of the IMU Euler angles measurements.
* It takes as input the urdf of the robot and make a comparison between the expected values retrieved from the forward kinematics and the ones read from the IMU itself.
* The test involves the movements of the joints belonging to the part on which the sensor is mounted. The movements are executed sequentially, traversing from the home position to the lower limit, upper limit and back to the home position for each joint.
* The test involves the movements of the joints belonging to the part on which the sensors are mounted.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at the configuration file https://github.com/robotology/icub-tests/blob/devel/suites/contexts/icub/test_imu.ini#L3, it seems that the test requires the existence of the multipleanalogsensorsserver with prefix /${robotname}/alljoints/inertials . Which robots expose this functionality? It could make sense to either list the robots that expose this functionality, or if that is too complicated from the maintenance point of view, just explicitly mention that the robot needs to expose a multipleanalogsensorsserver device with prefix /${robotname}/alljoints/inertials in its yarprobotinterface config files.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So far, no robots exposed this functionality upstream but I'm going to do this at least for iCubGenova11 and for iCubGazeboV2_* models I guess. We could use them as references to highlight in the documentation that is mandatory to have this MASserver exposed with that port name. Thanks @traversaro!

*
* You can manually modify the suites/contexts/icub/test_imu.ini file depending on the parameters of the test. In this case, after compiling, you can run:
* You can find the parameters involved in the test in the following table:
*
* Example: robottestingframework-testrunner --suite ../suites/imu.xml
* | Parameter name | Type | Required | Description | Notes |
* |:------------------:|:------------------:|:--------:|:-----------:|:-----:|
* | robot | string | Yes | The name of the robot. | e.g. icub |
* | model | string | Yes | The name of the robot model. | e.g. model.urdf |
* | port | string | Yes | The name of the port streaming IMU data. | e.g. /icub/alljoints/inertials |
* | remoteControlBoards| vector of string | Yes | The list of the controlboards to open. | e.g. ("torso", "head") |
* | axesNames | vector of string | Yes | The list of the controlled joints. | e.g. ("torso_pitch", "torso_roll", "torso_yaw", "neck_pitch", "neck_roll", "neck_yaw") |
* | sensorsList | vector of string | Yes | The list of the sensors to be tested. | e.g. ("head_imu_0", "l_arm_ft") or ("all")|
* | maxError | double | Yes | The tolerance on the error. | |
*
* This will launch the test and open a yarpscope with the plots of the IMU traces.
*
* Accepts the following parameters:
* | Parameter name | Type | Units | Default Value | Required | Description | Notes |
* |:------------------:|:------------------:|:-----:|:-------------:|:--------:|:-----------:|:-----:|
* | robot | string | - | - | Yes | The name of the robot. | e.g. icub |
* | model | string | - | - | Yes | The name of the robot model. | e.g. model.urdf |
* | port | string | - | - | Yes | The name of the port streaming IMU data. | e.g. /icub/head/inertials |
* | remoteControlBoards| vector of string | - | - | Yes | The list of the controlboards to open. | e.g. ("torso", "head") |
* | axesNames | vector of string | - | - | Yes | The list of the controlled joints. | e.g. ("torso_pitch", "torso_roll", "torso_yaw", "neck_pitch", "neck_roll", "neck_yaw") |
* | sensorsList | vector of string | - | - | Yes | The list of the sensors to be tested | e.g. ("head_imu_0", "l_arm_ft") or ("all)|
* | maxError | double | - | - | Yes | The tolerance on the error. | |
* Further instructions about how to install, configure and run the test can be found in the <a href="http://robotology.github.io/icub-tests/doxygen/doc/html/pages.html">related page</a>.
*/

class Imu : public yarp::robottestingframework::TestCase {
Expand Down
3 changes: 1 addition & 2 deletions suites/contexts/icub/test_imu.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,5 @@ model model.urdf
port /${robotname}/alljoints/inertials
remoteControlBoards ("torso", "head", "left_arm", "right_arm")
axesNames ("torso_pitch", "torso_roll", "torso_yaw", "neck_pitch", "neck_roll", "neck_yaw", "l_shoulder_pitch", "l_shoulder_roll", "l_shoulder_yaw", "r_shoulder_pitch", "r_shoulder_roll", "r_shoulder_yaw")
; sensorsList ("head_imu_0", "l_arm_ft", "r_arm_ft")
sensorsList ("all")
sensorsList ("all")
maxError 0.1
Loading