|
|
|
|
@ -20,27 +20,20 @@ class Proto_msg_to_ros:
|
|
|
|
|
Fly_Formation_topicToMqtt = None
|
|
|
|
|
|
|
|
|
|
#Proto
|
|
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
|
def ros_pub(cls, dataProto):
|
|
|
|
|
if dataProto.topic == cls.Flight_Information_topicToMqtt:
|
|
|
|
|
proto_msg = cls.flight_information_msg.FromString(dataProto.payload)
|
|
|
|
|
def on_message_Flight_Information(cls, client, userdata, msg):
|
|
|
|
|
proto_msg = cls.flight_information_msg.FromString(msg.payload)
|
|
|
|
|
protoTOJson_msg = json_format.MessageToJson(proto_msg, indent=None, preserving_proto_field_name=True, use_integers_for_enums=True)
|
|
|
|
|
cls.publisher_Flight_Information.publish(protoTOJson_msg)
|
|
|
|
|
cls.rate.sleep()
|
|
|
|
|
elif dataProto.topic == cls.Fly_Formation_topicToMqtt:
|
|
|
|
|
proto_msg = cls.fly_formation_msg.FromString(dataProto.payload)
|
|
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
|
def on_message_Fly_Formation(cls, client, userdata, msg):
|
|
|
|
|
proto_msg = cls.fly_formation_msg.FromString(msg.payload)
|
|
|
|
|
# protoTOJson_msg = json_format.MessageToJson(proto_msg, indent=None, preserving_proto_field_name=True)
|
|
|
|
|
protoTOJson_msg = json_format.MessageToJson(proto_msg, indent=None, preserving_proto_field_name=True, use_integers_for_enums=True)
|
|
|
|
|
cls.publisher_Fly_Formation.publish(protoTOJson_msg)
|
|
|
|
|
cls.rate.sleep()
|
|
|
|
|
else:
|
|
|
|
|
print("topic not found")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
|
def on_message(client, userdata, msg):
|
|
|
|
|
Proto_msg_to_ros.ros_pub(msg)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Json_msg_to_ros:
|
|
|
|
|
@ -53,17 +46,11 @@ class Json_msg_to_ros:
|
|
|
|
|
Fly_Formation_topicToMqtt = None
|
|
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
|
def ros_pub(cls, dataJson):
|
|
|
|
|
if dataJson.topic == cls.Flight_Information_topicToMqtt:
|
|
|
|
|
cls.publisher_Flight_Information.publish(dataJson.payload.decode("UTF-8"))
|
|
|
|
|
def on_message_Flight_Information(cls, client, userdata, msg):
|
|
|
|
|
cls.publisher_Flight_Information.publish(msg.payload.decode("UTF-8"))
|
|
|
|
|
cls.rate.sleep()
|
|
|
|
|
elif dataJson.topic == cls.Fly_Formation_topicToMqtt:
|
|
|
|
|
cls.publisher_Fly_Formation.publish(dataJson.payload.decode("UTF-8"))
|
|
|
|
|
cls.rate.sleep()
|
|
|
|
|
else:
|
|
|
|
|
print("topic not found")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
|
def on_message(client, userdata, msg):
|
|
|
|
|
Json_msg_to_ros.ros_pub(msg)
|
|
|
|
|
@classmethod
|
|
|
|
|
def on_message_Fly_Formation(cls, client, userdata, msg):
|
|
|
|
|
cls.publisher_Fly_Formation.publish(msg.payload.decode("UTF-8"))
|
|
|
|
|
cls.rate.sleep()
|