Ownership Management

Sometimes you may need control some aspects of a simulated object using other object or a real device. You may have a real rudder device to control a simulated ship for example.

In these cases you will need to take control of some attributes of the simulated object, such as its position . Thus, you can use the rudder angle to calculate the new position and directly update the attribute instead of asking the object to do so.

The ownership of an attribute does not make the object the “owner” of it. You will not have a rudder with a position attribute. It only allows the object to update its values and denies the real owner to do the same .

Tank position ownership

Tank position ownership


I will show you how to create a Federate to take the ownership of the “Position” attribute of the Tank and Aircraft in the MapViewer Federation. I’ll keep the Map Federate intact, but I need to change a few things in the Tank and Aircraft. You can download all the source code from Github of the changed units and  the new “Geocalc” Federate. There is a little test project here.

The Geocalc federate will subscribe to the BasicUnit class. This will trigger the discoverObjectInstance() event when Tanks and Aircraft arrives.

public void discoverObjectInstance( ObjectInstanceHandle theObject,
                                    ObjectClassHandle theObjectClass,
                                    String objectName ) throws FederateInternalError {
  // Is the object we found a kind of Unit?
  if ( federate.getUnitClass().isClassOf( theObjectClass ) ) {
    try {
      // If so, create a new Unit object in our list.
      federate.newUnit( theObjectClass, theObject  );
    } catch ( Exception e ) {
      log( e.getMessage() );

When a new unit raises, it’s time to ask the RTI for the ownership of the object’s position attribute.

// After a new unit is discovered try to acquire your position attribute so we can update it
public void newUnit( ObjectClassHandle theObjectClass, ObjectInstanceHandle theObject ) throws Exception {
  unitClass.createNew( theObjectClass, theObject );

We can do this by invoking the method attributeOwnershipAcquisition() of the RTI Ambassador. We must pass the handle of the attribute we want to take.

public void acquirePosition( ObjectInstanceHandle theObject ) throws Exception {
  AttributeHandleSet ahs = rtiamb.getAttributeHandleSetFactory().create();
  ahs.add( positionHandle );
  rtiamb.attributeOwnershipAcquisition( theObject, ahs, null );

The RTI will ask (or command) the attribute owner ( Tank / Aircraft ) to release the ownership. Here I decided to give the ownership without complaints but you can deny it by invoking attributeOwnershipReleaseDenied() from the RTIAmbassador.

public void requestAttributeOwnershipRelease( ObjectInstanceHandle theObject,
    AttributeHandleSet candidateAttributes, byte[] userSuppliedTag)	throws FederateInternalError {
  try {
    federate.releaseAttributeOwnership(theObject, candidateAttributes);
  } catch ( Exception e ) {
    // This attributes may not be mine

After the attribute release, the  RTI will trigger event  attributeOwnershipAcquisitionNotification()  of the Federate Ambassador. It is just for your informations, because the ownership is already your at this point.

public void attributeOwnershipAcquisitionNotification( ObjectInstanceHandle theObject,
    AttributeHandleSet securedAttributes, byte[] userSuppliedTag) throws FederateInternalError {
  log("Ownsership acquired : " + theObject );

From now you can update the position as if it were yours. The old owner can’t update it anymore  ( until he decides to take it back ).

public void updatePosition() throws Exception {
  for ( UnitObject unit : instances  ) {
    AttributeHandleValueMap attributes = rtiamb.getAttributeHandleValueMapFactory().create(1);
    attributes.put( positionHandle, encoder.encodePosition( unit.getPosition() ) );			
    rtiamb.updateAttributeValues( unit.getHandle(), attributes, "Unit Position".getBytes() );



Add Comment