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

GPS return nil value at some coordinate #1530

Closed
kulapa2000 opened this issue Jul 21, 2023 · 6 comments
Closed

GPS return nil value at some coordinate #1530

kulapa2000 opened this issue Jul 21, 2023 · 6 comments
Labels
area-CraftOS This affects CraftOS, or any other Lua portions of the mod. bug A problem or unexpected behaviour with the mod. wontfix A bug which I won't fix or an enhancement which won't be implemented.

Comments

@kulapa2000
Copy link

Minecraft Version

1.18.x

Version

1.101.2

Details

2023-07-21_20 56 00

I was using the ender modem to get the gps coordinates, and as the screenshot shows, gps works normally at (1437,8,1148) but it returns nil after it went one step forward, which is at (1437,8,1149)

@kulapa2000 kulapa2000 added the bug A problem or unexpected behaviour with the mod. label Jul 21, 2023
@SquidDev SquidDev added the area-CraftOS This affects CraftOS, or any other Lua portions of the mod. label Jul 21, 2023
@SquidDev
Copy link
Member

Thank you for the report! Just a couple of questions:

  • What are the positions of your GPS hosts? Just so I can attempt to reproduce this locally!
  • Could you run gps.locate(2, true) as well, and screenshot the result - this should include some additional debugging information, which will help explain why it cannot find the position.

@kulapa2000
Copy link
Author

I was using it on a forge server, but when i log into the server today, gps works normally at that coordinate. But please don't close this issue for now, because this bug has showed up for a several times, I will follow up next time it shows up.

@SquidDev SquidDev added the cannot reproduce I'm unable to reproduce this bug. label Jul 22, 2023
@kulapa2000
Copy link
Author

I got a new error coordinate this time.
The gps return a nil value at (1411,70,100)

The host position are as follows:
(1557,69,948)
(1557,69,953)
(1562,69,948)
(1557,73,948)

And when I run the gps.locate(2,true) it says ambiguous position
image

@SquidDev SquidDev added wontfix A bug which I won't fix or an enhancement which won't be implemented. and removed cannot reproduce I'm unable to reproduce this bug. labels Jul 30, 2023
@SquidDev
Copy link
Member

Thank you, that's very helpful!

The problem here is that you're very far away from your GPS array, which causes accuracy to suffer. In this particular case, we can't disambiguate on the y axis between $y = 68$ and $y = 70$. If we compare the distances to the GPS host at $(1557, 73, 948)$, we can see why:

$$ \begin{align} \text{distance}(y = 68) &= \sqrt{146^2 + 5^2 + 848^2} \approx 860.492 \\ \text{distance}(y = 70) &= \sqrt{146^2 + 3^2 + 848^2} \approx 860.483 \\ \end{align} $$

Because the two distances are less than 0.01 away from each other, the GPS library decides that's not accurate enough to guarantee the correct position.

The easiest fix here is just to move the GPS hosts further apart. Just shifting the top computer up a few more blocks should help here!

If you're trying to serve a massive area, I normally put my GPS hosts in the corners of a chunk, with 14 blocks between them. So something like this:

A screenshot of a sandstone superflat Minecraft world, with four computers on it. The chunk borders are visible, and we can see three computers are in three corners of the chunk (on a plane) and one computer is high above the others.

@Lupus590
Copy link
Contributor

Hmm, maybe we should add this as a note on the GPS documentation as a long-range setup. I think we should mention the accuracy issue and its symptoms too.

@SquidDev
Copy link
Member

Yeah, that's probably not a bad idea.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-CraftOS This affects CraftOS, or any other Lua portions of the mod. bug A problem or unexpected behaviour with the mod. wontfix A bug which I won't fix or an enhancement which won't be implemented.
Projects
None yet
Development

No branches or pull requests

3 participants