forked from facontidavide/PlotJuggler
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ZMQ: Add topics filtering (facontidavide#730)
- Add ZeroMQ topics support. - Add ZeroMQ publisher in /utilities. - Add requirements.txt
- Loading branch information
Showing
7 changed files
with
168 additions
and
50 deletions.
There are no files selected for viewing
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
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
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
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
56 changes: 56 additions & 0 deletions
56
plotjuggler_plugins/DataStreamZMQ/utilities/start_test_publisher.py
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import zmq | ||
import math | ||
import json | ||
import argparse | ||
|
||
from time import sleep | ||
import numpy as np | ||
|
||
PORT = 9872 | ||
|
||
parser = argparse.ArgumentParser("start_test_publisher") | ||
|
||
parser.add_argument("--topic|-t", | ||
dest="topic", | ||
help="Topic on which messages will be published", | ||
type=str, | ||
required=False) | ||
|
||
args = parser.parse_args() | ||
topic = args.topic | ||
|
||
|
||
def main(): | ||
context = zmq.Context() | ||
server_socket = context.socket(zmq.PUB) | ||
server_socket.bind("tcp://*:" + str(PORT)) | ||
ticks = 0 | ||
|
||
while True: | ||
data = { | ||
"ticks": ticks, | ||
"data": { | ||
"cos": math.cos(ticks), | ||
"sin": math.sin(ticks), | ||
"floor": np.floor(np.cos(ticks)), | ||
"ceil": np.ceil(np.cos(ticks)) | ||
} | ||
} | ||
|
||
if topic: | ||
print(f"[{topic}] - " + json.dumps(data)) | ||
server_socket.send_multipart( | ||
[topic.encode(), json.dumps(data).encode()]) | ||
else: | ||
print(json.dumps(data)) | ||
server_socket.send(json.dumps(data).encode()) | ||
|
||
ticks += 1 | ||
|
||
sleep(0.1) | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
numpy==1.23.2 | ||
pyzmq==23.2.1 | ||
autopep8==1.7.0 |