0

I have a sensor but it is coded in python. I do not want to convert it to C++. I want to integrate this with the Carla and use it just as any other sensor. However, sensors in Carla are writtten in C++. Therefore I want to write a skeleton sensor in C++, which would then use pybind11 to embed python and use my already existing sensor written in python.

I have built Carla from source on Ubuntu 20.04. Then, I added a new sensor according to the tutorial given here: Link.

These are the files that are needed to be added:

Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Sensor/MySensor.h
Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Sensor/MySensor.cpp

LibCarla/source/carla/sensor/s11n/MySerializer.h
LibCarla/source/carla/sensor/s11n/MySerializer.cpp

LibCarla/source/carla/sensor/data/MyEvent.h

And these files were needed to be modified:

PythonAPI/carla/source/libcarla/SensorData.cpp

LibCarla/source/carla/sensor/SensorRegistry.h

With some minor tweaks, I was finally able to compile everything(make clean, make PythonAPI and make launch) and get it to work as expected. Now, I have written a skeleton C++ program and used CMake and pybind11 to run my python sensor from within this C++ program. This works fine. Here is the CMakeLists.txt file I used:

cmake_minimum_required(VERSION 3.5...3.26)
project(name1)

add_subdirectory(pybind11)

add_executable(name2 main.cpp)
target_link_libraries(name2 PRIVATE pybind11::embed)

My folder structure was as follows:

Project Root Folder
    pybind11
    main.cpp
    CMakeLists.txt
    python code directory
    build
        name2 (the executable created after running `make` in the terminal)
        some other build files and stuff (created after running `cmake ..` in the terminal)

But how do this with Carla now? That is, where do I put my C++ file, which CMakeLists.txt file (there are several CMakeLists.txt files in Carla) do I have to edit in Carla and where in Carla do I put my python sensor code?

brex
  • 1
  • 1

0 Answers0