robotology / wearables

Data collection framework for wearable sensors
BSD 3-Clause "New" or "Revised" License
19 stars 11 forks source link

Allow IWearRemapper to attach and remap IWear interfaces #170

Closed lrapetti closed 1 year ago

lrapetti commented 1 year ago

Until now, the IWear remapper had the dual role of network client (converting yarp port to interface) and remapper (merging multiple signals).

This PR extend the IWearRemapper capabilities concerning the second role (remapping) enabling it to merge multiple interfaces (until now it was only capable of merging signals from ports). In the future the other role (network client) might be delegated to a dedicated device.

As a consequence of this change:

lrapetti commented 1 year ago

Previously this device was in the status WaitingForFirstRead until some data are read from the input port in onRead method.

As discussed with @RiccardoGrieco, now the remapper should wait for:

As far as I see there is not a predefined order in which the onRead and attachAll are called. The easiest thing would be to have two flags detecting the two methods to be executed. The point is that attachAll is not called if there is nothing to attach to, so we can not distinguish the case in which there are only ports to which we should connect and we do not have to wait for the attach all. Am I missing something? Is there a way to know if the attach is present in the configuration file? cc @traversaro @RiccardoGrieco @S-Dafarra

traversaro commented 1 year ago

Am I missing something? Is there a way to know if the attach is present in the configuration file? cc @traversaro @RiccardoGrieco @S-Dafarra

I do not think so. I think the easiest solution (even if it is not ideal) is to add a specific parameter to the device to set if no device is attached to it, or a parameter that specifies if the device should wait for attachAll or not.

RiccardoGrieco commented 1 year ago

Am I missing something? Is there a way to know if the attach is present in the configuration file? cc @traversaro @RiccardoGrieco @S-Dafarra

I do not think so. I think the easiest solution (even if it is not ideal) is to add a specific parameter to the device to set if no device is attached to it, or a parameter that specifies if the device should wait for attachAll or not.

I agree! It was also one of the possibilities that came up discussing with @lrapetti.

lrapetti commented 1 year ago

With https://github.com/robotology/wearables/pull/170/commits/6026b0c29cfc9d76d4484b7247acb6de09a03fa2 I have added the flag waitForAttachAll as you both proposed. Moreover, in case no there are no input ports, I am avoiding starting the loop (which was used only for initializing the onRead() callback).

lrapetti commented 1 year ago

For reference, this PR has been tested with the following configuration file Human.xml.txt that modifies https://github.com/robotology/human-dynamics-estimation/blob/master/conf/xml/Human.xml adding the IWearRemapper that remaps directly the interface

lrapetti commented 1 year ago

LGTM! Just don't fortget to update the CHANGELOG before merging

Done!