How can I correctly update an instance of a Federate?

164 views Asked by At

I am using Pitch pRTI free and "World Map" simulator. I tried by looking at page 50 of "The HLA Tutorial.pdf" to set and update for a federate instance, but I am failing in it, I don't know why. In advance, the object in my code is instantiated and renderized in the World Map, but it just doesn't update it's position. I pasted the parts of the code related to the attributes, object handle, attributes handles and RTIambassador. You may notice that there are some structures, they are based on the RPR Fom, some of them might not be the best implementation. The update attributes attempt is in the last 15 lines.

Thank you!

   private RTIambassador _rtiAmbassador;
   private final String[] _args;
   private InteractionClassHandle interactionHandle;   
   private ObjectInstanceHandle _userId;

   private AttributeHandle _attributeEntityType;
   private AttributeHandle _attributeSpatial;   
   private AttributeHandle _attributeEntityId; 
   private AttributeHandle _attributeDamageState; 
   private AttributeHandle _attributeForceId; 
   private AttributeHandle _attributeIsConcealed; 
   private AttributeHandle _attributeMarking; 
.
.
.
   private EncoderFactory _encoderFactory;
.
.
.
         ObjectClassHandle participantId = _rtiAmbassador.getObjectClassHandle("BaseEntity.PhysicalEntity.Platform.Aircraft");          

         //Atributos da entidade criada. Esses campos foram retirados do FOM base, nesse caso o netn2_2010.xml
         _attributeEntityType = _rtiAmbassador.getAttributeHandle(participantId, "EntityType");        
         _attributeEntityId = _rtiAmbassador.getAttributeHandle(participantId, "EntityIdentifier");  
         _attributeSpatial = _rtiAmbassador.getAttributeHandle(participantId, "Spatial");  
         _attributeDamageState = _rtiAmbassador.getAttributeHandle(participantId, "DamageState");   
         _attributeForceId = _rtiAmbassador.getAttributeHandle(participantId, "ForceIdentifier");  
         _attributeIsConcealed = _rtiAmbassador.getAttributeHandle(participantId, "IsConcealed");   
         _attributeMarking = _rtiAmbassador.getAttributeHandle(participantId, "Marking");  
.
.
.
         AttributeHandleSet attributeSet = _rtiAmbassador.getAttributeHandleSetFactory().create();
         attributeSet.add(_attributeEntityType);
         attributeSet.add(_attributeSpatial);
         attributeSet.add(_attributeEntityId);
         attributeSet.add(_attributeForceId);
         attributeSet.add(_attributeIsConcealed);
         attributeSet.add(_attributeMarking);
.
.
.

         //Spatial

         WorldLocationStruct worldLocation = new WorldLocationStruct( 7.291122019556398e-304, 4114673.3659611, -4190319.2556862);
         VelocityVectorStruct velocityVectorStruct = new VelocityVectorStruct(0.5415523,-0.5452158,-1.1100446);
         OrientationStruct orientationStruct = new OrientationStruct(-12.183228,-7.050103e+07,0.0);
         SpatialFPStruct spatialFPStruct = new SpatialFPStruct(worldLocation,velocityVectorStruct,orientationStruct);
         SpatialFPStructEncoder spatialFPStructEncoder = new SpatialFPStructEncoder(spatialFPStruct);     

         /////////////////// Entity Type

             EntityTypeStruct entityTypeStruct = new EntityTypeStruct(1,2,29,20,13,3,0);
             EntityTypeStructEncoder entityTypeStructEncoder = new EntityTypeStructEncoder(entityTypeStruct);

         ///////////// Force Identifier         
             ForceIdentifierEnum forceIdEnum = ForceIdentifierEnum.NEUTRAL;
             ForceIdentifierEnumEncoder forceIdEnumEncoder = new ForceIdentifierEnumEncoder(forceIdEnum);
         /////////////// Entity Identifier         

             EntityIdentifierStruct entityIdentifierStruct = new EntityIdentifierStruct(3001,101,102);
             EntityIdentifierStructEncoder entityIdentifierStructEncoder = new EntityIdentifierStructEncoder(entityIdentifierStruct);


         // IsConcealed
         HLAoctet isConcealed = _encoderFactory.createHLAoctet();           
         isConcealed.setValue((byte) 0);

         //Marking ----

         MarkingStruct markingStruct = new MarkingStruct(1,"TesteXplane");
         MarkingStructEncoder markingStructEncoder = new MarkingStructEncoder(markingStruct);

         AttributeHandleValueMap attributes = _rtiAmbassador.getAttributeHandleValueMapFactory().create(7);

         attributes.put(_attributeEntityType , entityTypeStructEncoder.toByteArray());
         attributes.put(_attributeSpatial , spatialFPStructEncoder.toByteArray());       
         attributes.put(_attributeForceId, forceIdEnumEncoder.toByteArray());
         attributes.put(_attributeEntityId , entityIdentifierStructEncoder.toByteArray());
         attributes.put(_attributeIsConcealed, isConcealed.toByteArray());  
         attributes.put(_attributeMarking, markingStructEncoder.toByteArray());          

.
.
.
         _rtiAmbassador.subscribeObjectClassAttributes(participantId, attributeSet);
         _rtiAmbassador.publishObjectClassAttributes(participantId, attributeSet);  
.
.
.
                 forceIdEnum = ForceIdentifierEnum.OPPOSING;
                 forceIdEnumEncoder = new ForceIdentifierEnumEncoder(forceIdEnum);
                 attributes.put(_attributeForceId, forceIdEnumEncoder.toByteArray());

                  worldLocation = new WorldLocationStruct(542543245345.9, 4114673.3659611, -4190319.2556862);
                  velocityVectorStruct = new VelocityVectorStruct(0.5415523, -0.5452158, -1.1100446);
                  orientationStruct = new OrientationStruct(-12.183228,-7.050103e+07,0.0);
                  spatialFPStruct = new SpatialFPStruct(worldLocation,velocityVectorStruct,orientationStruct);
                  spatialFPStructEncoder = new SpatialFPStructEncoder(spatialFPStruct);        

                 attributes.put(_attributeSpatial, spatialFPStructEncoder.toByteArray());
                 System.out.println("Updating position");

             _rtiAmbassador.updateAttributeValues( _userId, attributes, null);
0

There are 0 answers