Accounting for sensor 'blips'
|
Haravikk Mistral
Registered User
Join date: 8 Oct 2005
Posts: 2,482
|
12-29-2005 15:01
Anyone who's used a sensor may have come across this. Quite simple a sensor 'blip' as I call them is when a sensor detects someone outside of the simulator the sensor is in. The proble with this is that the co-ordinates returned cannot be used to return a meaningful distance using a simple llVecDist() call.
For example, I am in one sim at <10,10,10> and someone else in the neighbouring sim at <246,10,10>. The actual distance between these points is 20m, but the distance it gives will be 266m. In this case simple subtracting 256m will work, however this isn't a sure solution.
What I'm wondering is what the best solution to this is, in terms of getting a useful cross-sim distance from the points returned by the sensor sweep.
|
Jeffrey Gomez
Cubed™
Join date: 11 Jun 2004
Posts: 3,522
|
12-29-2005 17:09
Well, sensors only work up to about 96 meters, right?
Therefore, the blips should always be out of range and, therefore, discarded or accounted for if llVecDist returns greater than that distance.
_____________________
---
|
Haravikk Mistral
Registered User
Join date: 8 Oct 2005
Posts: 2,482
|
12-29-2005 17:38
Unfortunately not, as it's possible for a sensor to detect objects in neighbouring sims. So if you're on the edge of one sim, you can detect objects/avatars in the sim next to you. However, the llDetectedPos() function returns the positions in region coordinates, which don't take into account simulators being next to each other.
So it's possible to have an avatar at <254,0,0> in sim A, and an avatar in sim B (which is to the right of the sim A) at position <1,0,0>. These two avatars are standing directly beside one another, yet the distance returned when you do llVecDist() on these two positions is 254m, when in fact they are only 2m apart (but on different sides of the sim border).
The problem comes when the co-ordinates aren't as simple as these examples, and working out how far apart the avatars REALLY are becomes tricky.
So you're partially correct that the sensor range is important, namely if the distance calculated is greater than 96, then something's wrong (ie we have a situation like I described above). But what I'm having trouble figuring out is what to do instead to work out the distance.
|
Jeffrey Gomez
Cubed™
Join date: 11 Jun 2004
Posts: 3,522
|
12-29-2005 18:04
Oh. So you mean getting the actual range function? if(llVecDist(blah, blahblah) > range) { vector compare = blah - blahblah; compare.x = (float)llAbs((integer)compare.x); compare.y = (float)llAbs((integer)compare.y);
if(compare.x > range || compare.y > range) { if(compare.x > range) compare.x -= 256.0; // Subtract 256 from X if(compare.y > range) compare.y -= 256.0; // Subtract 256 from Y } return llVecMag(compare); }
You can get away with this for all instances of sim border issues I believe, as the sensor range is always smaller than the size of a sim. Should even work on corner sims, if you get a return from one.
_____________________
---
|
Argent Stonecutter
Emergency Mustelid
Join date: 20 Sep 2005
Posts: 20,263
|
12-29-2005 23:08
From: Haravikk Mistral Unfortunately not, as it's possible for a sensor to detect objects in neighbouring sims. So if you're on the edge of one sim, you can detect objects/avatars in the sim next to you. However, the llDetectedPos() function returns the positions in region coordinates, which don't take into account simulators being next to each other. So? vector real_offset(vector pos) { vector my_pos = llDetectedPos(); if(my_pos.x > pos.x + 96.0) pos.x += 256; if(my_pos.x < pos.x - 96.0) pos.x -= 256; if(my_pos.y > pos.y + 96) pos.y += 256; if(my_pos.y < pos.y - 96.0) pos.y -= 256; return pos - my_pos; }
|
Harris Hare
Second Life Resident
Join date: 5 Nov 2004
Posts: 301
|
12-30-2005 00:47
From my experience, sensors never detect avatars outside the current sim.
I've even stood on the edge of a sim with someone on the other side less than 10m away and my sensor won't detect them.
|
Ben Bacon
Registered User
Join date: 14 Jul 2005
Posts: 809
|
12-30-2005 01:55
From: Harris Hare From my experience, sensors never detect avatars outside the current sim. I believe that this occurs when the av has just walked out of the sim you're in into the other - for a short while, and within 10m of the border, their agent is still in the same sim as you, even though their av is painted "next door"
|
Kayla Stonecutter
Scripting Oncalupen
Join date: 9 Sep 2005
Posts: 224
|
12-30-2005 04:17
From: Harris Hare From my experience, sensors never detect avatars outside the current sim.
I've even stood on the edge of a sim with someone on the other side less than 10m away and my sensor won't detect them. Sensors in an object attached to an avatar will not detect across sim borders. If the sensor is not attached, it will detect avatars once every 5 seconds I believe.
|
Haravikk Mistral
Registered User
Join date: 8 Oct 2005
Posts: 2,482
|
12-30-2005 05:59
Hmm, well the sensor I'm dealing with is attached to my HUD (except when it's near enough to a 'permanent' detector that it can use information from this instead, like in my shop). It has been detecting avatars beyond sim boarders quite happily (and to my dismay as it comes up with wildly different distances).
I've gone for a combination of the two solutions proposed, and it seems to working happily now! Thanks everyone for your replies!
|
Kayla Stonecutter
Scripting Oncalupen
Join date: 9 Sep 2005
Posts: 224
|
12-30-2005 10:00
From: Haravikk Mistral Hmm, well the sensor I'm dealing with is attached to my HUD (except when it's near enough to a 'permanent' detector that it can use information from this instead, like in my shop). It has been detecting avatars beyond sim boarders quite happily (and to my dismay as it comes up with wildly different distances).
I've gone for a combination of the two solutions proposed, and it seems to working happily now! Thanks everyone for your replies! Something weird is going on then, I just did some testing of llSensor() and llSensorRepeat() across sim borders. string Text; integer x;
default { state_entry() { llSensorRepeat("", NULL_KEY, AGENT, 96, PI, 2.0); } sensor(integer num) { Text = "Total: " + (string)num; for(x = 0; x < num; ++x) Text += "\n" + llDetectedName(x) + " at " + (string)llDetectedPos(x); llSetText(Text, <1,1,1>, 1); } no_sensor() { llSetText("none", <1,1,1>, 1); } }
llSensorRepeat(), when on the ground next to me, detects my avatar constantly, and an avatar 6m away in another sim every few seconds. When attached, it doesn't detect the other avatar at all. Plus, when it did detect the other avatar, it shows the position in region coordinates of the current sim (ie <-3,87,70>  not the coords of the sim they were in, so llVecDist() would give the correct distance. string Text; integer x;
default { state_entry() { llSetTimerEvent(1); } sensor(integer num) { Text = "Total: " + (string)num; for(x = 0; x < num; ++x) Text += "\n" + llDetectedName(x) + " at " + (string)llDetectedPos(x); llSetText(Text, <1,1,1>, 1); } no_sensor() { llSetText("none", <1,1,1>, 1); } timer() { llSensor("", NULL_KEY, AGENT, 96, PI); } }
llSensor, when on the ground, only detect my avatar, never the other across the border. It also never detected the other av across the border when attached. Would you mind posting snippets of your code Haravikk? I'm quite curious now what's going on.
|
Haravikk Mistral
Registered User
Join date: 8 Oct 2005
Posts: 2,482
|
01-01-2006 07:18
Hrm, spoke to soon. It seems as though the errors I was seeing were not just for objects in other sims, but also when I attached the sensor to my HUD, it is actually detecting avatars regardless of their height.
ie, the radius around me that is sensed is 96m, however it's as if it is scanning within a cylinder rather than a sphere, as I have been getting results of up to 900m! I've confirmed this with the co-ordinates that were found, but it's seemingly a random occurrance as I can't reproduce it when I want to. Sometimes these results have been staying in my scans, sometimes they've come up during one 'sweep' then disappeared in the next.
|
Max Case
Registered User
Join date: 23 Dec 2004
Posts: 353
|
01-01-2006 09:07
I have seen what you are describing. Seems to just be AVs who sit on the sim join/borders. Also, they only pop up ~1 out of every 5 scans. I have even picked someone up once who was in a sim kitty corner from the one i was in. Also, I got accurate distance reading to this person (like 200m) returned from the sensor.
|
Lex Neva
wears dorky glasses
Join date: 27 Nov 2004
Posts: 1,361
|
01-01-2006 13:01
Max is exactly right. Sometimes sensors DO return people in other sims, often way out of sensor range, but the coordinates they return give accurate llVecDist() results because they are always relative to the sim you're in. Namely, for someone who's in the sim north of yours, the Y coordinate will be over 256, and coordinates can also go negative for sims west and south.
This seems to happen sporadically if you have a llSensorRepeat going... I don't think it's always exactly every fifth sensor, but it does seem like it can alternate between sensor returns.
|