Treat non-0x10 native states as running only when the error byte is zero, while retaining raw diagnostics and blocking motion on faults. Save zero with CAN 0x19 and validate its offset reply without position readback or automatic reboot. Propagate calibration failures to the arm API. Return shutdown failures without throwing and continue motor/bus cleanup after per-device errors. Keep the three-node Lingkong configuration. Validation: 35 fake-transport protocol tests and 2 motor-manager shutdown tests passed; full make install completed. No physical zero writes or motion tests were performed for these changes. |
||
|---|---|---|
| .vscode | ||
| assets | ||
| cmake | ||
| cmvr-es | ||
| data | ||
| dependency | ||
| docs | ||
| model | ||
| protos | ||
| python | ||
| scripts | ||
| tools | ||
| .aiignore | ||
| .codex | ||
| .gitignore | ||
| .gitmodules | ||
| CMakeLists.txt | ||
| compile_commands.json | ||
| LICENSE | ||
| MUJOCO_LOG.TXT | ||
| README.md | ||
| request.txt | ||
CMVR-ES
简介
CMVR-ES 工程。
机械臂已提供独立的 OMPL RRTConnect 关节路径规划模块。MotorRobotArm::moveP 已接入路径规划、
五次 B 样条平滑、运动限值校验与碰撞复检,并按控制周期下发电机指令。
运行时自碰撞监测位于 cmvr-es/safety/self_collision:SelfCollisionMonitor
通过 RobotArm 接口读取反馈、触发保护停止并协调恢复,碰撞计算仍由
algorithms/collision_detection 中的 CollisionChecker 完成。
SelfCollisionTask 仅绑定机械臂和转发周期调度;Monitor 不创建线程,恢复调用期间
须继续周期检测。现有 self_collision_task 配置格式保持不变。
安装
1. 拉取 Git 子模块
git submodule update --init --recursive
2. 安装系统依赖
# 基础工具
sudo apt-get update
sudo apt install -y build-essential cmake git pkg-config patchelf libboost-all-dev libssl-dev
# OpenCV
sudo apt install -y \
libjpeg-dev libpng-dev libtiff-dev \
libavcodec-dev libavformat-dev libswscale-dev \
libv4l-dev libxvidcore-dev libx264-dev \
libgtk-3-dev
# PulseAudio
sudo apt-get install libpulse-dev
# OpenGL
sudo apt-get install libgl1-mesa-dev
# GLFW
sudo apt-get install libglfw3-dev
# Assimp
sudo apt-get install libassimp-dev
# visp
sudo apt-get install -y libx11-dev liblapack-dev libzbar-dev libpthread-stubs0-dev libdc1394-dev nlohmann-json3-dev
# RealSense
sudo apt-get install -y \
libusb-1.0-0-dev libudev-dev \
libglu1-mesa-dev
# Matplot++
sudo apt install gnuplot-qt
3. 配置 IgH EtherCAT
工程已内置 IgH EtherCAT 1.7.0 的 userspace 文件:
dependency/x86/third_party/ethercat/v1.7.0
当前依赖的源码提交和配套内核版本记录在该目录的 BUILDINFO.txt 中。
目录中保留的其他内核版本模块不代表与当前 userspace 兼容。
先设置本机路径:
export CMVR_ES_ROOT=/path/to/cmvr-es
export IGH_ETHERCAT_ROOT=$CMVR_ES_ROOT/dependency/x86/third_party/ethercat/v1.7.0
安装当前内核的 header:
sudo apt-get update
sudo apt-get install -y linux-headers-$(uname -r)
只有在内置 userspace(libethercat.so、ecrt.h)与 EtherCAT 内核模块来自
同一个源码提交,并且模块对应当前内核版本时,才可以直接安装到系统:
sudo mkdir -p /lib/modules/$(uname -r)/ethercat
sudo cp -r $IGH_ETHERCAT_ROOT/lib/modules/$(uname -r)/ethercat/* /lib/modules/$(uname -r)/ethercat/
sudo depmod
不能只根据 uname -r 和 IgH 1.7.0 版本号判断兼容性。同一个稳定分支的不同
提交也可能使用不同的 ioctl 数据结构,混用后会出现
Failed to create slave config: Inappropriate ioctl for device。如果无法确认 userspace
和内核模块来自同一提交,或者 $IGH_ETHERCAT_ROOT/lib/modules/$(uname -r) 不存在,
需要在这台机器上使用同一份源码重新编译安装 IgH EtherCAT:
sudo apt-get update
sudo apt-get install -y \
build-essential autoconf automake libtool pkg-config git \
linux-headers-$(uname -r)
cd /tmp
git clone --branch stable-1.7 --depth 1 https://gitlab.com/etherlab.org/ethercat.git ethercat-stable-1.7
cd ethercat-stable-1.7
git rev-parse HEAD # 记录本次 userspace 和内核模块共同使用的提交
./bootstrap
./configure \
--prefix=$IGH_ETHERCAT_ROOT \
--libdir=$IGH_ETHERCAT_ROOT/lib \
--includedir=$IGH_ETHERCAT_ROOT/include \
--sysconfdir=$IGH_ETHERCAT_ROOT/etc \
--with-systemdsystemunitdir=$IGH_ETHERCAT_ROOT/lib/systemd/system \
--enable-generic \
--with-linux-dir=/lib/modules/$(uname -r)/build
make -j$(nproc) all modules
make install
sudo make modules_install
sudo depmod
其中,make install 会更新 $IGH_ETHERCAT_ROOT 下的用户态库、头文件和工具,
也会覆盖该目录中的默认配置文件;已有网卡配置应先备份并在安装后恢复。
sudo make modules_install 会更新 /lib/modules/$(uname -r)/ethercat 下的
ec_master.ko、ec_generic.ko 等内核模块。已加载的模块需要通过下方启动脚本
停止并重新加载后才会使用新文件;执行前应退出正在占用主站的应用。
安装完成后,检查用户态库与内核模块中的“创建 slave config” ioctl 编号。
使用 libethercat.so.1 符号链接,避免把实际库文件名固定为旧的 1.2.0:
objdump -d --disassemble=ecrt_master_slave_config "$IGH_ETHERCAT_ROOT/lib/libethercat.so.1" \
| rg -o -m1 '\$0x[cC][0-9a-fA-F]+a423'
objdump -d "/lib/modules/$(uname -r)/ethercat/master/ec_master.ko" \
| rg -o -m1 '\$0x[cC][0-9a-fA-F]+a423'
两条命令的输出必须完全一致。编号不同说明 ABI 不兼容,不能启动 EtherCAT 应用; 编号一致是必要检查,仍需保证用户态和内核模块来自同一源码提交。
启动 EtherCAT。eno1 换成实际连接 EtherCAT 从站的网卡:
sudo scripts/ethercat/start_ethercat.sh eno1
脚本会写入内置 IgH 配置文件:
$IGH_ETHERCAT_ROOT/etc/ethercat.conf
脚本会把该网卡的 MAC 写到 MASTER0_DEVICE,使用 DEVICE_MODULES="generic",把网卡从 NetworkManager 断开,并通过 ethercatctl -c 启动 IgH master。
查看状态:
scripts/ethercat/status_ethercat.sh
$IGH_ETHERCAT_ROOT/bin/ethercat master
$IGH_ETHERCAT_ROOT/bin/ethercat slaves
$IGH_ETHERCAT_ROOT/bin/ethercat pdos
停止 EtherCAT:
sudo scripts/ethercat/stop_ethercat.sh eno1
sudo scripts/ethercat/stop_ethercat.sh eno1 --restore-network
4. 编译并安装
项目脚本统一位于 scripts/,用途见 脚本索引。
在项目根目录执行,不传参数默认使用 Debug,也可显式选择构建类型:
./scripts/build.sh
./scripts/build.sh Debug
./scripts/build.sh Release
./scripts/build.sh RelWithDebInfo
三种类型分别使用 build/Debug、build/Release、build/RelWithDebInfo,
重复执行会增量编译。编译成功后自动安装到 output;编译失败不会执行安装。
日常运行和性能测试建议使用 RelWithDebInfo,保留调试信息并开启优化。
预编译的第三方库直接复用,不会随构建类型重新编译。
默认使用 4 个编译任务,可通过环境变量调整:
CMAKE_BUILD_PARALLEL_LEVEL=2 ./scripts/build.sh RelWithDebInfo
安装会更新 output/bin、output/lib,并用源码目录的配置和模型替换
output/bin/config、output/bin/model;需要保留的配置应修改在源码目录中。