fr3py调试遇到的一些问题

这是本文档旧的修订版!


fr3py调试遇到的一些问题

问题1:lcm的转发工具 fr3_joint_interface的 Core崩溃问题

fr3_joint_interface 在运行时,支持两种模式:torque 和 velocity 模式;但是这2种模式是互斥的;也就是如果同时运行2个,必然有一个会崩溃。

可能会提示如下错误:

libfranka: Move command rejected: command not possible in the current mode (“User stopped”)!

fr3_joint_interface 不能在【Execution】模式下执行,因为 fr3_joint_interface 内部会通过fci的control去注册数据回调,在 【Execution】模式下,运行 fr3_joint_interface ,FCI会报错,提示模式不允许直接退出。

问题2:使用fr3py 无法在LCM模式下采集数据

fr3_joint_interface 只能在franka的【Programming】模式下执行,此模式可以执行 LCM转发到FCI的任何指令,也能采集到数据。

但是 franka的【Programming】模式下 无法执行示教操作,无法用手引导Pilot 末端执行器做一些操作。此时关节被电击控制,即使按了pilot的按钮,也无法人工操作末端执行器。

所以我们不可以使用LCM模式的情况下,利用fr3py 去采集Pilot的示教数据。

问题3:官方只提供了 gripper.cpp 机制绕过了 LCM模式

官方只提供了 gripper.cpp桥接,可以让python直接调用 libfranka实现数据采集。 而没有提供关节的桥接。 这样可以避开问题2,问题2 里使用control指令受限。

我们编写了joint.cpp 自己绕过libfranka,获取关节数据。

joint.cpp
#include <franka/gripper.h> 
#include <franka/gripper_state.h>
#include <pybind11/pybind11.h>
#include <pybind11/stl.h>
#include <string>
 
namespace py = pybind11;
using namespace pybind11::literals;
 
PYBIND11_MODULE(fr3_gripper, handle)
{
  py::class_<franka::GripperState>(handle, "GripperState")
    .def(py::init<>())
    .def_readwrite("width", &franka::GripperState::width)
    .def_readwrite("max_width", &franka::GripperState::max_width)
    .def_readwrite("is_grasped", &franka::GripperState::is_grasped)
    .def_readwrite("temperature", &franka::GripperState::temperature)
    .def_readwrite("time", &franka::GripperState::time)
    .def("__repr__",
        [](const franka::GripperState &state) {
            return "<GripperState width='" + std::to_string(state.width) + "' max_width='" + std::to_string(state.max_width) + "' is_grasped='" + std::to_string(state.is_grasped) + "' temperature='" + std::to_string(state.temperature) + "' time='" + std::to_string(state.time.toMSec()) + "'>";
        }
    );
 
  py::class_<franka::Gripper>(handle, "Gripper")
    .def(py::init<const std::string&>())
    .def("homing", &franka::Gripper::homing)
    .def("grasp", &franka::Gripper::grasp)
    .def("move", &franka::Gripper::move)
    .def("stop", &franka::Gripper::stop)
    .def("readOnce", [](franka::Gripper &self) -> py::dict {
        franka::GripperState state = self.readOnce();
        return py::dict("width"_a=state.width, "max_width"_a=state.max_width, "is_grasped"_a=state.is_grasped, "temperature"_a=state.temperature, "time (ms)"_a=state.time.toMSec());
    }, "read the gripper state")
    .def("serverVersion", &franka::Gripper::serverVersion);
}
机器人/franka/fr3py/fr3py调试遇到的一些问题.1762255235.txt.gz · 最后更改: 2025/11/04 11:20
CC Attribution 4.0 International 除额外注明的地方外,本维基上的内容按下列许可协议发布: CC Attribution 4.0 International