robotology / wearables

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

Implement the python bindings for the WearableData msg #162

Closed GiulioRomualdi closed 2 years ago

GiulioRomualdi commented 2 years ago

With this PR it will be possible to get and send the WearableData message via python and thanks to this in MATLAB

import yarp
import wearables.bindings as wearables

# create the yarp network 
network = yarp.Network()
network.init()

port = wearables.msg.BufferedPortWearableData()
port.open("/foo")

data = port.read(False)

On matlab

%% Initialize the YARP Network and collect data.
clear; clc;
network = yarp.Network()
network.init()
py.importlib.import_module('wearables.bindings');
port = py.wearables.bindings.msg.BufferedPortWearableData();
port.open("/foo"); % Opening port named '/foo'

% Remember to connect the ports. Command line is the following:
% yarp connect /iFeelSuit/WearableData/data:o /foo
yarp.Network.connect('/iFeelSuit/WearableData/data:o', '/foo') 
data = port.read();
val = data.forceTorque6DSensors;
forceZ_Left = val{'iFeelSuit::ft6D::Node#1'}.data.force.z;
forceZ_Right = val{'iFeelSuit::ft6D::Node#2'}.data.force.z;

cc @conconman @RiccardoGrieco @lrapetti @traversaro

GiulioRomualdi commented 2 years ago

Done @lrapetti. @conconman could you please copy-paste the example in MatLab that we run this morning?

conconman commented 2 years ago

@GiulioRomualdi as far as I can tell, there's no timestamp associated with this data collection. That would be necessary information to have.

GiulioRomualdi commented 2 years ago

As far as I know, the timestamp is not streamed, @lrapetti can complement this

lrapetti commented 2 years ago

I confirm the timestamp is not included in the message that is streamed, you can have an idea of the content of the message by looking at the thrift https://github.com/robotology/wearables/blob/master/msgs/thrift/WearableData.thrift.

Depending on your purpose, maybe you can use the receiver timestep from your machine?

conconman commented 2 years ago

I confirm the timestamp is not included in the message that is streamed, you can have an idea of the content of the message by looking at the thrift https://github.com/robotology/wearables/blob/master/msgs/thrift/WearableData.thrift.

Depending on your purpose, maybe you can use the receiver timestep from your machine?

I think you're right @lrapetti. Without spending a ton of time on this problem, I believe the cputime or tic/toc should be sufficient depending on the situation.

lrapetti commented 2 years ago

@GiulioRomualdi sorry for the delay, can I proceed to merge?

lrapetti commented 2 years ago

One thing that seems to be missing is the test with the WEARABLES_COMPILE_PYTHON_BINDINGS flag ON, @GiulioRomualdi let me know if you can take care of adding it, otherwise I will take care.

I think after merging we should add the flag also in therobotology-superbuild

RiccardoGrieco commented 2 years ago

I would also add a reference to WEARABLES_COMPILE_PYTHON_BINDINGS in the README, for instance here.

GiulioRomualdi commented 2 years ago

I updated the readme in https://github.com/robotology/wearables/pull/162/commits/10e8fa0b2923ce44fbf9d8da45a5101d5dc78e31 and I enabled the compilation of the bindings in the CI in https://github.com/robotology/wearables/pull/162/commits/706256051293326bb040e89121d9199a64c55bc6

@RiccardoGrieco and @lrapetti let me know if you are fine with the changes 😃

lrapetti commented 2 years ago

I just noticed that what I mentioned in https://github.com/robotology/wearables/pull/162#issuecomment-1228182084 regarding the superbuild, still needs to be addressed. I will take care of it

lrapetti commented 2 years ago

I just noticed that what I mentioned in #162 (comment) regarding the superbuild, still needs to be addressed. I will take care of it

PR opened https://github.com/robotology/robotology-superbuild/pull/1259