|
|
|
@ -32,6 +32,7 @@ import mavros_msgs.msg
|
|
|
|
|
|
|
|
|
|
|
|
# ROS2 Service imports
|
|
|
|
# ROS2 Service imports
|
|
|
|
import fc_interfaces.srv as fcsrv
|
|
|
|
import fc_interfaces.srv as fcsrv
|
|
|
|
|
|
|
|
import fc_interfaces.msg as fcmsg
|
|
|
|
from .ackEnum import serviceAckResult
|
|
|
|
from .ackEnum import serviceAckResult
|
|
|
|
|
|
|
|
|
|
|
|
# 自定義 imports
|
|
|
|
# 自定義 imports
|
|
|
|
@ -231,7 +232,7 @@ class VehicleStatusPublisher(Node):
|
|
|
|
publisher.publish(msg)
|
|
|
|
publisher.publish(msg)
|
|
|
|
|
|
|
|
|
|
|
|
def _publish_position_ned(self, sysid: int, status: mvv.ComponentStatus):
|
|
|
|
def _publish_position_ned(self, sysid: int, status: mvv.ComponentStatus):
|
|
|
|
"""發布 LOCAL_POSITION_NED(NED 座標,含位置與速度)"""
|
|
|
|
"""發布 LOCAL_POSITION_NED (NED 座標,含位置與速度)"""
|
|
|
|
if not self.rate_controller.should_publish(sysid, 'position_ned'):
|
|
|
|
if not self.rate_controller.should_publish(sysid, 'position_ned'):
|
|
|
|
return
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
|
|
@ -267,34 +268,28 @@ class VehicleStatusPublisher(Node):
|
|
|
|
publisher.publish(msg)
|
|
|
|
publisher.publish(msg)
|
|
|
|
|
|
|
|
|
|
|
|
def _publish_attitude(self, sysid: int, status: mvv.ComponentStatus):
|
|
|
|
def _publish_attitude(self, sysid: int, status: mvv.ComponentStatus):
|
|
|
|
"""發布姿態(IMU)"""
|
|
|
|
"""發布原始姿態(roll/pitch/yaw 與角速度)"""
|
|
|
|
if not self.rate_controller.should_publish(sysid, 'attitude'):
|
|
|
|
if not self.rate_controller.should_publish(sysid, 'attitude'):
|
|
|
|
return
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
|
|
att = status.attitude
|
|
|
|
att = status.attitude
|
|
|
|
if att.roll is None:
|
|
|
|
if att.roll is None or att.pitch is None or att.yaw is None:
|
|
|
|
return
|
|
|
|
return
|
|
|
|
publisher = self._get_or_create_publisher(sysid, 'attitude', sensor_msgs.msg.Imu)
|
|
|
|
publisher = self._get_or_create_publisher(
|
|
|
|
|
|
|
|
sysid, 'attitude', fcmsg.AttitudeRaw
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
if publisher.get_subscription_count() == 0:
|
|
|
|
if publisher.get_subscription_count() == 0:
|
|
|
|
return
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
|
|
msg = sensor_msgs.msg.Imu()
|
|
|
|
msg = fcmsg.AttitudeRaw()
|
|
|
|
|
|
|
|
msg.stamp = self.get_clock().now().to_msg()
|
|
|
|
# 歐拉角轉四元數
|
|
|
|
msg.roll = float(att.roll)
|
|
|
|
qx, qy, qz, qw = self._euler_to_quaternion(
|
|
|
|
msg.pitch = float(att.pitch)
|
|
|
|
att.roll, att.pitch, att.yaw
|
|
|
|
msg.yaw = float(att.yaw)
|
|
|
|
)
|
|
|
|
msg.rollspeed = float(att.rollspeed) if att.rollspeed is not None else 0.0
|
|
|
|
msg.orientation.x = qx
|
|
|
|
msg.pitchspeed = float(att.pitchspeed) if att.pitchspeed is not None else 0.0
|
|
|
|
msg.orientation.y = qy
|
|
|
|
msg.yawspeed = float(att.yawspeed) if att.yawspeed is not None else 0.0
|
|
|
|
msg.orientation.z = qz
|
|
|
|
|
|
|
|
msg.orientation.w = qw
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 角速度
|
|
|
|
|
|
|
|
if att.rollspeed is not None:
|
|
|
|
|
|
|
|
msg.angular_velocity.x = att.rollspeed
|
|
|
|
|
|
|
|
msg.angular_velocity.y = att.pitchspeed
|
|
|
|
|
|
|
|
msg.angular_velocity.z = att.yawspeed
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
publisher.publish(msg)
|
|
|
|
publisher.publish(msg)
|
|
|
|
|
|
|
|
|
|
|
|
@ -1137,7 +1132,8 @@ ros2_manager = fc_ros_manager()
|
|
|
|
2026.04.07
|
|
|
|
2026.04.07
|
|
|
|
1. 完成 ros2 的 MavPositionTargetGlobalInt 區域
|
|
|
|
1. 完成 ros2 的 MavPositionTargetGlobalInt 區域
|
|
|
|
2. 優化 response.ack_result 回傳值的資訊
|
|
|
|
2. 優化 response.ack_result 回傳值的資訊
|
|
|
|
|
|
|
|
3. 新增 _publish_position_ned() 發布剛體座標的訊息
|
|
|
|
|
|
|
|
4. 重製 _publish_attitude() 使其更簡單的去發布姿態訊息
|
|
|
|
|
|
|
|
|
|
|
|
TODO
|
|
|
|
TODO
|
|
|
|
1. service 部分會需要跟 mavlinkobject 大量互動 也許需要考慮對方的生命週期
|
|
|
|
1. service 部分會需要跟 mavlinkobject 大量互動 也許需要考慮對方的生命週期
|
|
|
|
|