I tried using remoteApi but it doesn't work with simulink (only matlab)
So, I am using shared memory.
I used generic shared memory files from https://drive.google.com/drive/u/0/fold ... 2VxOEY2bjQ to build upon.
here is a pic of simulink:
and this one from the vrep file:
I am writing script in a non-threaded child script of the joint
my problem is with DataIn, its type is float table, i think i can extract number sent through simulink from DataIn
Code: Select all
--In this example the desired position of the cube is sent from simulink, --vrep positions the object and sends its current position to simulink. if (sim_call_type==sim_childscriptcall_initialization) then handle=simGetObjectHandle('rev_joint') result,memIn=simExtShareMemoryOpen("rev_joint_entrada_1",3*4) result,memOut=simExtShareMemoryOpen ("rev_joint_salida_1",3*4) --To use the "Generic Shared Memory" block, two shared memories must be defined in Vrep (see block help). --One is used to write data to simulink (memOut) and another to read data from simulink (memIn) --The size of the memory is defined in "char", to write and read the position of the object 3 float = 12 char are neded end if (sim_call_type==sim_childscriptcall_actuation) then result,rawDataIn=simExtShareMemoryRead(memIn) --read the data from the shared memory DataIn=simUnpackFloatTable(rawDataIn) --unpack the data (convert char array to float table) res=simSetJointForce(handle,DataIn) --do something with the data --print(rawDataIn, DataIn) end if (sim_call_type==sim_childscriptcall_sensing) then --DataOut=simGetObjectPosition(handle,-1) --generate some data --rawDataOut=simPackFloatTable(DataOut) -- pack data on char array --result=simExtShareMemoryWrite(memOut,rawDataOut) -- write data to shared memory end if (sim_call_type==sim_childscriptcall_cleanup) then simExtShareMemoryClose(memIn) simExtShareMemoryClose(memOut) end
but this doesn't happen at all
for example if I sent 70 from simulink
i get these fields for DataIn: DataIn = 0, DataIn = 3.273583, DataIn = 0, DataIn = 0, ....... and so on with just zeros
in addition I get this error:
I think problem will be solved if i converted DataIn from tablefloat type to just float or double (may be I am wrong)
how can I receive input from simulink as a number that is acceptable with simSetJointForce function?