Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

How does a sensor find objects exactly?

Ross Penucca
Super Rubik's User
Join date: 3 Jun 2008
Posts: 26
06-30-2008 00:52
Ok, I've been wondering this for a while now, and the LSL wiki doesn't give a very good explaination as to how a sensor senses objects. To be more specific, how does the arc "look" graphically based on the value of arc in respect to the xyz axes. I've tried testing this using a simple "search for objects at 0.0 radians, then increase by 45.0 radians, rinse and repeat" script, and no matter where I place the other object (+/- x-axis, +/- y-axis, and +/- z-axis in respect to the sensor object), it finds it at 0.0 radians. Now, if the sensor starts at the +x axis from the center of the sensor object, then expands outwards where an arc of PI radians searches in all quadrants of the xyz axes, except for -x, or however it works, then why is my sensor object detecting the object at 0.0 radians no matter where I move the found object? A graphical representation would work WONDERS.

Thanks,
Ross Penucca

PS: Would it be possible to pin-point a certain object found based on its position in respect to the sensor object, instead of name, key, or type?
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
06-30-2008 00:58
How are you getting this angle that you claim keeps being zero? Sensors don't GIVE you any angle inherent to the other object's position, so if you want one you must calculate it.
Dora Gustafson
Registered User
Join date: 13 Mar 2007
Posts: 779
06-30-2008 03:51
From: Ross Penucca
To be more specific, how does the arc "look" graphically based on the value of arc in respect to the xyz axes. A graphical representation would work WONDERS.

See: http://www.lslwiki.net/lslwiki/wakka.php?wakka=llSensor
It has wonderful graphics too
You can pin point a sensed objects since you can get its position: llDetectedPos() and its rotation: llDetectedRot()
_____________________
From Studio Dora
Senuka Harbinger
A-Life, one bit at a time
Join date: 24 Oct 2005
Posts: 491
06-30-2008 05:03
I believe that 0.0 radians produces the same "arc" as PI, a complete sphere. I'd have to test it though.

as to which axis it originates from it should be the positive x axis
_____________________
My SLExchange shop

Typos are forgiven; desecrating the english language with reckless abandon and necrophilic acts is not.


The function is working perfectly fine. It's just not working the way you wanted it to work.
Ross Penucca
Super Rubik's User
Join date: 3 Jun 2008
Posts: 26
06-30-2008 13:55
Thank you Dora, you provided me with what I needed. I guess I'll tweak that around and such. What I want to do with positions of sensed objects is link objects found to the sensor object, which would be the parent prim. IE: Object A is the sensor object, Object B is the sensed object, Object A looks for Object B not by its name, id, or key, but rather Object A looks for Object B (or any object for that matter) in a specific position in relation to Object A.
Talarus Luan
Ancient Archaean Dragon
Join date: 18 Mar 2006
Posts: 4,831
06-30-2008 14:27
Imagine for a moment that a "sensor" is your eye. You look out in any particular direction (the forward or X-axis of the prim is the direction in which your eye is "looking";). The "arc" value is actually 1/2 of the angle describing the "field of view" cone for your eye. If you have tunnel vision, the arc may be 15 degrees (for 30 degrees total angle left-to-right, top-to-bottom, etc). If you have an extremely wide field of vision, seeing everything in front of the plane perpendicular to your viewing direction, the arc would be PI/2. If your eye were "omniscient" (literally "sensing in any direction";), the arc would be PI.

Now, when you look out in any particular direction, you may "see" a LOT of things. Many things may not interest you (and you can only actually "see" the closest 16 things of interest anyway), so the rest of the parameters help you narrow your "interest" criteria so you only get things you are interested in. Name lets you only see things with that exact name. Key is highly specific, only searching for that one specific thing with that unique ID. Type limits the kinds of things you are interested in, like scripted objects, agents (avatars), physical objects, etc. Finally, distance specifies that you are interested in closer things than farther away things.

What is returned from the sensor is an array of up to the closest 16 things which fit the criteria you gave for the sensor. If you keep the criteria narrow enough, then you will likely "see" what you are looking for, if it is there. The information that is returned includes:

llDetectedPos() - the position of the target, in region coordinates.
llDetectedRot() - a rotation describing the orientation of the target itself, unrelated to your eye position or rotation.
llDetectedType() - specifies what the target is.
llDetectedName() - the name of the target
llDetectedKey() - the unique UUID key of the target.
llDetectedGroup() - the unique UUID key of the group the target is presently set to.
llDetectedOwner() - the unique UUID key of the target's owner agent/avatar.
llDetectedVel() - the current velocity vector of the target, including direction and speed.

Now, if you want to figure out the position or rotation relative to your "eye", you have to compute that using your eye's position, and the llDetectedPos position returned from the sensor. If you want to "look" in a specific direction, you have to rotate your eye prim yourself.

Also, make sure you don't get your units mixed up for angles. "45.0 radians" is nonsensical, since there are only about 6.28 radians in a full 360-degree circle. The llSensor function DOES take arc value in radians, so if you wanted to have a 90-degree FoV cone, then you would pass 45.0 * DEG_TO_RAD.
Ross Penucca
Super Rubik's User
Join date: 3 Jun 2008
Posts: 26
06-30-2008 21:14
Oh right, I forgot about DEG_TO_RAD, but you helped clarify how this works PERFECTLY. You let me know exactly what I can do and thank you for it. Now I should be able to finish my first project. :3 Thanks again.