Kathy Church

When creating a new service, I am adding two Entity Partners to the Partner List. My notificaton handler gets called when the first entity is added to the world, but not the second. I would like for my notification handler to get called twice, once for each entity partner. When using the code below, the service will only get a notification when entity1 is inserted, but not entity2. Any advice would be appreciated.

Thanks,

Kathy

Code Snippet

ServiceInfoType type = new ServiceInfoType(toolchanger.Contract.Identifier, "http://localhost/toolconnector");

type.PartnerList.Add(Microsoft.Robotics.Simulation.Partners.CreateEntityPartner("http://localhost/" + entity1.State.Name));

type.PartnerList.Add(Microsoft.Robotics.Simulation.Partners.CreateEntityPartner("http://localhost/" + entity2.State.Name));

DsspResponsePort<CreateResponse> resultPort = CreateService(type);

SimulationEngine.GlobalInstancePort.Insert(entity2);

SimulationEngine.GlobalInstancePort.Insert(entity1);



Re: Microsoft Robotics - Simulation Multiple Entity Partners

Piyoosh

You must have been using a call such as:
SimulationEngine.GlobalInstancePort.Subscribe(ServiceInfo.PartnerList, _notificationPort)

The Subscribe function here is overloaded. Hence, you can create an Entity Subscription Request for each entity you want to subscribe for and then call the Subscribe function for each of the requests as SimulationEngine.GlobalInstancePort.Subscribe(request, _notificationPort).
Each request i.e. EntitySubscribeRequestType supports a property named Name that determines the entity name you are subscribing for.




Re: Microsoft Robotics - Simulation Multiple Entity Partners

Kathy Church

Thanks, that did fix my problem. I iterated through the PartnerList to get the names of every entity partner, then subscribed to them as you suggested.

Kathy