robotology / yarp

YARP - Yet Another Robot Platform
http://www.yarp.it
Other
530 stars 195 forks source link

ControlBoardCouplingHandler: a device for publishing phyisical joints quantities in under-actuated system #3085

Closed Nicogene closed 8 months ago

Nicogene commented 9 months ago

This is a first draft of the device that will expose the publishing phyisical joints quantities in under-actuated system using the new IJointCoupling interface.

This PR is super draft, it just compiles, I opened the PR for agreeing w/ @traversaro @randaz81 @elandini84 on:

Please ignore both the test folder (that has been copied from controlBoardRemapper) and the implementation in the .cpp, I will write it once we agree on the points above.

cc @pattacini

update-docs[bot] commented 9 months ago

Thanks for opening this pull request! The maintainers of this repository would appreciate it if you would update the release notes by adding a file in doc/release/<target_branch>, based on your changes.

randaz81 commented 9 months ago
  • The device name
  • The interfaces that implement
  • The interfaces that has as private attribute members

Name is ok for me. IEncodersTimed and IAxisInfo interfaces are ok. Will the device also perform some internal computation (e.g. for differential joints) or it is just a remapping of encoders data?

For the implementation, remember to use the new parser generator https://github.com/robotology/yarp/discussions/3081, I'm already going to replace all manual implementation in all devices in yarp 3.10 https://github.com/robotology/yarp/pull/3084

Nicogene commented 9 months ago

Will the device also perform some internal computation (e.g. for differential joints) or it is just a remapping of encoders data?

My idea was to get the actuated axis quantities via the private attributes interfaces and perform the transformations for getting the physical joints quantities (positions, velocities, accelerations) but I am open to other possibilities

Nicogene commented 9 months ago
  • The device name
  • The interfaces that implement
  • The interfaces that has as private attribute members

Name is ok for me. IEncodersTimed and IAxisInfo interfaces are ok. Will the device also perform some internal computation (e.g. for differential joints) or it is just a remapping of encoders data?

For the implementation, remember to use the new parser generator #3081, I'm already going to replace all manual implementation in all devices in yarp 3.10 #3084

Hi @randaz81, I was trying to use this nice new feature, but if I got it correctly it does support only these types of params:

Parameter type c++ type yarp::os::Value call
"bool" bool .asBool()
"string" std::string .asString()
"int" int .asInt64()
"size_t" size_t .asInt64()
"float" float .asFloat32()
"double" double .asFloat64()

How can we handle the vector/lists ? I generated the parser and then I change by hand using the vectors/lists? Lists are often used as parameters for devices, are you planning to add it ?

cc @elandini84

Nicogene commented 9 months ago
  • The device name
  • The interfaces that implement
  • The interfaces that has as private attribute members

Name is ok for me. IEncodersTimed and IAxisInfo interfaces are ok. Will the device also perform some internal computation (e.g. for differential joints) or it is just a remapping of encoders data? For the implementation, remember to use the new parser generator #3081, I'm already going to replace all manual implementation in all devices in yarp 3.10 #3084

Hi @randaz81, I was trying to use this nice new feature, but if I got it correctly it does support only these types of params: Parameter type c++ type yarp::os::Value call "bool" bool .asBool() "string" std::string .asString() "int" int .asInt64() "size_t" size_t .asInt64() "float" float .asFloat32() "double" double .asFloat64()

How can we handle the vector/lists ? I generated the parser and then I change by hand using the vectors/lists? Lists are often used as parameters for devices, are you planning to add it ?

cc @elandini84

Ah ok the vectors will be added in:

See:

Nicogene commented 9 months ago

An important update on this, I managed to finish the first working version of controlBoardCouplingHandler device.

In the end I sorted out that this device just needs the coupling_device parameter in which the is specified which underlying coupling device has to be opened (e.g. couplingXCubHandMk5), then all other parameters specified in the xml file are forwarded to the parsing of coupling_device that may change in function of which coupling we are using.

/**
* This class is the parameters parser for class ControlBoardCouplingHandler.
*
* These are the used parameters:
* | Group name | Parameter name  | Type   | Units | Default Value | Required | Description                                  | Notes |
* |:----------:|:---------------:|:------:|:-----:|:-------------:|:--------:|:--------------------------------------------:|:-----:|
* | -          | coupling_device | string | -     | -             | 1        | Name of the device that handles the coupling | -     |
*
* The device can be launched by yarpdev using one of the following examples:
* \code{.unparsed}
* yarpdev --device controlBoardCouplingHandler --coupling_device <mandatory_value>
* \endcode
*
* \code{.unparsed}
* yarpdev --device controlBoardCouplingHandler --coupling_device <mandatory_value>
* \endcode
*
*/

