## Using LIDAR sensor with remoteAPI

Typically: "How do I... ", "How can I... " questions
jdjdjd
Posts: 2
Joined: 05 Feb 2019, 09:39

### Using LIDAR sensor with remoteAPI

Hi,

I am trying to use a LIDAR sensor in a python program I write using the remoteAPI.

how can I get the LIDAR data (points cloud / array)?

what do I have to add to the child process of the sensors and how can I read the data in Python.

I have tried using both the Velodyne and SICK sensors.

thanks,

Yuval

coppelia
Posts: 7936
Joined: 14 Dec 2012, 00:25

### Re: Using LIDAR sensor with remoteAPI

Hello Yuval,

you have several ways you can share the LIDAR data with your remote API client. The simplest is probably to set a string signal inside of the child script, that contains the packed data, e.g., in each simulation pass:

Code: Select all

    data=sim.packFloatTable(measuredData)
sim.setStringSignal("measuredDataAtThisTime",data)

you can then constantly read that signal from your remote API client, with simxGetStringSignal. Make sure to use data streaming mode to read that signal.
Then decode that signal (with simxUnpackFloats) and you have your data.

You have sevral other way of exchanging data. One other way would be to call a specific script function with simxCallScriptFunction.

Cheers

jdjdjd
Posts: 2
Joined: 05 Feb 2019, 09:39

### Re: Using LIDAR sensor with remoteAPI

Hi,

I have added the lines to the Velodyne's child process but I get the following error when I am running the simulation:

Lua runtime error: [string "CHILD SCRIPT velodyneHDL_64E_S2"]:10: One of the function's argument type is not correct. (sim.packFloatTable)
stack traceback:
[C]: in function 'packFloatTable'
[string "CHILD SCRIPT velodyneHDL_64E_S2"]:10: in function <[string "CHILD SCRIPT velodyneHDL_64E_S2"]:9>

coppelia
Posts: 7936
Joined: 14 Dec 2012, 00:25

### Re: Using LIDAR sensor with remoteAPI

you will still have to adjust the script a little bit, e.g.:

Code: Select all

function sysCall_sensing()
data=simVision.handleVelodyneHDL64E(h,sim.getSimulationTimeStep())
packedData=sim.packFloatTable(data)
sim.setStringSignal("measuredDataAtThisTime",packedData)
end

Cheers