Created
March 22, 2016 16:00
-
-
Save dunmatt/0dbb4180141500c6bdd0 to your computer and use it in GitHub Desktop.
This is a simple app to demonstrate connecting to the Mass Destruction telemetry stream and parsing the stream format.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.zeromq.ZMQ | |
case class TelemetryDatum(robotId: Int, x: Double, y: Double, theta: Double) {} | |
object TelemetryDatum { | |
def apply(d: String): TelemetryDatum = { | |
val arr = d.trim.split(" ") | |
TelemetryDatum(arr(0).toInt, arr(1).toDouble, arr(2).toDouble, arr(3).toDouble) | |
} | |
} | |
object Main extends App { | |
val context = ZMQ.context(1) | |
val subscriber = context.socket(ZMQ.SUB) | |
subscriber.connect("tcp://172.16.10.214:5555") // TODO: make this a command line parameter | |
subscriber.subscribe(Array.empty[Byte]) | |
(0 until 100).foreach { _ => | |
val raw = new String(subscriber.recv(0)) | |
println(TelemetryDatum(raw)) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment