darkscyla / MATLAB-Carla-Interface

Interfacing Carla with MATLAB using Python and ROS
107 stars 36 forks source link

The implementation of senFunc #1

Closed youngsend closed 3 years ago

youngsend commented 3 years ago

Hi, @darkscyla , thank you for the code! I am trying to reuse the CarlaDataAcquisition.m, however, senFunc seems not exist. Could you tell me how to implement senFunc.getData function?

I read carla documentation and it seems there's only listen function to get Image data. However, listen takes a lambda as argument and I don't know how to use Python lambda in Matlab.

youngsend commented 3 years ago

It seems sensorBind.m is doing this job.

darkscyla commented 3 years ago

Thanks for showing interest in the project. I do apologize for the messy documentation as we had to merge two separate approaches into one. This led to documentation that is hard to read.

Coming back to the problem you are facing, I would recommend that you do not use the implementation in the obsolete folder. The sensor bind should work fine as you mentioned. The idea is that we offload as much work to python as possible. This way, we can leverage numpy array manipulations without significant costs. For example, take a look at how semantic segmentation matrix is converted into a RGB array. This should give you a idea how you can define custom lambdas (within python). Whenever you need the data in MATLAB, you can query the loaded python file with something like this: py.getattr(pyModuleInMATLAB, 'array') where array is the name of the variable the you store data in

darkscyla commented 3 years ago

For convenience, I have also attached the documentation for python only. It should be way more helpful though its not complete (missing the ROS part). The videos are also not available as it surpassed the github size limits. Nonetheless, just change the extension to .md and paste it in the root directory of the project. You should be able to view it on for e.g. VS Code by opening it and pressing Ctrl + Shift + V

README_python.txt

youngsend commented 3 years ago

Thank you for the kind reply! I succeeded in showing the rgb images with sensorBind as vehicle moves. So convenient!! Also thank you for the Python API README! This is so helpful! Right now I need to use PythonAPI only.