diff --git a/src/getcoordinates.jl b/src/getcoordinates.jl index 153c4f4a22b42b5c7a97c5477f6a5ace5f6b01fb..3c6e86cba1dc5a4442bdd1517b825fa743fe2624 100644 --- a/src/getcoordinates.jl +++ b/src/getcoordinates.jl @@ -61,6 +61,27 @@ function getz(bot::TCPSocket) end end +""" + gettheta(bot::TCPSocket) + +Returns the ``θ``-coordinate of the omnibot as `Float64`. +""" +function gettheta(bot::TCPSocket) + msg = "rtheta" + print(bot,msg) + ret = readline(bot) + if msg[1] == 'e' + error(ret) + end + try + return parse(Float64,ret) + catch e + if isa(e, ArgumentError) + throw(ArgumentError("Received $ret from the bot, which is not a valid float.")) + end + end +end + """ getmaxspeed(bot::TCPSocket) diff --git a/test/testclient.jl b/test/testclient.jl index bdca29d206b14869352e2a491f39916f32896524..d56fcd7db07367c50f47dd628331a14e08254fed 100644 --- a/test/testclient.jl +++ b/test/testclient.jl @@ -1,14 +1,15 @@ using Omnibot +using Sockets -ip = "192.168.0.101" +ip = getipaddr() bot = connectomnibot(ip) for i = 1:100 setspeed(bot,[100,100,100]) - println("x:"*getx(bot)) - println("y:"*gety(bot)) - println("z:"*getz(bot)) - println("theta:"*gettheta(bot)) + println("x:"*string(getx(bot))) + println("y:"*string(gety(bot))) + println("z:"*string(getz(bot))) + println("theta:"*string(gettheta(bot))) sleep(0.1) end