sub all 3 drone
This commit is contained in:
@@ -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.Flight_Information_topicToMqtt = cfg.Flight_Information_topicToMqtt
|
||||||
utils.Proto_msg_to_ros.Fly_Formation_topicToMqtt = cfg.Fly_Formation_topicToMqtt
|
utils.Proto_msg_to_ros.Fly_Formation_topicToMqtt = cfg.Fly_Formation_topicToMqtt
|
||||||
elif cfg.msg_format == "Json":
|
elif cfg.msg_format == "Json":
|
||||||
|
# set ros publisher
|
||||||
utils.Json_msg_to_ros.rate = rospy.Rate(10)
|
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)
|
utils.Json_msg_to_ros.publisher_Fly_Formation = rospy.Publisher(cfg.ROStopicName_Fly_Formation,String,queue_size=10)
|
||||||
|
utils.Json_msg_to_ros.Drone550_publisher_Flight_Information = rospy.Publisher(cfg.Dron550_ROStopicName_Flight_Information,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.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.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.Flight_Information_topicToMqtt = cfg.Flight_Information_topicToMqtt
|
||||||
utils.Json_msg_to_ros.Fly_Formation_topicToMqtt = cfg.Fly_Formation_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):
|
def on_connect(self, userdata, flags, rc):
|
||||||
logger.info("Connected with result code " + str(rc))
|
logger.info("Connected with result code " + str(rc))
|
||||||
client.subscribe(cfg.Flight_Information_topicToMqtt)
|
|
||||||
client.subscribe(cfg.Fly_Formation_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):
|
def on_disconnect(client, userdata, rc):
|
||||||
logger.info("disconnecting reason " +str(rc))
|
logger.info("disconnecting reason " +str(rc))
|
||||||
|
|||||||
@@ -9,13 +9,22 @@ MQTT:
|
|||||||
lwt: Dron550 Gone Offline
|
lwt: Dron550 Gone Offline
|
||||||
willRetain: False
|
willRetain: False
|
||||||
# Mqtt topic
|
# Mqtt topic
|
||||||
Flight_Information_topicToMqtt: Drone550/Flight_Information
|
|
||||||
Fly_Formation_topicToMqtt: Drone550/Formation
|
Fly_Formation_topicToMqtt: Drone550/Formation
|
||||||
|
Drone550_Flight_Information_topicToMqtt: Drone550/Flight_Information
|
||||||
|
|
||||||
|
Drone380_Flight_Information_topicToMqtt: Drone380/Flight_Information
|
||||||
|
|
||||||
|
Drone650_Flight_Information_topicToMqtt: Drone650/Flight_Information
|
||||||
|
|
||||||
# Change formate qos
|
# Change formate qos
|
||||||
Fly_Formation_topicToMqtt_QOS: 2
|
Fly_Formation_topicToMqtt_QOS: 2
|
||||||
ROS:
|
ROS:
|
||||||
ROSClientNameSub: Drone550Sub
|
ROSClientNameSub: Drone550Sub
|
||||||
ROStopicName_Flight_Information: Flight_Information_reciver
|
|
||||||
ROStopicName_Fly_Formation: Fly_Formation_reciver
|
ROStopicName_Fly_Formation: Fly_Formation_reciver
|
||||||
|
Dron550_ROStopicName_Flight_Information: Dron550_Flight_Information_reciver
|
||||||
|
|
||||||
|
Dron380_ROStopicName_Flight_Information: Dron380_Flight_Information_reciver
|
||||||
|
|
||||||
|
Dron650_ROStopicName_Flight_Information: Dron650_Flight_Information_reciver
|
||||||
LOG:
|
LOG:
|
||||||
logFileName: sub.log
|
logFileName: sub.log
|
||||||
|
|||||||
@@ -39,18 +39,31 @@ class Proto_msg_to_ros:
|
|||||||
class Json_msg_to_ros:
|
class Json_msg_to_ros:
|
||||||
rate = None
|
rate = None
|
||||||
#Ros publisher
|
#Ros publisher
|
||||||
publisher_Flight_Information = None
|
|
||||||
publisher_Fly_Formation = None
|
publisher_Fly_Formation = None
|
||||||
|
Drone550_publisher_Flight_Information = None
|
||||||
|
Drone380_publisher_Flight_Information = None
|
||||||
|
Drone650_publisher_Flight_Information = None
|
||||||
#Mqtt topic: check data from which topic
|
#Mqtt topic: check data from which topic
|
||||||
Flight_Information_topicToMqtt = None
|
Flight_Information_topicToMqtt = None
|
||||||
Fly_Formation_topicToMqtt = None
|
Fly_Formation_topicToMqtt = None
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def on_message_Flight_Information(cls, client, userdata, msg):
|
|
||||||
cls.publisher_Flight_Information.publish(msg.payload.decode("UTF-8"))
|
|
||||||
cls.rate.sleep()
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def on_message_Fly_Formation(cls, client, userdata, msg):
|
def on_message_Fly_Formation(cls, client, userdata, msg):
|
||||||
cls.publisher_Fly_Formation.publish(msg.payload.decode("UTF-8"))
|
cls.publisher_Fly_Formation.publish(msg.payload.decode("UTF-8"))
|
||||||
|
cls.rate.sleep()
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def Drone550_on_message_Flight_Information(cls, client, userdata, msg):
|
||||||
|
cls.Drone550_publisher_Flight_Information.publish(msg.payload.decode("UTF-8"))
|
||||||
|
cls.rate.sleep()
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def Drone380_on_message_Flight_Information(cls, client, userdata, msg):
|
||||||
|
cls.Drone380_publisher_Flight_Information.publish(msg.payload.decode("UTF-8"))
|
||||||
|
cls.rate.sleep()
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def Drone650_on_message_Flight_Information(cls, client, userdata, msg):
|
||||||
|
cls.Drone650_publisher_Flight_Information.publish(msg.payload.decode("UTF-8"))
|
||||||
cls.rate.sleep()
|
cls.rate.sleep()
|
||||||
Reference in New Issue
Block a user