|
|
|
@ -23,10 +23,13 @@ from geometry_msgs.msg import Vector3
|
|
|
|
def init_dataFormat(cfg:Read_PUB_Config):
|
|
|
|
def init_dataFormat(cfg:Read_PUB_Config):
|
|
|
|
Proto_msg_from_ros.sel = serial.Serial(cfg.ttyport, cfg.baudrate, serial.EIGHTBITS, serial.PARITY_NONE, serial.STOPBITS_ONE)
|
|
|
|
Proto_msg_from_ros.sel = serial.Serial(cfg.ttyport, cfg.baudrate, serial.EIGHTBITS, serial.PARITY_NONE, serial.STOPBITS_ONE)
|
|
|
|
Proto_msg_from_ros.flight_information_msg = flight_information_pb2.flight_information_message()
|
|
|
|
Proto_msg_from_ros.flight_information_msg = flight_information_pb2.flight_information_message()
|
|
|
|
Proto_msg_from_ros.rate = rospy.Rate(10)
|
|
|
|
Proto_msg_from_ros.rate = rospy.Rate(5)
|
|
|
|
rospy.Subscriber('/mavros/global_position/global', NavSatFix, Proto_msg_from_ros.callBack_gps)
|
|
|
|
rospy.Subscriber('/mavros/global_position/global', NavSatFix, Proto_msg_from_ros.callBack_gps)
|
|
|
|
rospy.Subscriber('/mavros/global_position/compass_hdg', Float64, Proto_msg_from_ros.callBack_compass_hdg)
|
|
|
|
rospy.Subscriber('/mavros/global_position/compass_hdg', Float64, Proto_msg_from_ros.callBack_compass_hdg)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def shutdown_callback():
|
|
|
|
|
|
|
|
Proto_msg_from_ros.turnOffUavlink()
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
if __name__ == '__main__':
|
|
|
|
FilePath = os.path.join(os.path.dirname(__file__),"utils","uavlinkConfig_PUB.yml")
|
|
|
|
FilePath = os.path.join(os.path.dirname(__file__),"utils","uavlinkConfig_PUB.yml")
|
|
|
|
cfg = Read_PUB_Config(FilePath)
|
|
|
|
cfg = Read_PUB_Config(FilePath)
|
|
|
|
@ -44,7 +47,7 @@ if __name__ == '__main__':
|
|
|
|
|
|
|
|
|
|
|
|
file_handler = logging.FileHandler(cfg.logFileName, mode='w')
|
|
|
|
file_handler = logging.FileHandler(cfg.logFileName, mode='w')
|
|
|
|
file_handler.setFormatter(file_formatter)
|
|
|
|
file_handler.setFormatter(file_formatter)
|
|
|
|
file_handler.setLevel(logging.INFO)
|
|
|
|
file_handler.setLevel(logging.DEBUG)
|
|
|
|
|
|
|
|
|
|
|
|
logger = logging.getLogger("__UAVLINKSUBPUB__")
|
|
|
|
logger = logging.getLogger("__UAVLINKSUBPUB__")
|
|
|
|
logger.setLevel(logging.DEBUG)
|
|
|
|
logger.setLevel(logging.DEBUG)
|
|
|
|
@ -55,15 +58,16 @@ if __name__ == '__main__':
|
|
|
|
# Ros
|
|
|
|
# Ros
|
|
|
|
rosClient = cfg.ROSClientNamePub
|
|
|
|
rosClient = cfg.ROSClientNamePub
|
|
|
|
rospy.init_node(rosClient)
|
|
|
|
rospy.init_node(rosClient)
|
|
|
|
|
|
|
|
rospy.on_shutdown(shutdown_callback)
|
|
|
|
|
|
|
|
|
|
|
|
# init data format
|
|
|
|
# init data format
|
|
|
|
init_dataFormat(cfg)
|
|
|
|
init_dataFormat(cfg)
|
|
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
rospy.spin()
|
|
|
|
rospy.spin()
|
|
|
|
except KeyboardInterrupt as e:
|
|
|
|
except rospy.ROSInterruptException as e:
|
|
|
|
Proto_msg_from_ros.turnOffUavlink()
|
|
|
|
Proto_msg_from_ros.turnOffUavlink()
|
|
|
|
print("End of program")
|
|
|
|
logger.debug("End of program")
|
|
|
|
sys.exit()
|
|
|
|
sys.exit()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|