proto and speed test
This commit is contained in:
@@ -5,13 +5,13 @@ import ssl
|
||||
import rospy
|
||||
from std_msgs.msg import String
|
||||
import paho.mqtt.client as mqtt
|
||||
import json
|
||||
import orjson
|
||||
|
||||
|
||||
# Ros
|
||||
def ros_pub(dataJson):
|
||||
global publisher, rate
|
||||
# data = json.loads(dataJson)
|
||||
# data = orjson.loads(dataJson)
|
||||
publisher.publish(dataJson) #將date字串發布到topic
|
||||
rate.sleep()
|
||||
# print(f"publish data {data}")
|
||||
@@ -25,8 +25,7 @@ def initialise_clients(clientname):
|
||||
|
||||
def on_connect(client, userdata, flags, rc):
|
||||
print("Connected with result code " + str(rc))
|
||||
# client.subscribe(mqtt_config["topic"])
|
||||
client.subscribe("data/pub")
|
||||
client.subscribe(mqtt_config["topic"])
|
||||
|
||||
|
||||
def on_message(client, userdata, msg):
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env python3
|
||||
#coding:utf-8
|
||||
import sys
|
||||
import json
|
||||
import orjson
|
||||
import paho.mqtt.client as mqtt
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ def callBack_gps(GPS):
|
||||
def callBack_rng(RNG):
|
||||
dataRngUpdate = {"range": RNG.range}
|
||||
data.update(dataRngUpdate)
|
||||
dataJsonFormate = json.dumps(data)
|
||||
dataJsonFormate = orjson.dumps(data)
|
||||
# print ('range:'+range+'\n')
|
||||
print (dataJsonFormate)
|
||||
mqtt_Pub(message=dataJsonFormate)
|
||||
|
||||
Reference in New Issue
Block a user