初始化:RMUL 2027 哨兵导航仿真工程

- Gazebo Sim (Jetty 10.6) + ROS 2 Lyrical + Nav2 全栈
- 整车模型:URDF/SDF + 减面网格(SolidWorks 装配体实测尺寸)
- 场地:RMUL 2027 官方包(2D 栅格地图 + 3D 场地模型),放在 field/
- sentry_nav C++ 包:self_filter 点云自滤 / patrol 航点巡逻
- 文档:README(含本机开发环境实测)、MID-360 接入说明

已排除:build/ install/ log/ 缓存目录,以及 115 MB 的原始高模
(仿真实际用的是 meshes/base.stl 减面版,约 25.7 万面)
This commit is contained in:
mzx committed 2026-11-14 21:18:04 +08:00
1 parent ed31ccc39f
commit f7412ec369
142 files changed
+58958 -2

No files matched your search

+63
View File
@@ -0,0 +1,63 @@
#!/usr/bin/env python3
"""用 Nav2 的 NavigateToPose 动作发目标,打印反馈与结果,并检查 TF。"""
import sys
import time
import rclpy
from nav2_msgs.action import NavigateToPose
from rclpy.action import ActionClient
from rclpy.node import Node
from tf2_ros import Buffer, TransformListener
gx = float(sys.argv[1]) if len(sys.argv) > 1 else 2.0
gy = float(sys.argv[2]) if len(sys.argv) > 2 else 2.0
rclpy.init()
node = Node('nav_client')
tf_buffer = Buffer()
TransformListener(tf_buffer, node)
client = ActionClient(node, NavigateToPose, 'navigate_to_pose')
print('等待 navigate_to_pose 动作服务器...')
if not client.wait_for_server(timeout_sec=30):
print('❌ 动作服务器不可用')
raise SystemExit(1)
print('✅ 动作服务器可用')
goal = NavigateToPose.Goal()
goal.pose.header.frame_id = 'map'
goal.pose.header.stamp = node.get_clock().now().to_msg()
goal.pose.pose.position.x = gx
goal.pose.pose.position.y = gy
goal.pose.pose.orientation.w = 1.0
sent = client.send_goal_async(goal, feedback_callback=lambda fb: print(
f' 反馈: 剩余 {fb.feedback.distance_remaining:.2f} m'))
rclpy.spin_until_future_complete(node, sent, timeout_sec=15)
handle = sent.result()
if handle is None or not handle.accepted:
print('❌ 目标被拒绝')
raise SystemExit(1)
print('✅ 目标已接受,等待结果...')
res = handle.get_result_async()
t0 = time.time()
while not res.done() and time.time() - t0 < 120:
rclpy.spin_once(node, timeout_sec=0.2)
if res.done():
status = res.result().status
names = {4: '✅ SUCCEEDED', 5: '❌ CANCELED', 6: '❌ ABORTED'}
print(f'结果: {names.get(status, status)}')
else:
print('超时未完成')
try:
tr = tf_buffer.lookup_transform('map', 'base_link', rclpy.time.Time())
p = tr.transform.translation
print(f'TF map->base_link: x={p.x:.2f} y={p.y:.2f}')
except Exception as exc: # noqa: BLE001
print(f'⚠️ 查不到 TF map->base_link: {exc}')
node.destroy_node()
rclpy.shutdown()