16 posts
Posted 30 April 2012 - 02:02 AM
Hi there.
As the title already says, I would want to make a startup script, so a computer automatically configures itself as a GPS Host with given coordinates ( I assign them in the script). Now I already got the computer to start the wireless at startup, but I can't get the GPS thing to load. I hope anybody can help me.
Thanks already.
1604 posts
Posted 30 April 2012 - 02:06 AM
Just add this to the startup file:
shell.run("gps", "x", "y", "z")
replacing the x, y, and z for the corresponding values.
16 posts
Posted 30 April 2012 - 02:21 AM
So many thanks. Just have another problem, how do you get a computer to send the gps data which he git with the GPS locate command to another computer?
65 posts
Location
The Internet
Posted 30 April 2012 - 02:24 AM
If you mean that you placed another computer, types gps locate, and got a single definite position, how to use that? simple type gps host, and it will set you up with the co-ordinates it uses your current GPS network to triangulate.
1111 posts
Location
Portland OR
Posted 30 April 2012 - 02:25 AM
You can use the gps api from within your program so doing this would send out a request for the turtles/computers coordinates to the host and wait 1 second for a reply, and print the results, or error message if it fails.
x, y, z = gps.locate(1)
if x == nil or y == nil or z == nil then
error("Failed to get Coordinates, check GPS Hosts")
else
print (x)
print (y)
print(z)
end
end
16 posts
Posted 30 April 2012 - 02:28 AM
@ luanub
Not directly, the computer/turtle sends his gps coordinates to an other computer with different coordinates and the second computer will print it.
1111 posts
Location
Portland OR
Posted 30 April 2012 - 02:33 AM
You would want to use rednet to send the x,y,z vars to the second computer in a message then have that computer print the message
turtle/computer
rednet.send( id, x.." "..y.." "..z ) -- replace id with the 2nd computer's id
2nd computer
id , msg = rednet.receive()
print ("Computer "..id.." is at "..msg)
should work, I havent tested it though.
Edited on 30 April 2012 - 12:40 AM
16 posts
Posted 30 April 2012 - 02:44 AM
Thanks a lot. I'll test it and report, if there is a bug in the code.
16 posts
Posted 30 April 2012 - 02:55 AM
Sorry to say, but in the first script it tells my attempt to concenatate string and nill, and in the second script it tells me unexpected symbol in line 3.
16 posts
Posted 30 April 2012 - 03:21 AM
I accidently kinda left the lua lines at the top of. Maby that was the problem.
=
16 posts
Posted 30 April 2012 - 03:30 AM
Never minde, it works now.
1111 posts
Location
Portland OR
Posted 30 April 2012 - 03:54 AM
You can do this to filter out the GPS request if your getting clutter from them too
if msg ~= "PING" then
print ("Computer "..id.." is at "..msg.."n")
end
And this to make the message look better:
msg = ("X: "..x.." Y: "..y.." Z: "..z)
rednet.send( id , msg )
Edited on 30 April 2012 - 01:59 AM
16 posts
Posted 30 April 2012 - 04:07 AM
thanks. but what does the n in the first script do?
1111 posts
Location
Portland OR
Posted 30 April 2012 - 04:10 AM
Its a line break. So it will print like
Computer 0 is at x y z
Computer 1 is at x y z
instead of
Computer 0 is at x y z
Computer 1 is at x y z
Just personal preference, if you want to remove it just do ..msg)
16 posts
Posted 30 April 2012 - 04:12 AM
no no. its okay. just wanted to know.
16 posts
Posted 30 April 2012 - 04:23 AM
Now it is perfect. Thanks.
16 posts
Posted 30 April 2012 - 09:29 AM
Just so i can plan my map, how many gps hosts does a turtle/computer use when i execute the gps locate command?
1111 posts
Location
Portland OR
Posted 30 April 2012 - 09:54 AM
I believe it needs at least 3 replies
16 posts
Posted 30 April 2012 - 10:03 AM
Yea, but how many will it use, i have about 6 or so built. Will it use all 6 at the same time for one positioning?
1111 posts
Location
Portland OR
Posted 30 April 2012 - 10:08 AM
If it can reach all 6 it will use all 6. I use 5 and they all respond to each request since the are all in range of my turtles, this helps to ensure that the coordinates are accurate.
16 posts
Posted 30 April 2012 - 10:11 AM
goodi, but why does it then just list 4 of them on the screen?
1111 posts
Location
Portland OR
Posted 30 April 2012 - 10:17 AM
Ya I guess I remembered wrong. It needs 4 of them, and apparently >4 does not matter if its only listing the first 4. It just says you need at least 4 does not mention if >4 is useful or not.
16 posts
Posted 30 April 2012 - 10:21 AM
Still good. Thanks for the help. If I have further questions, I'll tell you.
16 posts
Posted 30 April 2012 - 11:51 AM
Got a question: what is wrong with that code
lua
=
x, y, z = gps.locate(1)
rednet.send( 100, ..x" "..y.." "..z )
It tells me, there is an unexpected symbol in line 3
1111 posts
Location
Portland OR
Posted 30 April 2012 - 12:15 PM
It's due to the lua =
It's trying to assign it x,y,z but then see's the = gps.locate(1) and gets confused. What are you wanting to use the var lua for?
16 posts
Posted 30 April 2012 - 12:26 PM
Oh. I thought the lua must always be there. But it is working now (without the lua). Thanks.