====== libfranka的库的版本适配问题-如何手动编译ubuntu的依赖和ros的依赖 ====== 有一些项目,强制依赖了ROS1,导致使用的是ubuntu20,进而导致 系统默认的so依赖 和Franka的平台不匹配,这里对遇到的问题进行整理。 首先,我们要了解兼容性标准: https://www.franka.cn/FCI/compatibility.html ^ Robot System Version ^ libfranka Version ^ Robot/Gripper Server ^ franka_ros2 Version ^ Ubuntu / ROS 2 ^ franka_ros Version ^ | >= 5.7.2 | >= 0.15.0 | 9 / 3 | >= v1.0.0 | 22.04 / humble | >= 0.10.0 | | >= 5.7.0 | >= 0.14.1 to < 0.15.0 | 8 / 3 | >= v0.1.15 | 22.04 / humble | >= 0.10.0 | | >= 5.5.0 | >= 0.13.3 to < 0.14.1 | 7 / 3 | >= v0.1.15 | 22.04 / humble | >= 0.10.0 | | >= 5.2.0 | >= 0.10.0 to < 0.13.3 | 6 / 3 | >= v0.1.0 to >= v0.1.8 | 22.04 / humble | >= 0.10.0 | 我们可以看到 对于 franka_ros 基本是不挑的,主要集中在 libfranka 的适配上。 而我们遇到的类似的报错,就是这个表格的映射: Failed to initialize libfranka robot. libfranka: Incompatible library version (server version: 8, library version: 5) frank的机器人用的版本是8版本,但是 目前的so库用的5版本。 在 ubuntu20上,直接在ros上 apt install ros-noetic-libfranka ros-noetic-franka-ros 就会是5版本,无法使用,直接报错 ===== ubuntu20 的 libfranka 对应于8版本的编译 ===== 这里我们选用 0.14.2版本编译,比推荐的最低版本稍微高一个版本,而且编译出的是8版本的。 # 下载老的自带的包,确保不会影响,默认的是5版本 sudo apt remove ros-noetic-libfranka ros-noetic-franka-ros # ubuntu20 没有 pinocchio 的包,需要手动安装,而且官网被墙了,只能加速 sudo mkdir -p /etc/apt/keyrings curl http://robotpkg.openrobots.org/packages/debian/robotpkg.asc | sudo tee c echo "deb [arch=amd64 signed-by=/etc/apt/keyrings/robotpkg.asc] https://748996.xyz/robotpkg.openrobots.org/packages/debian/pub focal robotpkg" | sudo tee /etc/apt/sources.list.d/robotpkg.list # 安装必备的编译基础代码 sudo apt install build-essential cmake git libpoco-dev libeigen3-dev libfmt-dev # github被墙了,从指定的加速站点下载,注意分支 fix-0.14.2 不要随便改,因有git 子模块,别的分支可能没处理子模块 cd ~ mkdir gitfranka cd gitfranka git clone --recurse-submodules -b fix-0.14.2 https://gitee.com/caodev/mirror-libfranka libfranka cd libfranka mkdir build && cd build cmake -DCMAKE_BUILD_TYPE=Release .. -DCMAKE_PREFIX_PATH="/opt/openrobots" make -j$(nproc) sudo make install sudo ldconfig ===== ubuntu20的 libfranka_ros相关的编译 ===== 此处比较简单,不是特别困难 # 1. 进入src cd ~/catkin_ws/src # 如果src里没有franka_ros,克隆它(Noetic用noetic-devel分支) git clone https://gitee.com/caodev/mirror_franka_ros franka_ros -b noetic-devel # 2. 安装依赖(跳过libfranka,因为手动装了,不要再下载旧版本) rosdep install --from-paths . --ignore-src -r -y --skip-keys libfranka cd ~/catkin_ws # 2. 删除 build 和 devel 目录。避免之前有污染 rm -rf build/ devel/ # 3. 开始编译,但是特别注意,要使用ROS镜像自带的python3,不要版本太高的python,会报错 catkin_make -DPYTHON_EXECUTABLE=/usr/bin/python3 -DCMAKE_BUILD_TYPE=Release -DFranka_DIR:PATH=~/gitfranka/libfranka/build # 4. 开始生效 source ~/catkin_ws/devel/setup.bash # 5. 测试franka_gripper是否可用 python3 -c "import franka_gripper.msg; print('franka_gripper 成功加载!可以用了')" ===== franka_ros安装报错 empy 相关错误 ===== CMake Error at /opt/ros/noetic/share/catkin/cmake/empy.cmake:30 (message): Unable to find either executable 'empy' or Python module 'em'... try installing the package 'python3-empy' Call Stack (most recent call first): /opt/ros/noetic/share/catkin/cmake/all.cmake:164 (include) /opt/ros/noetic/share/catkin/cmake/catkinConfig.cmake:20 (include) CMakeLists.txt:58 (find_package) 使用系统内置的python3,推荐是3.8的,如果还是没有这个库,pip install empy ; 千万不要激活conda ===== libfranka_ros 提示实时性相关的报错 ===== 提示系统实时补丁没有打开,realtime_config: enforce 直接打开 ~/catkin_ws/src/franka_ros/franka_control/config/franka_control_node.yaml 修改 realtime_config: ignore ===== libfranka_ros编译,提示找不到 libpinocchio_default.so ===== /usr/bin/ld: warning: q.3.4.0, needed by /usr/local/lib/libfranka.so.0.14.1, not found (try using -rpath or -rpath-link) /usr/bin/ld: warning: libpinocchio_default.so.3.4.0, needed by /usr/local/lib/libfranka.so.0.14.1, not found (try using -rpath or -rpath-link) /usr/bin/ld: /usr/local/lib/libfranka.so.0.14.1: undefined reference to `pinocchio::ModelTpl::addJointFr ame(unsigned long const&, int)' /usr/bin/ld: /usr/local/lib/libfranka.so.0.14.1: undefined reference to `pinocchio::ModelTpl::addJoint(u nsigned long, pinocchio::JointModelTpl const&, pinocchio::SE3Tpl const&, std::__cxx11::basic_ string, std::allocator > const&, Eigen::Matrix const&, Eigen::Matrix const&, Eigen::Matrix const&, Eigen::Matrix const&, Eigen::Matrix const&, Eig en::Matrix const&)' 原因,编译libfranka_ros的 确保FRANKA_DIR的正确 catkin_make -DPYTHON_EXECUTABLE=/usr/bin/python3 -DCMAKE_BUILD_TYPE=Release -DFranka_DIR:PATH=~/gitfranka/libfranka/build