都改用Xmake
This commit is contained in:
1 parent
ec9332826a
commit
d8f1e2226d
21 files changed
+355
-561
No files matched your search
@@ -0,0 +1,71 @@
|
||||
#!/usr/bin/env python3
|
||||
"""冒烟探针:等 Nav2 就绪 → 收几帧过滤后的点云 → 发一个导航目标并等结果。"""
|
||||
import sys
|
||||
import time
|
||||
|
||||
import rclpy
|
||||
from rclpy.node import Node
|
||||
from rclpy.action import ActionClient
|
||||
from rclpy.qos import QoSProfile, ReliabilityPolicy
|
||||
from sensor_msgs.msg import PointCloud2
|
||||
from geometry_msgs.msg import PoseStamped
|
||||
from nav2_msgs.action import NavigateToPose
|
||||
|
||||
rclpy.init()
|
||||
node = Node('smoke_probe')
|
||||
|
||||
got = {'cloud': 0, 'pts': 0, 'minz': None}
|
||||
|
||||
|
||||
def on_cloud(msg):
|
||||
got['cloud'] += 1
|
||||
got['pts'] = msg.width * msg.height
|
||||
|
||||
|
||||
qos = QoSProfile(depth=3, reliability=ReliabilityPolicy.BEST_EFFORT)
|
||||
node.create_subscription(PointCloud2, '/scan/points_filtered', on_cloud, qos)
|
||||
|
||||
AC = ActionClient(node, NavigateToPose, 'navigate_to_pose')
|
||||
print('[probe] 等 navigate_to_pose 动作服务器…')
|
||||
for _ in range(90):
|
||||
if AC.wait_for_server(timeout_sec=2.0):
|
||||
break
|
||||
print('[probe] 还没起来')
|
||||
else:
|
||||
print('[probe] ❌ 动作服务器 180 秒没起来')
|
||||
sys.exit(2)
|
||||
print('[probe] ✅ 动作服务器就绪')
|
||||
|
||||
t0 = time.time()
|
||||
while time.time() - t0 < 25 and got['cloud'] < 3:
|
||||
rclpy.spin_once(node, timeout_sec=0.2)
|
||||
print('[probe] /scan/points_filtered: %d 帧, 最后一帧 %d 点 %s'
|
||||
% (got['cloud'], got['pts'], '✅' if got['cloud'] else '❌ 一帧都没收到'))
|
||||
|
||||
goal = NavigateToPose.Goal()
|
||||
goal.pose = PoseStamped()
|
||||
goal.pose.header.frame_id = 'map'
|
||||
goal.pose.header.stamp = node.get_clock().now().to_msg()
|
||||
goal.pose.pose.position.x = 2.0
|
||||
goal.pose.pose.position.y = 2.0
|
||||
goal.pose.pose.orientation.w = 1.0
|
||||
|
||||
print('[probe] 发导航目标 (2.0, 2.0) …')
|
||||
send = AC.send_goal_async(goal)
|
||||
rclpy.spin_until_future_complete(node, send, timeout_sec=30)
|
||||
handle = send.result()
|
||||
if handle is None or not handle.accepted:
|
||||
print('[probe] ❌ 目标被拒绝')
|
||||
sys.exit(3)
|
||||
print('[probe] 目标已接受,等结果…')
|
||||
|
||||
res = handle.get_result_async()
|
||||
rclpy.spin_until_future_complete(node, res, timeout_sec=240)
|
||||
if not res.done():
|
||||
print('[probe] ❌ 240 秒内没拿到结果')
|
||||
sys.exit(4)
|
||||
status = res.result().status
|
||||
print('[probe] ★ NavigateToPose status = %d (%s)'
|
||||
% (status, 'SUCCEEDED' if status == 4 else '不是 SUCCEEDED'))
|
||||
rclpy.shutdown()
|
||||
sys.exit(0 if status == 4 else 5)
|
||||
Reference in new issue
Block a user