Unity, ML-Agents and Grpc

I've been part of a team creating a framework for a robot battle tournament game; mostly doing other stuff and now also dabbling with the machine learning side of things. I've been changing the way the way the robots are moved in our simulation environment and now I need to modify the protocol implementations. Another goal is to simplify the protobuf code and make the generation as simple as possible. I've been encountering surprising problems, rising from the ML-Agents framework and Unity themselves.

Trying to make a project that interoperates with Unity ML-Agents and with a fairly recent Grpc version is an absolute pain, as ML-Agents packs its own version of Grpc.

/Users/sjl/p/robot-uprising-hq/ai-simulator/Assets/Scripts/Proto/GeneratedCode/RobotSystemCommunication.cs(12,12):
  Error CS0234: The type or namespace name 'IBufferMessage' does not exist in the namespace 'Google.Protobuf'
  (are you missing an assembly reference?) (CS0234)

Google.Protobufs and Grpc.Core are up-to-date, problem seeems to be the ML-Agents bundle. One solution is to use an old enough version to build the proto files for the project as one blogger has done.

Another would be to try and fix the upstream. Another would be to separate the code using the ML-Agents and the protocol code so that the code using the protocol code would not need to mix in the Unity project.

In our case, the ML-Agents is needed by a so called brain server, which will do inference on the received observations with Unity ML-Agents code, so splitting the project to isolate the problem does not work. Nevertheless, this is something I think warrants a fix, as this might become an issue at some point and in any case will cause problems for our users, should they want to regenerate the protocol code.

I've been ripping hairs for enough hours figuring out the problem and trying to devise a clean fix. None has been very forthcoming yet. To make the system compile, a version of grpc from end of 2018 needs to be used. This is not very satisfactory. This is what my team mates had originally done and which I wanted to avoid :)

At some point it would be nice to fix the ML-Agents to use a more current version of grpc.

links

social