Clear Filters
Clear Filters

How can I implement an ousterlidar object in Simulink?

3 views (last 30 days)
I am using an Ouster Os-128 lidar to collect, visualize, and process point cloud data in MATLAB. Using this link, I started by storing the lidar as ousterlidar object, from which I could use the read() function to store it as a pointcloud object, like in the lines below.
obj = ousterlidar("OS1-128","path to metedata.json file")
ptCloud = read(obj)
This works fine in MATLAB but using it within a function block in Simulink produces the following error: "The 'ousterlidar' class does not support code generation."
Unfortunately, I am not as comfortable with Simulink as I am with MATLAB so I am not quite sure how to troubleshoot this problem, and I would greatly appreciate even just a nod towards the right direction. Thank you.

Answers (1)

Gayatri Rathod
Gayatri Rathod on 27 Apr 2023
Hi Mario,
  • The error message indicates that the 'ousterlidar' class is not supported for code generation which means that it cannot be used directly in a Simulink model.
  • One possible workaround is to create a MATLAB function that reads the data from the ousterlidar object and outputs the point cloud data as a variable. You can then call this function from your Simulink model using a MATLAB Function block.
  • Here is an example MATLAB function that reads the data from the ousterlidar object and outputs the point cloud data as a variable:
function ptCloud = readPointCloud(obj)
% Create ousterlidar object
obj = ousterlidar("OS1-128","path to metadata.json file");
% Read point cloud data
ptCloud = read(obj);
end
To use the MATLAB Function block in your Simulink model, follow these steps:
1.Drag a MATLAB Function block from the Simulink Library Browser into your Simulink model.
2.Open the block by double-clicking on it.
3.In the "Function name" field, enter the name of the MATLAB function you created above (e.g., "readPointCloud").
4.In the "Inputs" and "Outputs" sections, specify the input and output ports for the block.
5.Save and close the block.
6.Connect the input and output ports of the MATLAB Function block to the other blocks in your Simulink model as needed.
7.Run the Simulink model to generate the point cloud data.
You can read more about the MATLAB Function Block from the following documentation: MATLAB Function Block.
Hope it helps!

Products


Release

R2022b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!