都改用Xmake
This commit is contained in:
1 parent
ec9332826a
commit
d8f1e2226d
21 files changed
+355
-561
No files matched your search
@@ -1,66 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# 重新生成工作区根的 compile_commands.json(VS Code / clangd 的智能感知数据源)。
|
||||
#
|
||||
# 做了两件事:
|
||||
# 1. 用 -DCMAKE_EXPORT_COMPILE_COMMANDS=ON 跑一遍 colcon build(增量,很快)
|
||||
# 2. 把 build/<包>/compile_commands.json 合并到工作区根目录
|
||||
#
|
||||
# 什么时候要重跑:新增/重命名了新 .cpp、新增了 C++ 包、改了 CMakeLists 的
|
||||
# include 目录或依赖、换了 ROS 发行版。
|
||||
#
|
||||
# 用法:
|
||||
# tools/gen_compdb.sh # 全部包
|
||||
# tools/gen_compdb.sh sentry_nav # 只处理某个包
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
ROS_SETUP="${ROS_SETUP:-/opt/ros/lyrical/setup.bash}"
|
||||
# 本脚本在 tools/ 下,工作区根是它的父目录。
|
||||
WS_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
|
||||
if [[ ! -f "${ROS_SETUP}" ]]; then
|
||||
echo "找不到 ${ROS_SETUP},请用 ROS_SETUP=/opt/ros/<distro>/setup.bash 指定" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# shellcheck disable=SC1090
|
||||
# ROS 的 setup.bash 里有未定义变量,必须临时关掉 set -u 才能 source。
|
||||
set +u
|
||||
# shellcheck disable=SC1090
|
||||
source "${ROS_SETUP}"
|
||||
set -u
|
||||
cd "${WS_ROOT}"
|
||||
|
||||
# 位置参数 = 包名列表;不给参数就构建整个工作区。
|
||||
if [[ $# -gt 0 ]]; then
|
||||
PACKAGE_ARGS=(--packages-select "$@")
|
||||
else
|
||||
PACKAGE_ARGS=()
|
||||
fi
|
||||
|
||||
colcon build --symlink-install \
|
||||
"${PACKAGE_ARGS[@]}" \
|
||||
--cmake-args -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
|
||||
|
||||
python3 - "${WS_ROOT}" <<'PY'
|
||||
import glob
|
||||
import json
|
||||
import os
|
||||
import sys
|
||||
|
||||
root = sys.argv[1]
|
||||
out = []
|
||||
for path in sorted(glob.glob(os.path.join(root, "build", "*", "compile_commands.json"))):
|
||||
with open(path, encoding="utf-8") as f:
|
||||
entries = json.load(f)
|
||||
print(f"{len(entries):4d} 条 <- {os.path.relpath(path, root)}")
|
||||
out.extend(entries)
|
||||
|
||||
if not out:
|
||||
sys.exit("没有找到任何 compile_commands.json,检查包是否含 C/C++ 源文件")
|
||||
|
||||
with open(os.path.join(root, "compile_commands.json"), "w", encoding="utf-8") as f:
|
||||
json.dump(out, f, indent=2)
|
||||
print(f"合并完成 -> {os.path.join(root, 'compile_commands.json')}({len(out)} 条)")
|
||||
PY
|
||||
+26
-5
@@ -1,9 +1,30 @@
|
||||
#!/usr/bin/env bash
|
||||
# 由 URDF(xacro) 生成 Gazebo 用的静态模型 SDF。
|
||||
# 改了 URDF 之后重跑一次本脚本(launch 用 world 里 include 的 model://sentry)。
|
||||
# 改了 URDF(或换了网格/雷达参数)之后重跑一次本脚本。
|
||||
#
|
||||
# 产物:
|
||||
# src/sentry_sim/models/sentry/model.sdf Gazebo 世界里 include 的 model://sentry
|
||||
# generated/sentry.urdf 本次 xacro 展开的中间结果(留给人看)
|
||||
set -e
|
||||
cd "$(dirname "$0")/.."
|
||||
[ -f install/setup.bash ] && source install/setup.bash || source /opt/ros/lyrical/setup.bash 2>/dev/null || true
|
||||
xacro src/sentry_sim/urdf/sentry.urdf.xacro > /tmp/sentry.urdf
|
||||
gz sdf -p /tmp/sentry.urdf > src/sentry_sim/models/sentry/model.sdf
|
||||
echo "已生成 src/sentry_sim/models/sentry/model.sdf ($(wc -l < src/sentry_sim/models/sentry/model.sdf) 行)"
|
||||
WS="$PWD"
|
||||
|
||||
# 本工程不使用 ament / colcon,xacro 的 `$(find sentry_sim)` 查不到包,
|
||||
# 所以 URDF 里写的是 `$(env SENTRY_SIM_SHARE)`,这里必须先把变量设好。
|
||||
export SENTRY_SIM_SHARE="${SENTRY_SIM_SHARE:-$WS/src/sentry_sim}"
|
||||
|
||||
# xacro 只需要 ROS 的基础环境,不需要工作空间的 install/setup.bash(也没有了)。
|
||||
source /opt/ros/lyrical/setup.bash 2>/dev/null || true
|
||||
|
||||
mkdir -p generated
|
||||
TMP="$(mktemp -d)"
|
||||
trap 'rm -rf "$TMP"' EXIT
|
||||
|
||||
xacro src/sentry_sim/urdf/sentry.urdf.xacro > "$TMP/sentry.urdf"
|
||||
cp "$TMP/sentry.urdf" generated/sentry.urdf
|
||||
gz sdf -p "$TMP/sentry.urdf" > src/sentry_sim/models/sentry/model.sdf
|
||||
|
||||
echo "已生成:"
|
||||
echo " src/sentry_sim/models/sentry/model.sdf ($(wc -l < src/sentry_sim/models/sentry/model.sdf) 行)"
|
||||
echo " generated/sentry.urdf ($(wc -l < generated/sentry.urdf) 行)"
|
||||
echo "网格路径前缀:$SENTRY_SIM_SHARE"
|
||||
@@ -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