Here are the xml files I used for testing on ergoCub hand V1_1 (in simulation)

<?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="left_hand-coupling_handler" type="controlBoardCouplingHandler">
    <param name="coupling_device"> couplingXCubHandMk5 </param>
    <param name="jointNames"> l_thumb_add l_thumb_prox l_thumb_dist l_index_add l_index_prox l_index_dist l_middle_prox l_middle_dist l_ring_prox l_ring_dist l_pinkie_prox l_pinkie_dist </param>
    <group name="LIMITS">
        <param name="jntVelMax"> 100.0   100.0 100.0 100.0 100.0 100.0  100.0 100.0  100.0 100.0   100.0 100.0 </param>
        <param name="jntPosMax"> 100.0   90.0  101.4 15.0  90.0  103.1  90.0  103.1  90.0  103.1   90.0  98.7  </param>
        <param name="jntPosMin"> -100.0 -90.0 -101.4 -15.0 -90.0 -103.1 -90.0 -103.1 -90.0  -103.1 -90.0 -98.7 </param>
    </group>
    <group name="COUPLING">
        <param name="actuatedAxesNames"> l_thumb_add l_thumb_oc l_index_add l_index_oc l_middle_oc l_ring_pinky_oc </param>
        <param name="actuatedAxesPosMin"> 0.0 0.0 0.0 0.0 0.0 0.0 </param>
        <param name="actuatedAxesPosMax"> 100.0 90.0 15.0 90.0 90.0 90.0 </param>
    </group>
    <group name="COUPLING_PARAMS">
        <param name="L0x"> -0.0050 -0.0050 -0.0050 -0.0050 -0.0050 </param>
        <param name="L0y"> 0.0040 0.0040 0.0040 0.0040 0.0040 </param>
        <param name="q2bias"> -173.35 -173.35 -173.35 -173.35 -170.53 </param>
        <param name="q1off"> 2.45 2.15 2.15 2.15 2.46 </param>
        <param name="k"> 0.03415 0.03913 0.03913 0.03913 0.03418 </param>
        <param name="d"> 0.03503 0.04003 0.04003 0.04003 0.03503 </param>
        <param name="l"> 0.00604 0.00604 0.00604 0.00604 0.00608 </param>
        <param name="b"> 0.00640 0.00640 0.00640 0.00640 0.00640 </param>
    </group>
    <action phase="startup" level="10" type="attach">
        <param name="device"> left_hand_hardware_device </param>
    </action>
    <action phase="shutdown" level="15" type="detach" />
</device>
<?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="left_hand-mc_nws_yarp" type="controlBoard_nws_yarp">
    <param name="name"> ${portprefix}/left_hand </param>
    <param name="period">0.01</param>
    <action phase="startup" level="10" type="attach">
        <param name="device"> left_hand-coupling_handler </param>
    </action>
    <action phase="shutdown" level="15" type="detach" />
</device>

controlBoardCouplingHandler can be attached by controlBoardRemapper, controlBoard_nws_yarp, controlBoard_nws_ros2, controlBoard_nws_ros and will publish the physical joint data, e.g:

immagine

fyi @PeterBowman @mebbaid @traversaro @randaz81 @maggia80 @pattacini @PasMarra @martinaxgloria

sonarcloud[bot] commented 9 months ago

Quality Gate Failed Quality Gate failed

Failed conditions
33.7% Coverage on New Code (required ≥ 80%)
3.0% Duplication on New Code (required ≤ 3%)

See analysis details on SonarCloud

randaz81 commented 9 months ago

To all readers, please note that the example .xml shown in https://github.com/robotology/yarp/pull/3085#issuecomment-1983678503 is using a deprecated format and it should not be considered a good example to take inspiration from.

All lists of parameters MUST be always parenthisized i.e.:

THIS IS AN INVALID LINE: <param name="jntVelMax"> 100.0 100.0 100.0 100.0 100.0 100.0 100.0 100.0 100.0 100.0 100.0 100.0 </param> THIS IS THE CORRECT LINE: <param name="jntVelMax"> (100.0 100.0 100.0 100.0 100.0 100.0 100.0 100.0 100.0 100.0 100.0 100.0 ) </param>

the old format is currently supported because of yarp bug which might be fixed in a future release!

In this specific example, couplingXCubHandMk5 parser, which is not related to this PR, is not correct and it needs to be fixed together with this xml file