try useing thread with each callback
This commit is contained in:
@@ -4,6 +4,7 @@ import time
|
|||||||
import proto.flight_information_pb2 as flight_information_pb2
|
import proto.flight_information_pb2 as flight_information_pb2
|
||||||
import proto.flyformatioln_pb2 as flyformatioln_pb2
|
import proto.flyformatioln_pb2 as flyformatioln_pb2
|
||||||
import google.protobuf.json_format as json_format
|
import google.protobuf.json_format as json_format
|
||||||
|
import threading
|
||||||
|
|
||||||
class Proto_msg_to_ros:
|
class Proto_msg_to_ros:
|
||||||
#Protobuf
|
#Protobuf
|
||||||
@@ -50,15 +51,29 @@ class Json_msg_to_ros:
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def Drone550_on_message_Flight_Information(cls, client, userdata, msg):
|
def Drone550_on_message_Flight_Information(cls, client, userdata, msg):
|
||||||
cls.Drone550_publisher_Flight_Information.publish(msg.payload.decode("UTF-8"))
|
# define a function for handling the data from mqtt
|
||||||
cls.rate.sleep()
|
def thread_function():
|
||||||
|
cls.Drone550_publisher_Flight_Information.publish(msg.payload.decode("UTF-8"))
|
||||||
|
cls.rate.sleep()
|
||||||
|
|
||||||
|
# create a new thread to process the data
|
||||||
|
t = threading.Thread(target=thread_function)
|
||||||
|
t.start()
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def Drone380_on_message_Flight_Information(cls, client, userdata, msg):
|
def Drone380_on_message_Flight_Information(cls, client, userdata, msg):
|
||||||
cls.Drone380_publisher_Flight_Information.publish(msg.payload.decode("UTF-8"))
|
def thread_function():
|
||||||
cls.rate.sleep()
|
cls.Drone380_publisher_Flight_Information.publish(msg.payload.decode("UTF-8"))
|
||||||
|
cls.rate.sleep()
|
||||||
|
|
||||||
|
t = threading.Thread(target=thread_function)
|
||||||
|
t.start()
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def Drone650_on_message_Flight_Information(cls, client, userdata, msg):
|
def Drone650_on_message_Flight_Information(cls, client, userdata, msg):
|
||||||
cls.Drone650_publisher_Flight_Information.publish(msg.payload.decode("UTF-8"))
|
def thread_function():
|
||||||
cls.rate.sleep()
|
cls.Drone650_publisher_Flight_Information.publish(msg.payload.decode("UTF-8"))
|
||||||
|
cls.rate.sleep()
|
||||||
|
|
||||||
|
t = threading.Thread(target=thread_function)
|
||||||
|
t.start()
|
||||||
|
|||||||
Reference in New Issue
Block a user