Custom Sensor Definition

Hi, I’m using MLAgents with the Python API to create a custom ML agent and am wondering if there is a reasonable way to send data from the Unity Side to Python and pull it out into a struct-like object. So essentially what I’m looking to be able to do is to create a C# struct, serialize the data, send it out over the mlagents socket, de-serialize on the Python side into a data class, and then use it however in my agent.

I think I could theoretically make this work with a VectorSensor if I make a wrapper function that will throw my struct into the VectorSensor properly, but I’m not exactly sure what the bit padding situation is in the VectorSensor either.

Has anyone else done anything like this?

Thanks in advance!

I think you can take a look at the ISensor Interface.

https://docs.unity3d.com/Packages/com.unity.ml-agents@1.0/api/Unity.MLAgents.Sensors.ISensor.html#extensionmethods

It should be possible theoretically, to extend this to make custom sensors to send binaries as you want to your python script.