robotology / wb-toolbox

Simulink toolbox to rapidly prototype robot controllers
https://robotology.github.io/wb-toolbox/
GNU Lesser General Public License v2.1
24 stars 17 forks source link

Provide a block for reading multiple analog sensors devices #116

Open traversaro opened 6 years ago

traversaro commented 6 years ago

Since YARP has added support for a structured system of devices for reading multiple analog sensors interfaces (http://yarp.it/devel/group__dev__iface__multiple__analog.html and https://github.com/robotology/yarp/pull/1586 ) , it would be great to have support for reading this sensors at the wb-toolbox level.

traversaro commented 6 years ago

cc @hu-yue @fjandrad

traversaro commented 5 years ago

Instead of manually wrapping YARP C++ devices, it would be cool if we could automatically generated YARP Read/Write-like blocks for messages described by an IDL. This is similar to what Simulink official support for ROS does in the Publisher and Subscriber blocks, see https://it.mathworks.com/help/robotics/examples/get-started-with-ros-in-simulink.html#d120e3206 . However, I am not sure if they support arbitrary message types or just a fixed set.

traversaro commented 5 years ago

On the other hand, providing explicit support for wrapping the C++ YARP devices permits some cools integration such as https://github.com/robotology/wb-toolbox/issues/164 .

diegoferigo commented 5 years ago

Instead of manually wrapping YARP C++ devices, it would be cool if we could automatically generated YARP Read/Write-like blocks for messages described by an IDL.

It would be a very useful feature, I concur, but I think it would be a very difficult task. In short, this would translate to an autogenerated plugin library associated to a generic (templated) class that reads custom thrift objects. The autogenerated thrift class and the autogenerated plugin library must be compiled during runtime. Furthermore, in order to set the output ports we should parse all the fields (at least type and size) of the thrift file and set BlockInformation accordingly.

Do you have any other ideas? This is just a draft that does not take into account all possible problems, and it already seems overly complex.

On the other hand, providing explicit support for wrapping the C++ YARP devices

This is definitely more reasonable. We can load the plugins that contains the devices seamlessly since they are already compatible with shlibpp and then map the APIs of a DeviceDriver that implements also a PeriodicThread to the blockfactory::core::Block APIs. I have doubts on how to extend this to attached devices, this would be way more challenging.

permits some cools integration such as #164 .

I didn't get how it would help it, I am missing something. Do you mean that if we would wrap Gazebo inside a YARP DeviceDriver, that idea would come for free?

traversaro commented 5 years ago

It would be a very useful feature, I concur, but I think it would be a very difficult task. In short, this would translate to an autogenerated plugin library associated to a generic (templated) class that reads custom thrift objects. The autogenerated thrift class and the autogenerated plugin library must be compiled during runtime. Do you have any other ideas? This is just a draft that does not take into account all possible problems, and it already seems overly complex.

To be honest, I was thinking that all of this would happen at configuration/compilation time, in which you specify a new block and type in CMake and you get the resulting block.

diegoferigo commented 5 years ago

Ok now I got it. In this case, it will be easier since CMake can avoid to mess with templates. Here below some more detailed comments:

We can talk f2f on this and decide if it is worth the effort.

traversaro commented 5 years ago

We can talk f2f on this and decide if it is worth the effort.

I agree. Probably it is not worth the effort, but it was nice to point it out. In the official ROS support for simulink, I see they are using a bus as the only output signal, but I have no experience with it.

traversaro commented 5 years ago

I didn't get how it would help it, I am missing something. Do you mean that if we would wrap Gazebo inside a YARP DeviceDriver, that idea would come for free?

I meant that wrapping devices providing the MultipleAnalogSensors interfaces as we do for the controlboard interfaces (so the original proposal in https://github.com/robotology/wb-toolbox/issues/116#issue-324837914, not the suggestion in https://github.com/robotology/wb-toolbox/issues/116#issuecomment-450636346) will permit to properly access them even if Gazebo is embedded in the simulation master as described in https://github.com/robotology/wb-toolbox/issues/164 .

diegoferigo commented 5 years ago

I meant that wrapping devices providing the MultipleAnalogSensors interfaces as we do for the controlboard interfaces will permit to properly access them even if Gazebo is embedded in the simulation master

If here we are talking specifically about the MultipleAnalogSensors interface, I can now maybe see what you meant. Let me know if it is not:

Long term (off topic) If we can achieve: - This MAS support - Embedding gazebo - Running generic yarp devices (e.g. whole body dynamics) from within the same simulink model We would greatly simplify the execution of our controllers since we should not need to operate anymore on external processes in other terminals.
traversaro commented 5 years ago

Exactly, you got it correctly.

We would greatly simplify the execution of our controllers since we should not need to operate anymore on external processes in other terminals.

Or running it as a part of an RL training process. : )

traversaro commented 4 years ago

Related comment: https://github.com/robotology/yarp/issues/1693#issuecomment-574683563 .