hla

Problems with OpenRTI callbacks


How in the OpenRTI to make the rti send callbacks? For example, reserve a name with the reserveObjectInstanceName

_rtiAmbassador->reserveObjectInstanceName(name);

Errors:

terminate called after throwing an instance of 'rti1516e::ObjectInstanceNameNotReserved'


Solution

  • If you are using the HLA 1516e API (as opposed to HLA 1516 or HLA 1.3) when you make a call to connect you can specify a CallbackModel which is either SYNCHRONOUS or ASYNCHRONOUS. In a synchronous callback model, the federate has to call the method evokeCallback in order to trigger the RTI to send whatever is queued up. In asynchronous, the callbacks are sent automatically.

    What you should do in this instance is have something like this:

    _rtiAmbassador->reserveObjectInstanceName(std::wstring(L"MyObject"));
    _rtiAmbassador->evokeMultipleCallbacks();
    MyFederateAmbassador::objectInstanceNameReservationSucceeded(std::wstring const & name){
        _rtiAmbassador->registerObjectInstance(handle, std::wstring(L"MyObject"));
    }