# How to determine the laser beam in Solution of Exercise 4.1?

**URL:** <https://get-help.theconstruct.ai/t/how-to-determine-the-laser-beam-in-solution-of-exercise-4-1/30438>\
**Category:** C++ For Robotics\
**Created:** [May 9, 2024, 9:19am UTC](https://get-help.theconstruct.ai/t/how-to-determine-the-laser-beam-in-solution-of-exercise-4-1/30438 "2024-05-09T09:19:23Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![min.wang.1997.01.13](https://get-help.theconstruct.ai/user_avatar/get-help.theconstruct.ai/min.wang.1997.01.13/32/8912_2.png) [@min.wang.1997.01.13](https://get-help.theconstruct.ai/u/min.wang.1997.01.13)\
**Post date:** [May 9, 2024, 9:19am UTC](https://get-help.theconstruct.ai/t/how-to-determine-the-laser-beam-in-solution-of-exercise-4-1/30438/1 "2024-05-09T09:19:23Z")

</div>

Could you please tell me how you determine the laser beam index here?

```auto
// Get readings
  float right = rosbot.get_laser(121);
  float left = rosbot.get_laser(431);

```

---

<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:** [May 10, 2024, 9:52am UTC](https://get-help.theconstruct.ai/t/how-to-determine-the-laser-beam-in-solution-of-exercise-4-1/30438/2 "2024-05-10T09:52:48Z")

</div>

It is hard to understand your point. Please provide more context.

---

<div class="post-metadata">

**Author:** ![min.wang.1997.01.13](https://get-help.theconstruct.ai/user_avatar/get-help.theconstruct.ai/min.wang.1997.01.13/32/8912_2.png) [@min.wang.1997.01.13](https://get-help.theconstruct.ai/u/min.wang.1997.01.13)\
**Post date:** [May 10, 2024, 7:26pm UTC](https://get-help.theconstruct.ai/t/how-to-determine-the-laser-beam-in-solution-of-exercise-4-1/30438/3 "2024-05-10T19:26:39Z")

</div>

![Screenshot 2024-05-10 at 21.25.26](https://get-help.theconstruct.ai/uploads/default/original/2X/2/2f7a6b02128cfd3db60315d1185f3bdf1e106548.png)

The task is to call the `get_laser(n)` method, asking for the two readings that you think will delimite the wall from the left to the right.

I think the laser beam of left should be (360+180)=540  
right should be 180 degree  
or if we want to detect the laser beam of the wall edge, the left might be a number between 540 and 719; the right might be a number between 0 and 180.

These two lines of code from the solution of exercise 4.1.  
Let me paste the code here:

```auto
#include "rosbot_control/rosbot_class.h"
#include <ros/ros.h>

int main(int argc, char **argv) {
  ros::init(argc, argv, "rosbot_node");

  RosbotClass rosbot;

  rosbot.move_forward(3);

  // Get readings
  float right = rosbot.get_laser(121);
  float left = rosbot.get_laser(431);
  
  // Define and assign array values
  float array_laser[] = {left,right};
  // Print array
  ROS_INFO_STREAM("The wall is at " << array_laser[0] << " meters to the left, and at " << array_laser[1] << " meters to the right from the robot ");
  
    
    
  return 0;
}

```

---

<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:** [May 13, 2024, 12:24pm UTC](https://get-help.theconstruct.ai/t/how-to-determine-the-laser-beam-in-solution-of-exercise-4-1/30438/4 "2024-05-13T12:24:21Z")

</div>

I see.

Did you consider that the laser beam angles are with respect to the robot and not the wall? So, it depends on whether the robot is directly facing the wall as we have in the image, or not. Also, the robot’s distance from the wall would be a factor.

That, that does not mean what we have in the exercise is correct. What counts is that you are able to confirm that your reading in actually correct.

---

<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:** [May 18, 2024, 12:25pm UTC](https://get-help.theconstruct.ai/t/how-to-determine-the-laser-beam-in-solution-of-exercise-4-1/30438/5 "2024-05-18T12:25:16Z")

</div>

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