Files
AutoCalib-Workshop/agv_calib_brain/README.md
T

94 lines
2.6 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 🧠 AGV 标定中央大脑
**环境**: Ubuntu 22.04 + ROS 2 Humble | **语言**: C++ | **通信**: gRPC over Wi-Fi 6
> 标定车间的"发令大脑",通过局域网跨平台遥控 Windows 车端执行动作并拉取遥测数据。
---
## 📋 目录
1. [系统依赖安装](#1-系统依赖一键安装)
2. [VS Code 插件配置](#2-vs-code-核心插件配置)
3. [解决 IntelliSense 报错](#3-解决-vs-code-红色波浪线)
4. [编译与运行](#4-编译与运行)
---
## 1. 系统依赖一键安装
在 Ubuntu 22.04 终端执行以下命令:
```bash
sudo apt update
sudo apt install -y build-essential cmake pkg-config gdb
sudo apt install -y protobuf-compiler-grpc libgrpc++-dev libprotobuf-dev protobuf-compiler
```
> ⚠️ **警告**: 严禁自行去 GitHub 源码编译 gRPC,直接使用 Ubuntu 官方 APT 源即可,避免浪费时间与报错。
---
## 2. VS Code 核心插件配置
打开 VS Code → 扩展商店 (Extensions)**必须安装**以下 4 个插件:
| 插件名称 | 开发者 | 用途 |
|---------|--------|------|
| **C/C++** | Microsoft | 代码补全与 GDB 调试 |
| **CMake Tools** | Microsoft | 底部快速构建状态栏 |
| **ROS** | Microsoft | 自动识别 `colcon` 工作空间 |
| **vscode-proto3** | zxh404 | `.proto` 文件语法高亮 |
---
## 3. 解决 VS Code 红色波浪线 (IntelliSense 报错)
**问题原因**: gRPC 生成的 `.pb.h` 文件在 `colcon build` 阶段动态生成于 `build/` 目录,VS Code 初始无法识别。
**修复步骤**:
1.`Ctrl+Shift+P` → 输入 `C/C++: Edit Configurations (JSON)`
2. 确保 `c_cpp_properties.json` 包含以下配置:
```json
{
"configurations": [
{
"name": "ROS2",
"includePath": [
"${workspaceFolder}/**",
"/opt/ros/humble/include/**",
"${workspaceFolder}/build/agv_calib_brain/grpc_gen/**"
],
"compilerPath": "/usr/bin/gcc",
"cStandard": "c17",
"cppStandard": "c++17",
"intelliSenseMode": "linux-gcc-x64"
}
]
}
```
> 💡 **提示**: `grpc_gen` 是 CMakeLists 中配置的自动生成源码路径,请根据实际情况微调。
---
## 4. 编译与运行 (CMake 自动化)
> ✨ **无需手动执行 `protoc`** —— CMakeLists.txt 已配置自动化脚本,编译时自动生成 C++ 网络源码。
### 4.1 编译
```bash
# 回到工作空间根目录(如 ~/agv_ws)
source /opt/ros/humble/setup.bash
colcon build --packages-select agv_calib_brain --symlink-install
```
### 4.2 运行
```bash
source install/setup.bash
ros2 run agv_calib_brain brain_node
```