Page 1 of 1

How to get sensor data of Accerometer and GyroSensor in MATLAB?

Posted: 23 Apr 2024, 10:42
by ChiChi
Dear Coppeliasim,

Thank you for your effort in this field. Now a have some problems in using ZMQremoteAPI to get the sensor data of Accerometer and GyroSensor in Matlab.

I try to use this code in LUA Scripts:

Code: Select all

sim.setFloatSignal("accel1",accel[3])
and use these codes in Matlab .m file:

Code: Select all

signalValue = sim.getFloatSignal("accel1");
but I got an error in Matlab:

Code: Select all

When calling "RemoteAPIObject/subsref," no value was assigned to the output argument "varargout{1}" (possibly including other arguments).

Error occurred in testvrep (line 10)
signalValue = sim.getFloatSignal("accel1");
I am not exactly know how to use set and get Signal function to get the variable desgin by userself, between Coppe and Matlab. Do you have any Samples?

By the way, do we have the ZMQremoteAPI handbook for Matlab style? Online or Offline both Okay.

Re: How to get sensor data of Accerometer and GyroSensor in MATLAB?

Posted: 24 Apr 2024, 08:01
by coppelia
Hello,

the error very probably happens because the signal is not set (yet), and the call to sim.getFloatSignal returns nothing. So you can't assign nothing to a variable in MATLAB. Use a try-catch block to handle a possibly non-existing return value.

Cheers