Compare commits
2 Commits
29af363b4c
...
553dcc3081
| Author | SHA1 | Date |
|---|---|---|
|
|
553dcc3081 | |
|
|
2f9bcbb8ad |
77
README.md
77
README.md
|
|
@ -22,11 +22,9 @@
|
||||||
### 编译
|
### 编译
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
cd /workspace
|
|
||||||
# pip install -r requirements.txt
|
# pip install -r requirements.txt
|
||||||
|
cd /workspace
|
||||||
colcon build --symlink-install
|
colcon build --symlink-install
|
||||||
source /opt/ros/humble/setup.bash
|
|
||||||
source install/setup.bash
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### 注意事项
|
### 注意事项
|
||||||
|
|
@ -34,65 +32,64 @@ source install/setup.bash
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
source /opt/ros/humble/setup.bash
|
source /opt/ros/humble/setup.bash
|
||||||
source install/setup.bash
|
source /workspace/install/setup.bash
|
||||||
export TURTLEBOT3_MODEL=burger
|
|
||||||
export NAV2_MAP_PATH=/workspace/src/turtlebot3_simulations/turtlebot3_gazebo/map/office_map.yaml
|
export NAV2_MAP_PATH=/workspace/src/turtlebot3_simulations/turtlebot3_gazebo/map/office_map.yaml
|
||||||
```
|
```
|
||||||
|
|
||||||
为了方便,也可以写入 `~/.bashrc`:
|
## 2. 启动仿真(后面每一个步骤都在新终端执行)
|
||||||
|
|
||||||
```bash
|
|
||||||
echo 'source /opt/ros/humble/setup.bash' >> ~/.bashrc
|
|
||||||
echo 'source /workspace/install/setup.bash' >> ~/.bashrc
|
|
||||||
echo 'export TURTLEBOT3_MODEL=burger' >> ~/.bashrc
|
|
||||||
echo 'export NAV2_MAP_PATH=/workspace/src/turtlebot3_simulations/turtlebot3_gazebo/map/office_map.yaml' >> ~/.bashrc
|
|
||||||
source ~/.bashrc
|
|
||||||
```
|
|
||||||
1. 启动仿真, Nav2导航栈, AMCL节点,rviz
|
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
./gzsim_run.sh
|
./gzsim_run.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
## 3. 启动 AMCL节点(负责 “map_server + amcl”)
|
||||||
|
|
||||||
|
```bash
|
||||||
ros2 launch nav2_rrtstar_planner bringup_localization_with_initial_pose.launch.py \
|
ros2 launch nav2_rrtstar_planner bringup_localization_with_initial_pose.launch.py \
|
||||||
use_sim_time:=true \
|
use_sim_time:=true \
|
||||||
map:=$NAV2_MAP_PATH
|
map:=$NAV2_MAP_PATH \
|
||||||
|
params_file:=/workspace/src/TurtleBot-RRT-Star/nav2_params.yaml
|
||||||
|
```
|
||||||
|
|
||||||
|
## 4. 启动 Nav2导航栈(负责 “RRT* 规划器 + controller + bt_navigator)
|
||||||
|
|
||||||
|
```bash
|
||||||
ros2 launch nav2_bringup navigation_launch.py \
|
ros2 launch nav2_bringup navigation_launch.py \
|
||||||
use_sim_time:=True \
|
use_sim_time:=True \
|
||||||
params_file:=/workspace/src/TurtleBot-RRT-Star/nav2_params.yaml \
|
params_file:=/workspace/src/TurtleBot-RRT-Star/nav2_params.yaml
|
||||||
map:=$NAV2_MAP_PATH
|
```
|
||||||
|
|
||||||
|
## 5. 打开rviz
|
||||||
|
|
||||||
|
```bash
|
||||||
export __NV_PRIME_RENDER_OFFLOAD=1
|
export __NV_PRIME_RENDER_OFFLOAD=1
|
||||||
export __GLX_VENDOR_LIBRARY_NAME=nvidia
|
export __GLX_VENDOR_LIBRARY_NAME=nvidia
|
||||||
ros2 run rviz2 rviz2 -d /opt/ros/humble/share/nav2_bringup/rviz/nav2_default_view.rviz --ros-args -p use_sim_time:=true
|
ros2 run rviz2 rviz2 -d /opt/ros/humble/share/nav2_bringup/rviz/nav2_default_view.rviz --ros-args -p use_sim_time:=true
|
||||||
|
|
||||||
```
|
```
|
||||||
2. 新开终端,执行环境生效后启动vlm_perception_pkg的语义检测节点,开始目标语义标注并构建语义记忆库,在机器人导航过程中,节点实时检测环境中的目标并生成语义标注结果,保存JSON 格式的语义记忆库到指定路径。
|
|
||||||
|
新开终端,执行环境生效后启动vlm_perception_pkg的语义检测节点,开始目标语义标注并构建语义记忆库,在机器人导航过程中,节点实时检测环境中的目标并生成语义标注结果,保存JSON 格式的语义记忆库到指定路径。
|
||||||
|
## 6. 启动目标检测节点
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
ros2 run vlm_perception_pkg vlm_detection --ros-args -p use_sim_time:=true
|
ros2 run vlm_perception_pkg vlm_detection --ros-args -p use_sim_time:=true
|
||||||
# 默认:启动时加载历史 JSON(同一个语义记忆库文件)
|
# 默认:启动时加载历史 JSON(同一个语义记忆库文件)可选:启动时重置语义记忆库,避免历史最高分长期不更新
|
||||||
# 可选:启动时重置语义记忆库,避免历史最高分长期不更新
|
|
||||||
# ros2 run vlm_perception_pkg vlm_detection --ros-args -p use_sim_time:=true -p reset_records_on_startup:=true
|
# ros2 run vlm_perception_pkg vlm_detection --ros-args -p use_sim_time:=true -p reset_records_on_startup:=true
|
||||||
```
|
```
|
||||||
3. 加载生成的语义记忆库文件(in /workspace/src/vlm_nav_pkg/config),通过 CLIP 将语义标签编码为shared embedding space,当用户输入自然语言查询时,系统匹配最接近的已知目标,提取其坐标并发送至 Nav2,实现基于自然语言的语义导航。以下是验证步骤:
|
### 导航建议
|
||||||
4. 重新启动仿真, Nav2导航栈, AMCL节点,rviz
|
- TurtleBot3 机身较矮,相机视角较低,高目标物体适合较远距离观测。
|
||||||
|
- 建议在机器人低速或短暂停止时运行检测,以提高 RGB-D 与 TF 的稳定性。
|
||||||
|
- 建议目标距离相机约 1~3 米,可以多角度对目标进行观察。
|
||||||
|
- 本项目保存的是“最高分对应的目标坐标”,适合用于导航到目标附近,不保证是物体几何中心。
|
||||||
|
|
||||||
|
|
||||||
|
检测完成后可查看目标标注结果(in /workspace/src/vlm_nav_pkg/config,带时间戳),加载生成的语义记忆库文件,通过 CLIP 将语义标签编码为shared embedding space,当用户输入自然语言查询时,系统匹配最接近的已知目标,提取其坐标并发送至 Nav2,实现基于自然语言的语义导航。
|
||||||
|
## 7. 启动目标检测节点
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
# 关闭检测节点后
|
||||||
./gzsim_run.sh
|
# pip3 install "numpy<2"
|
||||||
|
|
||||||
ros2 launch nav2_rrtstar_planner bringup_localization_with_initial_pose.launch.py \
|
|
||||||
use_sim_time:=true \
|
|
||||||
map:=$NAV2_MAP_PATH
|
|
||||||
|
|
||||||
ros2 launch nav2_bringup navigation_launch.py \
|
|
||||||
use_sim_time:=True \
|
|
||||||
params_file:=/workspace/src/TurtleBot-RRT-Star/nav2_params.yaml \
|
|
||||||
map:=$NAV2_MAP_PATH
|
|
||||||
|
|
||||||
ros2 run rviz2 rviz2 -d /opt/ros/humble/share/nav2_bringup/rviz/nav2_default_view.rviz --ros-args -p use_sim_time:=true
|
|
||||||
|
|
||||||
pip3 install "numpy<2"
|
|
||||||
ros2 run vlm_nav_pkg semantic_nav
|
ros2 run vlm_nav_pkg semantic_nav
|
||||||
```
|
```
|
||||||
|
|
||||||
节点启动后,在终端输入自然语言语义目标(如 “water dispenser”“sofa”),系统将自动完成:语义查询与shared embedding space匹配,提取目标对应的地图坐标并向 Nav2 发送导航目标位姿,然后机器人自主规划路径并导航至语义目标位置,RViz2 中实时可视化规划路径与导航过程
|
节点启动后,在终端输入自然语言语义目标(如 “water dispenser”“sofa”),系统将自动完成:语义查询与shared embedding space匹配,提取目标对应的地图坐标并向 Nav2 发送导航目标位姿,然后机器人自主规划路径并导航至语义目标位置,RViz2 中实时可视化规划路径与导航过程。当前导航会默认在目标周围生成多个候选接近点,并优先选择距离当前机器人最近的可行点,避免直接撞向物体中心点。候选点会先经过 `/map` 自由空间筛选,再逐个试算全局路径,只在“有路径”的候选点里选最优目标。
|
||||||
|

|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 230 KiB After Width: | Height: | Size: 377 KiB |
|
|
@ -79,10 +79,6 @@ install(DIRECTORY launch/
|
||||||
DESTINATION share/${PROJECT_NAME}/launch
|
DESTINATION share/${PROJECT_NAME}/launch
|
||||||
)
|
)
|
||||||
|
|
||||||
install(DIRECTORY scripts/
|
|
||||||
DESTINATION share/${PROJECT_NAME}/scripts
|
|
||||||
)
|
|
||||||
|
|
||||||
if(BUILD_TESTING)
|
if(BUILD_TESTING)
|
||||||
find_package(ament_lint_auto REQUIRED)
|
find_package(ament_lint_auto REQUIRED)
|
||||||
ament_lint_auto_find_test_dependencies()
|
ament_lint_auto_find_test_dependencies()
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"Refrigerator": {
|
"Refrigerator": {
|
||||||
"highest_score": 0.301513671875,
|
"highest_score": 0.271240234375,
|
||||||
"last_detected": "2026-05-18T14:13:25.085735",
|
"last_detected": "2026-05-18T10:25:26.258502",
|
||||||
"position": {
|
"position": {
|
||||||
"x": -1.3181,
|
"x": -1.3181,
|
||||||
"y": 0.5165,
|
"y": 0.5165,
|
||||||
|
|
@ -9,39 +9,39 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"water dispenser": {
|
"water dispenser": {
|
||||||
"highest_score": 0.316162109375,
|
"highest_score": 0.31689453125,
|
||||||
"last_detected": "2026-05-18T14:15:56.440127",
|
"last_detected": "2026-05-18T10:26:11.990891",
|
||||||
"position": {
|
"position": {
|
||||||
"x": -1.6292,
|
"x": -1.4587,
|
||||||
"y": -1.7906,
|
"y": -1.8551,
|
||||||
"z": 0.661
|
"z": 0.6153
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"sofa": {
|
"sofa": {
|
||||||
"highest_score": 0.307861328125,
|
"highest_score": 0.311767578125,
|
||||||
"last_detected": "2026-05-18T14:17:27.585956",
|
"last_detected": "2026-05-18T10:26:51.065460",
|
||||||
"position": {
|
"position": {
|
||||||
"x": 1.4535,
|
"x": 1.6362,
|
||||||
"y": -0.4709,
|
"y": 0.2425,
|
||||||
"z": 0.5445
|
"z": 0.4759
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"white toilet": {
|
"white toilet": {
|
||||||
"highest_score": 0.269287109375,
|
"highest_score": 0.2568359375,
|
||||||
"last_detected": "2026-05-18T14:13:07.308074",
|
"last_detected": "2026-05-18T10:25:18.120319",
|
||||||
"position": {
|
"position": {
|
||||||
"x": -4.3598,
|
"x": -4.4027,
|
||||||
"y": -1.1593,
|
"y": -1.2225,
|
||||||
"z": 0.3363
|
"z": 0.1715
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"office chair with wheels": {
|
"office chair with wheels": {
|
||||||
"highest_score": 0.3037109375,
|
"highest_score": 0.302734375,
|
||||||
"last_detected": "2026-05-18T14:12:39.416197",
|
"last_detected": "2026-05-18T10:26:35.889506",
|
||||||
"position": {
|
"position": {
|
||||||
"x": -2.8461,
|
"x": -2.9779,
|
||||||
"y": 2.6732,
|
"y": 2.3836,
|
||||||
"z": 0.4811
|
"z": 0.4007
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -55,7 +55,12 @@ class ClipDetectionNode(Node):
|
||||||
|
|
||||||
# CLIP + Faster R-CNN
|
# CLIP + Faster R-CNN
|
||||||
self.clip_model, self.clip_preprocess = clip.load("ViT-B/32", device=self.device)
|
self.clip_model, self.clip_preprocess = clip.load("ViT-B/32", device=self.device)
|
||||||
self.frcnn_model = torchvision.models.detection.fasterrcnn_resnet50_fpn_v2(weights="DEFAULT").eval()
|
self.frcnn_model = torchvision.models.detection.fasterrcnn_resnet50_fpn_v2(
|
||||||
|
weights="DEFAULT"
|
||||||
|
).to(self.device).eval()
|
||||||
|
self.get_logger().info(
|
||||||
|
f"Detection models initialized on device={self.device}"
|
||||||
|
)
|
||||||
|
|
||||||
# Labels and score tracking
|
# Labels and score tracking
|
||||||
self.labels = ["Refrigerator","water dispenser", "sofa", "white toilet", "office chair with wheels"]
|
self.labels = ["Refrigerator","water dispenser", "sofa", "white toilet", "office chair with wheels"]
|
||||||
|
|
@ -208,7 +213,7 @@ class ClipDetectionNode(Node):
|
||||||
depth_img = self.latest_depth.copy()
|
depth_img = self.latest_depth.copy()
|
||||||
frame_stamp = self.latest_depth_stamp
|
frame_stamp = self.latest_depth_stamp
|
||||||
camera_info = self.camera_info
|
camera_info = self.camera_info
|
||||||
image_tensor = transforms.ToTensor()(cv_img)
|
image_tensor = transforms.ToTensor()(cv_img).to(self.device)
|
||||||
frcnn_min_score = self.get_parameter(
|
frcnn_min_score = self.get_parameter(
|
||||||
'frcnn_min_score'
|
'frcnn_min_score'
|
||||||
).get_parameter_value().double_value
|
).get_parameter_value().double_value
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue