@@ -353,7 +353,7 @@ private unsafe void FetchTopicEndpoints(RosTopic topic, bool disableTopicNameDem
353353 var namePtr = nameBuffer . IsEmpty ? null : ( byte * ) Unsafe . AsPointer ( ref nameBuffer [ 0 ] ) ;
354354
355355 var allocator = RclAllocator . Default . Object ;
356- var accessor = RosEnvironment . IsSupported ( RosEnvironment . Iron )
356+ ITopicEndPointDataAccessor accessor = RosEnvironment . IsSupported ( RosEnvironment . Iron )
357357 ? IronTopicEndPointDataAccessor . Instance
358358 : TopicEndPointDataAccessor . Instance ;
359359
@@ -372,7 +372,8 @@ private unsafe void FetchTopicEndpoints(RosTopic topic, bool disableTopicNameDem
372372 {
373373 for ( var i = 0 ; i < ( int ) endpoints . size . Value ; i ++ )
374374 {
375- items . Span [ i ] = new ( & endpoints . info_array [ i ] , accessor ) ;
375+ // Access info_array through accessor to deal with layout difference between different distros.
376+ items . Span [ i ] = new ( accessor . GetInfoFromArray ( endpoints . info_array , i ) , accessor ) ;
376377 }
377378 topic . UpdatePublishers ( this , items . Span , _nodes ) ;
378379 }
@@ -432,6 +433,11 @@ private unsafe class TopicEndPointDataAccessor : ITopicEndPointDataAccessor
432433 {
433434 public static readonly TopicEndPointDataAccessor Instance = new ( ) ;
434435
436+ public void * GetInfoFromArray ( void * array , int index )
437+ {
438+ return & ( ( rmw_topic_endpoint_info_t * ) array ) [ index ] ;
439+ }
440+
435441 public GraphId GetGraphId ( void * data )
436442 {
437443 var item = ( rmw_topic_endpoint_info_t * ) data ;
@@ -461,7 +467,12 @@ public QosProfile GetQosProfile(void* data)
461467
462468 private unsafe class IronTopicEndPointDataAccessor : ITopicEndPointDataAccessor
463469 {
464- public static readonly TopicEndPointDataAccessor Instance = new ( ) ;
470+ public static readonly IronTopicEndPointDataAccessor Instance = new ( ) ;
471+
472+ public void * GetInfoFromArray ( void * array , int index )
473+ {
474+ return & ( ( RclIron . rmw_topic_endpoint_info_t * ) array ) [ index ] ;
475+ }
465476
466477 public GraphId GetGraphId ( void * data )
467478 {
0 commit comments