PlotJuggler is a tool to visualize time series that is fast, powerful and intuitive.
The simplest way to install PlotJuggler is through snap:
$ sudo snap install plotjuggler
PlotJuggler
PlotJuggler got several ways of streaming data, it can subscribe to many different streaming sources: MQTT, Websockets, ZeroMQ, UDP, ROS topics, etc.
Here, Websocket and ZeroMQ will be introduced.
PlotJuggler
Start PlotJuggler, go to Streaming, choose ZMQ Subscriber, then Start, default transport Address tcp://localhost with port 9872, and the default message protocol is JSON, click OK.
Python Client
Here is a example of the python client publishing the data:
import zmq
import math
import json
from time import sleep
import numpy as np
context = zmq.Context()
serverSocket = context.socket(zmq.PUB)
port = 9872
serverSocket.bind("tcp://*:"+str(port))
time = 0.0
while True:
sleep(0.05)
time += 0.05
print(time)
data = {
"timestamp": time,
"test_data": {
"cos": math.cos(time),
"sin": math.sin(time),
"floor": np.floor(np.cos(time)),
"ceil": np.ceil(np.cos(time))
}
}
serverSocket.send_string(json.dumps(data))
PlotJuggler
Start PlotJuggler, go to Streaming, choose WebSocket Server, then Start the websocket server, default port is 9871, and protocol is JSON, OK.
Python Client
Here is a simple example of streaming data from a python script to the server through websocket.
import websocket
import math
import json
from time import sleep
import numpy as np
ws = websocket.WebSocket()
ws.connect("ws://localhost:9871")
time = 0.0
while True:
sleep(0.05)
time += 0.05
print(time)
data = {
"timestamp": time,
"test_data": {
"cos": math.cos(time),
"sin": math.sin(time),
"floor": np.floor(np.cos(time)),
"ceil": np.ceil(np.cos(time))
}
}
ws.send(json.dumps(data))