Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trying to understand light sensors #31

Open
LohGeek opened this issue May 19, 2013 · 6 comments
Open

Trying to understand light sensors #31

LohGeek opened this issue May 19, 2013 · 6 comments
Labels

Comments

@LohGeek
Copy link

LohGeek commented May 19, 2013

Hello,

I am running the chasing scenario on a flat terrain with obstacle avoidance. My robot has a light detector with a variable height (a motor is changing it). Having seen quite a fuzz around the theme of optic detection, I would like to ask the opinion of those who already investigated the light detector about two issues:

  1. Is the light detector in the simulator returning binary values (light detected or no light detected), or is it analogical as it should be? (And how could I see it's return values in real-time?)
  2. Is the light of the light-source produced at a single height? If you move the light-source sligthly upwards or downwards, are you still able to detect it? (To maximize the adaptability of my robot, I mounted my light sensor on a motor to search for lights at different heights... and I am starting to think it was not such a good idea...)

Thanks

@tcies
Copy link
Contributor

tcies commented May 19, 2013

Not getting invested into this, but you might want to check out robogen-simulator/src/model/sensors/LightSensor.cpp line 210 ff.

@Mikaz-fr
Copy link

1: Yes binary value (for this year version of the software). To see the output add the following lines to LightSensor.cpp:
Line 29 -> #include "model/Model.h"
Line 366 -> std::cout << "output: " << output << std::endl;
And recompile.

2: You should have a slight tolerance for detecting the light, depending of the amplitude of your sensor moves it should be ok. Make sure to adapte the height of the light source in ChasingScenario.cpp (line 61). When you'll be able to read the sensor value you can verify this.

I think that for this project, the simpler is your robot the more chance you have to see it working...

@tcies
Copy link
Contributor

tcies commented May 19, 2013

Wait... what does the ambient light do then? Is there a threshold somehwere?

@Mikaz-fr
Copy link

The ambient light allow you to see the environment in simulation (as user). But don't expect it to change anything for the light sensors. They only detect light source pointed directly at them.
If you want to go into the details, there is a threshold of 100 while the ambiant light add 10 to the perceived light:

    // Rescale total light received
    int output = 0;
    if (totalLight >= MAX_INTENSITY) {
        output = MAX_INTENSITY_VALUE;
    } else if (totalLight <= MIN_INTENSITY) {
        output = MIN_INTENSITY_VALUE;
    } else {
        output = MIN_INTENSITY_VALUE
                + (std::min(totalLight, MAX_INTENSITY) - MIN_INTENSITY) / 100
                        * (MAX_INTENSITY_VALUE - MIN_INTENSITY_VALUE);
    }

But then the value is binarized.

@hsubox
Copy link

hsubox commented May 19, 2013

if your robot is having difficulty seeing the light source, it may also help to increase the radius of the light source in LightSource.cpp. 0.05 seems to work for us.

@akshararai
Copy link

Yeah, actually this output ranges from 0 to 1. And since it returns an int, it gets binarised. I think if we want we can change the behaviour by returning a double. But I wonder if the real light sensors work like that. From the behaviour we saw, while testing ours, we think they are rather binary too.
As for your old question on whether light is still visible if you move up or down- no. The code of light sensor only takes into account 'visible' sources, which are the ones you get direct light from. And since the aperture of our light sensors is only 15 degrees or so, I think we see light source only when its right in front of it.
Also, to improve visibility from a larger distance, you should increase the radius, as @hsubox pointed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants