ROS2 in 5days (C++) Rosject: TurtleBot3 LaserScan Values not Consistent with Gazebo Simulation

Hello,

I’m working on the Rosject in ‘ROS2 in 5 days (C++)’ and am running issues reading laser scan values. I’m able to subscribe to the /scan topic, however laser scan values received are not consistent with the position of the turtlebot within the gazebo environment. I’ve attempted to move/rotate around the environment and see if laser scan values output correspond, but values are consistently between 0.2 to 1.5 regardless of where the turtlebot is positioned/oriented. I would expect some ‘Inf’ values for cases where the distance is greater than the 3.5m max range but this isn’t the case.

An example output of ‘ros2 topic echo /scan’ is presented below. Any help with resolving this issue would be greatly appreciated!

header:
stamp:
sec: 1163
nanosec: 942000000
frame_id: base_scan
angle_min: -3.1415998935699463
angle_max: 3.1415998935699463
angle_increment: 0.01750195026397705
time_increment: 0.0
scan_time: 0.0
range_min: 0.11999999731779099
range_max: 3.5
ranges:

  • 0.2720809876918793
  • 0.4809080958366394
  • 0.48294565081596375
  • 0.47152000665664673
  • 0.5063456296920776
  • 0.5183495879173279
  • 0.5190759897232056
  • 0.5259885787963867
  • 0.5043388605117798
  • 0.5429102182388306
  • 0.550223171710968
  • 0.5400900840759277
  • 0.5486384630203247
  • 0.5759043097496033
  • 0.566129207611084
  • 0.569210946559906
  • 0.6006303429603577
  • 0.6095983386039734
  • 0.599082887172699
  • 0.6267467141151428
  • 0.6303408145904541
  • 0.651023268699646
  • 0.6620339155197144
  • 0.6798816919326782
  • 0.6863064169883728
  • 0.7101622223854065
  • 0.7300627827644348
  • 0.7384911775588989
  • 0.7480509281158447
  • 0.7324837446212769
  • 0.7220928072929382
  • 0.7031022310256958
  • 0.7252587080001831
  • 0.7166895866394043
  • 0.6978046894073486
  • 0.709595263004303
  • 0.6684306263923645
  • 0.6652006506919861
  • 0.6704035401344299
  • 0.6390416622161865
  • 0.671387255191803
  • 0.6580063700675964
  • 0.6657813191413879
  • 0.6576122641563416
  • 0.6350789666175842
  • 0.6467925906181335
  • 0.6231690645217896
  • 0.6389837265014648
  • 0.6466415524482727
  • 0.6339901685714722
  • 0.6089464426040649
  • 0.6279748678207397
  • 0.6261333227157593
  • 0.6369873285293579
  • 0.6181063652038574
  • 0.6071773767471313
  • 0.6170379519462585
  • 0.6107621788978577
  • 0.6121054291725159
  • 0.6062418818473816
  • 0.62309730052948
  • 0.6124072670936584
  • 0.6045001745223999
  • 0.6044687032699585
  • 0.6227615475654602
  • 0.6210532784461975
  • 0.6217013001441956
  • 0.6053822636604309
  • 0.6224122047424316
  • 0.624238908290863
  • 0.6130855083465576
  • 0.6323776841163635
  • 0.6212782859802246
  • 0.6088104248046875
  • 0.6260411143302917
  • 0.635569155216217
  • 0.6319721341133118
  • 0.6459081172943115
  • 0.6402881741523743
  • 0.6530896425247192
  • 0.6566755175590515
  • 0.6419402956962585
  • 0.6398663520812988
  • 0.6638176441192627
  • 0.6661980152130127
  • 0.6588167548179626
  • 0.6828429698944092
  • 0.6969740986824036
  • 0.6844908595085144
  • 0.6861727237701416
  • 0.6854206919670105
  • 0.6883237361907959
  • 0.6985785365104675
  • 0.7201918959617615
  • 0.727832555770874
  • 0.7022713422775269
  • 0.7514712810516357
  • 0.7464208602905273
  • 0.7660641670227051
  • 0.7670108675956726
  • 0.7758666276931763
  • 0.795060932636261
  • 0.8029385209083557
  • 0.8056986331939697
  • 0.8331095576286316
  • 0.8442100882530212
  • 0.8556262254714966
  • 0.8617135882377625
  • 0.8749591708183289
  • 0.9112457633018494
  • 0.9225281476974487
  • 0.9584336876869202
  • 0.9549168348312378
  • 0.9964459538459778
  • 1.0028786659240723
  • 1.0211728811264038
  • 1.0431301593780518
  • 1.0630406141281128
  • 1.0887057781219482
  • 1.130672812461853
  • 1.1443603038787842
  • 1.2005341053009033
  • 1.2304497957229614
  • 1.2831318378448486
  • 1.3148354291915894
  • 1.3694559335708618
  • 1.4069299697875977
  • 1.4547417163848877
  • ‘…’
    intensities:
  • 0.0
  • 0.0
  • 0.0
  • 0.0
  • 0.0
  • 0.0
  • 0.0
  • 0.0
  • 0.0
  • 0.0
  • 0.0
  • 0.0
  • 0.0
  • 0.0
  • 0.0
  • 0.0
  • 0.0
  • 0.0
  • 0.0
  • 0.0
  • 0.0
  • 0.0
  • 0.0
  • 0.0
  • 0.0
  • 0.0
  • 0.0
  • 0.0
  • 0.0
  • 0.0
  • 0.0
  • 0.0
  • 0.0
  • 0.0
  • 0.0
  • 0.0
  • 0.0
  • 0.0
  • 0.0
  • 0.0
  • 0.0
  • 0.0
  • 0.0
  • 0.0
  • 0.0
  • 0.0
  • 0.0
  • 0.0
  • 0.0
  • 0.0
  • 0.0
  • 0.0
  • 0.0
  • 0.0
  • 0.0
  • 0.0
  • 0.0
  • 0.0
  • 0.0
  • 0.0
  • 0.0
  • 0.0
  • 0.0
  • 0.0
  • 0.0
  • 0.0
  • 0.0
  • 0.0
  • 0.0
  • 0.0
  • 0.0
  • 0.0
  • 0.0
  • 0.0
  • 0.0
  • 0.0
  • 0.0
  • 0.0
  • 0.0
  • 0.0
  • 0.0
  • 0.0
  • 0.0
  • 0.0
  • 0.0
  • 0.0
  • 0.0
  • 0.0
  • 0.0
  • 0.0
  • 0.0
  • 0.0
  • 0.0
  • 0.0
  • 0.0
  • 0.0
  • 0.0
  • 0.0
  • 0.0
  • 0.0
  • 0.0
  • 0.0
  • 0.0
  • 0.0
  • 0.0
  • 0.0
  • 0.0
  • 0.0
  • 0.0
  • 0.0
  • 0.0
  • 0.0
  • 0.0
  • 0.0
  • 0.0
  • 0.0
  • 0.0
  • 0.0
  • 0.0
  • 0.0
  • 0.0
  • 0.0
  • 0.0
  • 0.0
  • 0.0
  • 0.0
  • 0.0
  • 0.0
  • ‘…’

Hi @sina.sed,

I think you are getting the right values, since they are consistent with the size of the simulated lab. You are not getting any infinite values because the square in which the turtlebot3 is in is less than 3.5m.

Does tha make sense?

Thank you! I didn’t realize the environment was scaled to be smaller than 3.5m. Also, I didn’t notice that there was a pedestrian object in the environment at first. Laser outputs appear to be making sense now.