|
|
|
|
@ -27,12 +27,17 @@ def init_dataFormat(cfg:utils.Read_SUB_Config):
|
|
|
|
|
utils.Proto_msg_to_ros.Flight_Information_topicToMqtt = cfg.Flight_Information_topicToMqtt
|
|
|
|
|
utils.Proto_msg_to_ros.Fly_Formation_topicToMqtt = cfg.Fly_Formation_topicToMqtt
|
|
|
|
|
elif cfg.msg_format == "Json":
|
|
|
|
|
# set ros publisher
|
|
|
|
|
utils.Json_msg_to_ros.rate = rospy.Rate(10)
|
|
|
|
|
utils.Json_msg_to_ros.publisher_Flight_Information = rospy.Publisher(cfg.ROStopicName_Flight_Information,String,queue_size=10)
|
|
|
|
|
utils.Json_msg_to_ros.publisher_Fly_Formation = rospy.Publisher(cfg.ROStopicName_Fly_Formation,String,queue_size=10)
|
|
|
|
|
|
|
|
|
|
client.message_callback_add(cfg.Flight_Information_topicToMqtt, utils.Json_msg_to_ros.on_message_Flight_Information)
|
|
|
|
|
utils.Json_msg_to_ros.Drone550_publisher_Flight_Information = rospy.Publisher(cfg.Dron550_ROStopicName_Flight_Information,String,queue_size=10)
|
|
|
|
|
utils.Json_msg_to_ros.Drone380_publisher_Flight_Information = rospy.Publisher(cfg.Dron380_ROStopicName_Flight_Information,String,queue_size=10)
|
|
|
|
|
utils.Json_msg_to_ros.Drone650_publisher_Flight_Information = rospy.Publisher(cfg.Dron650_ROStopicName_Flight_Information,String,queue_size=10)
|
|
|
|
|
# set callback to each topic
|
|
|
|
|
client.message_callback_add(cfg.Fly_Formation_topicToMqtt, utils.Json_msg_to_ros.on_message_Fly_Formation)
|
|
|
|
|
client.message_callback_add(cfg.Drone550_Flight_Information_topicToMqtt, utils.Json_msg_to_ros.Drone550_on_message_Flight_Information)
|
|
|
|
|
client.message_callback_add(cfg.Drone380_Flight_Information_topicToMqtt, utils.Json_msg_to_ros.Drone380_on_message_Flight_Information)
|
|
|
|
|
client.message_callback_add(cfg.Drone650_Flight_Information_topicToMqtt, utils.Json_msg_to_ros.Drone650_on_message_Flight_Information)
|
|
|
|
|
|
|
|
|
|
utils.Json_msg_to_ros.Flight_Information_topicToMqtt = cfg.Flight_Information_topicToMqtt
|
|
|
|
|
utils.Json_msg_to_ros.Fly_Formation_topicToMqtt = cfg.Fly_Formation_topicToMqtt
|
|
|
|
|
@ -42,8 +47,10 @@ def init_dataFormat(cfg:utils.Read_SUB_Config):
|
|
|
|
|
|
|
|
|
|
def on_connect(self, userdata, flags, rc):
|
|
|
|
|
logger.info("Connected with result code " + str(rc))
|
|
|
|
|
client.subscribe(cfg.Flight_Information_topicToMqtt)
|
|
|
|
|
client.subscribe(cfg.Fly_Formation_topicToMqtt)
|
|
|
|
|
client.subscribe(cfg.Drone550_Flight_Information_topicToMqtt)
|
|
|
|
|
client.subscribe(cfg.Drone380_Flight_Information_topicToMqtt)
|
|
|
|
|
client.subscribe(cfg.Drone650_Flight_Information_topicToMqtt)
|
|
|
|
|
|
|
|
|
|
def on_disconnect(client, userdata, rc):
|
|
|
|
|
logger.info("disconnecting reason " +str(rc))
|
|
|
|
|
|