|
|
|
@ -59,18 +59,14 @@ class mavlink_publisher():
|
|
|
|
return [qx, qy, qz, qw]
|
|
|
|
return [qx, qy, qz, qw]
|
|
|
|
|
|
|
|
|
|
|
|
def create_attitude(self, sysid, component_obj):
|
|
|
|
def create_attitude(self, sysid, component_obj):
|
|
|
|
# target topic name # 請跟這個 method 的名稱保持一致
|
|
|
|
|
|
|
|
target_topic = 'attitude'
|
|
|
|
target_topic = 'attitude'
|
|
|
|
|
|
|
|
|
|
|
|
# 這邊要檢查 attitude 是否存在
|
|
|
|
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
_ = component_obj.emitParams['attitude']
|
|
|
|
_ = component_obj.emitParams['attitude']
|
|
|
|
except KeyError:
|
|
|
|
except KeyError:
|
|
|
|
# 這個 component id 還不存在
|
|
|
|
|
|
|
|
logger.warning('System ID : {} This Component ID : {} Did not init yet'.format(component_obj['sysid'], component_obj['compid']))
|
|
|
|
logger.warning('System ID : {} This Component ID : {} Did not init yet'.format(component_obj['sysid'], component_obj['compid']))
|
|
|
|
return False
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
|
|
|
# 若存在則 建立 publisher object 並回傳 true
|
|
|
|
|
|
|
|
topic_name = '{}/s{}/{}'.format(self.prefix_path, sysid, target_topic)
|
|
|
|
topic_name = '{}/s{}/{}'.format(self.prefix_path, sysid, target_topic)
|
|
|
|
publisher_ = self.create_publisher(sensor_msgs.msg.Imu, topic_name, 1)
|
|
|
|
publisher_ = self.create_publisher(sensor_msgs.msg.Imu, topic_name, 1)
|
|
|
|
component_obj.publishers[target_topic] = [publisher_, self.packEmit_attitude]
|
|
|
|
component_obj.publishers[target_topic] = [publisher_, self.packEmit_attitude]
|
|
|
|
@ -187,24 +183,6 @@ class mavlink_publisher():
|
|
|
|
publisher.publish(msg)
|
|
|
|
publisher.publish(msg)
|
|
|
|
pass
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
def create_global_hdg(self, sysid, component_obj):
|
|
|
|
|
|
|
|
target_topic = 'global_position/compass_hdg'
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
|
|
|
_ = component_obj.emitParams['global_position']
|
|
|
|
|
|
|
|
except KeyError:
|
|
|
|
|
|
|
|
logger.warning('System ID : {} This Component ID : {} Did not init yet'.format(component_obj['sysid'], component_obj['compid']))
|
|
|
|
|
|
|
|
return False
|
|
|
|
|
|
|
|
topic_name = '{}/s{}/{}'.format(self.prefix_path, sysid, target_topic)
|
|
|
|
|
|
|
|
publisher_ = self.create_publisher(std_msgs.msg.Float64, topic_name, 1)
|
|
|
|
|
|
|
|
component_obj.publishers[target_topic] = [publisher_, self.packEmit_global_hdg]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def packEmit_global_hdg(cls, emitParams, publisher):
|
|
|
|
|
|
|
|
mav_msg = emitParams['global_position']
|
|
|
|
|
|
|
|
msg = std_msgs.msg.Float64()
|
|
|
|
|
|
|
|
msg.data = mav_msg.hdg/1e2
|
|
|
|
|
|
|
|
publisher.publish(msg)
|
|
|
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def create_vfr_hud(self, sysid, component_obj):
|
|
|
|
def create_vfr_hud(self, sysid, component_obj):
|
|
|
|
target_topic = 'vfr_hud'
|
|
|
|
target_topic = 'vfr_hud'
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
@ -245,5 +223,6 @@ class mavlink_publisher():
|
|
|
|
msg.voltage = mav_msg.voltages[0]/1e3
|
|
|
|
msg.voltage = mav_msg.voltages[0]/1e3
|
|
|
|
publisher.publish(msg)
|
|
|
|
publisher.publish(msg)
|
|
|
|
pass
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# ↑↑↑↑↑↑↑↑↑↑↑↑ 處理不同 ros2 topic 訊息 請放在這裡 ↑↑↑↑↑↑↑↑↑↑↑↑
|
|
|
|
# ↑↑↑↑↑↑↑↑↑↑↑↑ 處理不同 ros2 topic 訊息 請放在這裡 ↑↑↑↑↑↑↑↑↑↑↑↑
|