MOSAIC simulator coupling #112
-
Hello all, I'm currently trying to extend MOSAIC for a project that I'm developing that involves BDI agents. My idea is to use the spade-bdi python module to implement BDI agents using a python script. It would basically create new BDI agents as new vehicles register MOSAIC and then use these agents as needed. As far as I know, to integrate a new component into MOSAIC you need to develop a federate since it's how MOSAIC can communicate with the simulator (in this case the running python script). So far, I defined a federate for the spade component but I don't really understand what it is doing. It is starting when MOSAIC starts but besides that, it does nothing. By looking at MOSAIC's repo I noticed that for example in your SUMO Ambassador you define an executor for launching sumo. I tried to do the same with my python script within the federate I defined, but nothing happened. I'm having trouble developing this federate because I do not know how I can use it to communicate with my python script. And as far as the documentation goes I think there's nothing there left that is useful for me to use. I've been relying on your repo to try to understand how you developed your other ambassadors but I'm having trouble understanding it. How can I use an ambassador to establish communication between a vehicle application and the python script that I want to run when launching my scenario? And how can I exchange information between them? Best regards, |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 7 replies
-
Hi Francisco, as soon as the simulator you want to couple is not based on Java, you will need to implement a socket-based interface to exchange messages between the ambassador (Java class coupled directly to MOSAIC), and the simulator (your python code). Currently there are three simulators coupled to MOSAIC which use such interface: The SumoAmbassador uses the TraCI interface provided directly by SUMO. This won't help you because it is a protocol offered by SUMO itself, we just wrote the client code for that to use this API. For our other couplings of OMNeT++ and ns-3 we implemented an own socket interface based on Protobuf messages. You can find that in the Unfortunately, we currently do not offer a "general purpose" socket API which would make it a lot easier to couple external simulators. All API available currently relies on Java. If you still want to continue and couple your python based simulator, I would suggest you to use gRPC or the like. |
Beta Was this translation helpful? Give feedback.
Hi Francisco,
as soon as the simulator you want to couple is not based on Java, you will need to implement a socket-based interface to exchange messages between the ambassador (Java class coupled directly to MOSAIC), and the simulator (your python code). Currently there are three simulators coupled to MOSAIC which use such interface: The SumoAmbassador uses the TraCI interface provided directly by SUMO. This won't help you because it is a protocol offered by SUMO itself, we just wrote the client code for that to use this API. For our other couplings of OMNeT++ and ns-3 we implemented an own socket interface based on Protobuf messages. You can find that in the
AbstractNetworkAmbassador
cla…