私は Pitch pRTI free と "World Map" シミュレーターを使用しています。「The HLA Tutorial.pdf」の 50 ページを参照してフェデレート インスタンスの設定と更新を試みましたが、失敗しています。理由がわかりません。事前に、コード内のオブジェクトはインスタンス化され、ワールド マップでレンダリングされますが、その位置は更新されません。アトリビュート、オブジェクト ハンドル、アトリビュート ハンドル、および RTIambassador に関連するコードの一部を貼り付けました。いくつかの構造があり、それらは RPR Fom に基づいていることに気付くかもしれませんが、それらのいくつかは最適な実装ではない可能性があります。更新属性の試行は、最後の 15 行にあります。
ありがとうございました!
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);