Can I measure light in BGE? (environmental sensor simulation)

HI. I am new to this forum, but not exactly new to Blender. I haven’t used it as much as I would have liked, but I’ve been busy so it kinda fell away from me. Anyway, I am trying to determine how easy it would be use Blender’s BGE to build simulations for simple robotics projects. The new servo type motion actuator looks very promising in this respect.

I do not anticipate Blender to be great at this “out of the box”, but if it is possible to build a useful simulation environment without having to muck about in the source I would be thrilled.

Here’s the question of the day then:
Is it possible to measure the strength of light at a given point in the BGE? I know I can fake it to an extent by measuring the distance to a lamp then applying a fall off factor. Additionally I can check for line of sight with the lamp to guess if the sensor is in shadow, but that does nothing as far as diffuse shadows goes. The point is that all the light calculations are handled by the engine, I just have to access that data somehow to feed it to the sensor.
Anybody got a clue on this?

I checked the API docs but I didn’t see anything useful.

The second question, assuming a negative response to the first then is:
How difficult would it be to make a Python hook in the source code to the rendering data (such as brightness of a measured region)? I have not crawled around in the source yet and am a little concerned about takling something too complex right now. (Too much to do not enough me.)

Cheers and thanks,
Neocognitron

Nothing? Not one bite? Did I say something wrong?

Alright, so getRGPA() returns the color of a given vertex. Does anyone happen to know if that color is altered by a light source, or if it is assigned and static?

I will investigate this on my own soon, right now I m trying to make wheels work properly. Forces don’t seem to apply properly right now, though it worked last night… oh well.

No one knows… If you can calculate light intensity and distance, that might do it.
You can actually change the light magnitude with IPOs.

I’m pretty sure getRGBA(), as well as similar "get"s, are fixed and unrelated to lighting. Other than that I can’t really help.

Thanks for the replies.

I’m gonna use a distance calculation for now.
I did think of an expensive solution that would work, but I don’t wanna do it right now.
(Use the BGE to take a small screen shot and measure that with a python script . . .hmm . . . i wonder if I could just take a sample and put it in ram rather than the disk . . . hmmm, I will investigate that.)

I figured that getRBGA() was a static value, that’s why I was putting off dealing with failing to make it work.

I was aware of being able to change the light’s magnitude via IPOs but that is not really applicable in this instance. The light should be a static thing (at first), I want the sensors to be able to register the intensity of the light hitting them. The robot will drive torward the light source by attempting to equalize the intensity on two sensors. If i get that working (its a race between BGE and C–>SDL) then I will try checking the magnitude of the light and then add multiple light sources and then …um…math.

I know that this is way off-topic, and not at all helpful to your blender questions, but if you’re looking for robotics simulation software, try player (base), stage (2d simulation), and gazebo (3d simulation – beta!). It’s pretty powerful stuff - because the simulators are somewhat separated from player, if you get a program to work in the simulator, it will also work on a robot which runs player!

Now that you mention it, I have heard of Gazebo. Though the ability to offload code to a bot is not useful unless I can target particular platforms. I have two that I’m working with and neither I think could handle it. I have a 2D simulator that I’m building from scratch for testing various relational mapping algorithms I’m playing with though.

Also I have an ulterior motive for using Blender. I really want to get more familiar with it, and this seemed like a good way to kill some birds with rocks or something.

Still, i will check out your suggestions. It may be a better solution overall.
<edit>neat. Stage seems to be just what i was building only its already built. Gonna do some API diving tonight on this one.</edit>
Cheers,
Neocognitron

This is pretty hard stuff, very little people are gonna be able to help you out on this sorry.

But for this screenshot stuff, try searching for the “video texture player” and “realtime shadows”, the guys behind these special scripts do work with screenshot and framebuffers, it may be usefull I think.

Cloud_GL >> Thanks for the suggestion. I will take poke around there when I get the chance.

If anyone cares, (this not being Blender related) I have failed to get Player/Stage compiled on Windows…actually I failed to get glib2.0 compiled on windows and that’s a dependency. It seems I can get mingw32 to find gettext but not pkg-config, while I can get cygwin to find pkg-config but not gettext…I have to take a break from that or I will become filled with hate a and murderous intent. I must wait until I am filled with coffee instead.