# ReadingLaser code interpretation

**URL:** <https://get-help.theconstruct.ai/t/readinglaser-code-interpretation/34449>\
**Category:** Behavior Trees for ROS2\
**Created:** [January 17, 2025, 9:55pm UTC](https://get-help.theconstruct.ai/t/readinglaser-code-interpretation/34449 "2025-01-17T21:55:48Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![fgenestcvdl](https://get-help.theconstruct.ai/user_avatar/get-help.theconstruct.ai/fgenestcvdl/32/9348_2.png) [@fgenestcvdl](https://get-help.theconstruct.ai/u/fgenestcvdl)\
**Post date:** [January 17, 2025, 9:55pm UTC](https://get-help.theconstruct.ai/t/readinglaser-code-interpretation/34449/1 "2025-01-17T21:55:49Z")

</div>

what is the intent of this loop ?

```
// 200 readings, from right to left, from -57 to 57 degress
// calculate new velocity cmd
float min = 10;
float current;
for (int i = 0; i < 200; i++) {
  current = data1;
  if (current < min) {
    min = current;
  }
}

```

1. The included comment is false
2. Since data1 = \_msg-\>ranges[0] and is provided by the call back of the subscriber to the laser scan it is looking this look is only to increase the chance that the laser scan value be below the “succes” thresold by sampling any updated value during the loop execution

---

<div class="post-metadata">

**Author:** ![bayodesegun](https://get-help.theconstruct.ai/user_avatar/get-help.theconstruct.ai/bayodesegun/32/10684_2.png) [@bayodesegun](https://get-help.theconstruct.ai/u/bayodesegun)\
**Post date:** [January 20, 2025, 9:39am UTC](https://get-help.theconstruct.ai/t/readinglaser-code-interpretation/34449/2 "2025-01-20T09:39:57Z")

</div>

Thanks for the feedback. Could you please tell us where we have this code? What unit and what section?

---

<div class="post-metadata">

**Author:** ![albertoezquerro](https://get-help.theconstruct.ai/user_avatar/get-help.theconstruct.ai/albertoezquerro/32/7031_2.png) [@albertoezquerro](https://get-help.theconstruct.ai/u/albertoezquerro)\
**Post date:** [January 20, 2025, 2:57pm UTC](https://get-help.theconstruct.ai/t/readinglaser-code-interpretation/34449/3 "2025-01-20T14:57:03Z")

</div>

Hello @fgenestcvdl ,

I’ve been reviewing the code and it seems to me that loop is doing nothing. Therefore, I have removed it. Many thanks for your feedback.

---

<div class="post-metadata">

**Author:** ![system](https://get-help.theconstruct.ai/uploads/default/original/2X/9/9d3ce8305cc0d0d9b6e07d15767a6f245c526f1b.jpeg) [@system](https://get-help.theconstruct.ai/u/system)\
**Post date:** [January 25, 2025, 2:58pm UTC](https://get-help.theconstruct.ai/t/readinglaser-code-interpretation/34449/4 "2025-01-25T14:58:03Z")

</div>

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.
