[Playerstage-developers] Help: Weird laser range readings

 [Playerstage-developers] Help: Weird laser range readings From: Vikram Harinath - 2003-11-16 15:53:01 ```Hi there, I am using PlayerStage 1.3.1, librtk 2.1.1. I was doing some testing under Stage and was wondering why my code wasn't working when I realised that I was getting strange readings from the laser sensor. However, here is my dilemma: In one piece of code, which I just called logger.cc, I used it to grab the laser range readings and output the readings of every degree (from -90 to 90). My code went as follows: for(i=0; i<=360; i+=2) //only record the "whole" degrees over a range of 180deg { std::cout << "Laser Angle: " << (i*0.5-90); std::cout << " Laser - Distance to obstacle: " << lp.ranges[i] << std::endl; } This gave me the following output: Laser Angle: -3 Laser - Distance to obstacle: 3620 Laser Angle: -2 Laser - Distance to obstacle: 3620 Laser Angle: -1 Laser - Distance to obstacle: 3620 Laser Angle: 0 Laser - Distance to obstacle: 3620 Laser Angle: 1 Laser - Distance to obstacle: 3620 Laser Angle: 2 Laser - Distance to obstacle: 3620 Laser Angle: 3 Laser - Distance to obstacle: 3620 Which is absolutely fine. However, when I implemented the following code into my current program - obsavoid.cc: for (laserangle = 0; laserangle <= 360; laserangle+=2) { cout << "Laser Angle: " << (laserangle*0.5-90); cout << " Laser - Distance to obstacle: " << lp.ranges[laserangle] << endl; } This gave me the following output (with the robot at exactly the same position): Laser Angle: -3 Laser - Distance to obstacle: 16385 Laser Angle: -2 Laser - Distance to obstacle: 0 Laser Angle: -1 Laser - Distance to obstacle: 16384 Laser Angle: 0 Laser - Distance to obstacle: 49151 Laser Angle: 1 Laser - Distance to obstacle: 16384 Laser Angle: 2 Laser - Distance to obstacle: 0 Laser Angle: 3 Laser - Distance to obstacle: 0 What am I doing wrong here? I have no idea why this is happening. Thankyou for any help you can give me. Vikram ```

 [Playerstage-developers] Help: Weird laser range readings From: Vikram Harinath - 2003-11-16 15:53:01 ```Hi there, I am using PlayerStage 1.3.1, librtk 2.1.1. I was doing some testing under Stage and was wondering why my code wasn't working when I realised that I was getting strange readings from the laser sensor. However, here is my dilemma: In one piece of code, which I just called logger.cc, I used it to grab the laser range readings and output the readings of every degree (from -90 to 90). My code went as follows: for(i=0; i<=360; i+=2) //only record the "whole" degrees over a range of 180deg { std::cout << "Laser Angle: " << (i*0.5-90); std::cout << " Laser - Distance to obstacle: " << lp.ranges[i] << std::endl; } This gave me the following output: Laser Angle: -3 Laser - Distance to obstacle: 3620 Laser Angle: -2 Laser - Distance to obstacle: 3620 Laser Angle: -1 Laser - Distance to obstacle: 3620 Laser Angle: 0 Laser - Distance to obstacle: 3620 Laser Angle: 1 Laser - Distance to obstacle: 3620 Laser Angle: 2 Laser - Distance to obstacle: 3620 Laser Angle: 3 Laser - Distance to obstacle: 3620 Which is absolutely fine. However, when I implemented the following code into my current program - obsavoid.cc: for (laserangle = 0; laserangle <= 360; laserangle+=2) { cout << "Laser Angle: " << (laserangle*0.5-90); cout << " Laser - Distance to obstacle: " << lp.ranges[laserangle] << endl; } This gave me the following output (with the robot at exactly the same position): Laser Angle: -3 Laser - Distance to obstacle: 16385 Laser Angle: -2 Laser - Distance to obstacle: 0 Laser Angle: -1 Laser - Distance to obstacle: 16384 Laser Angle: 0 Laser - Distance to obstacle: 49151 Laser Angle: 1 Laser - Distance to obstacle: 16384 Laser Angle: 2 Laser - Distance to obstacle: 0 Laser Angle: 3 Laser - Distance to obstacle: 0 What am I doing wrong here? I have no idea why this is happening. Thankyou for any help you can give me. Vikram ```
 Re: [Playerstage-developers] Help: Weird laser range readings From: Vikram Harinath - 2003-11-17 00:08:21 ```Hi again, Well I found my error - I didnt have the robot.Read() line in the continuous for loop. :P Ooopsie. Thanks anyway. Vikram Vikram Harinath wrote: > Hi there, > > I am using PlayerStage 1.3.1, librtk 2.1.1. > > I was doing some testing under Stage and was wondering why my code > wasn't working when I realised that I was getting strange readings from > the laser sensor. However, here is my dilemma: > > In one piece of code, which I just called logger.cc, I used it to grab > the laser range readings and output the readings of every degree (from > -90 to 90). My code went as follows: > > for(i=0; i<=360; i+=2) //only record the "whole" degrees over a range > of 180deg > { > std::cout << "Laser Angle: " << (i*0.5-90); > std::cout << " Laser - Distance to obstacle: " << lp.ranges[i] << > std::endl; > } > > This gave me the following output: > > Laser Angle: -3 Laser - Distance to obstacle: 3620 > Laser Angle: -2 Laser - Distance to obstacle: 3620 > Laser Angle: -1 Laser - Distance to obstacle: 3620 > Laser Angle: 0 Laser - Distance to obstacle: 3620 > Laser Angle: 1 Laser - Distance to obstacle: 3620 > Laser Angle: 2 Laser - Distance to obstacle: 3620 > Laser Angle: 3 Laser - Distance to obstacle: 3620 > > Which is absolutely fine. However, when I implemented the following code > into my current program - obsavoid.cc: > > for (laserangle = 0; laserangle <= 360; laserangle+=2) > { > cout << "Laser Angle: " << (laserangle*0.5-90); > cout << " Laser - Distance to obstacle: " << lp.ranges[laserangle] << > endl; > } > > This gave me the following output (with the robot at exactly the same > position): > > Laser Angle: -3 Laser - Distance to obstacle: 16385 > Laser Angle: -2 Laser - Distance to obstacle: 0 > Laser Angle: -1 Laser - Distance to obstacle: 16384 > Laser Angle: 0 Laser - Distance to obstacle: 49151 > Laser Angle: 1 Laser - Distance to obstacle: 16384 > Laser Angle: 2 Laser - Distance to obstacle: 0 > Laser Angle: 3 Laser - Distance to obstacle: 0 > > What am I doing wrong here? I have no idea why this is happening. > > Thankyou for any help you can give me. > > Vikram > > ------------------------------------------------------- > This SF. Net email is sponsored by: GoToMyPC > GoToMyPC is the fast, easy and secure way to access your computer from > any Web browser or wireless device. Click here to Try it Free! > https://www.gotomypc.com/tr/OSDN/AW/Q4_2003/t/g22lp?Target=mm/g22lp.tmpl > _______________________________________________ > Playerstage-developers mailing list > Playerstage-developers@... > https://lists.sourceforge.net/lists/listinfo/playerstage-developers ```