笛卡尔位姿接口
笛卡尔位姿接口
该接口用于通过借用的命令接口向机器人发送笛卡尔位姿命令。FrankaSemanticComponentInterface 类负责处理借用的命令接口和状态接口。在启动笛卡尔位姿接口时,用户需要向构造函数传递一个布尔标志,以指示该接口是否用于肘部。
auto is_elbow_active = false;CartesianPoseInterface cartesian_pose_interface(is_elbow_active);
该接口允许用户读取由 franka 硬件接口设置的当前位姿命令接口值。
std::arraypose; pose = cartesian_pose_interface.getInitialPoseMatrix();
用户还可以以 Eigen 格式读取四元数和位移值。
Eigen::Quaterniond quaternion; Eigen::Vector3d translation; std::tie(quaternion, translation) = cartesian_pose_interface.getInitialOrientationAndTranslation();
在设置好笛卡尔接口后,需要在控制器中调用 assign_loaned_command_interfaces 和 assign_loaned_state_interfaces。这些操作应在控制器的 on_activate() 函数中完成。示例可参见 分配借出的命令接口示例。
cartesian_pose_interface.assign_loaned_command_interfaces(command_interfaces_); cartesian_pose_interface.assign_loaned_state_interfaces(state_interfaces_);
在控制器的 update 函数中,可以向机器人发送位姿命令。
std::arraypose; pose = {1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0.5, 0, 0.5, 1}; cartesian_pose_interface.setCommanded(pose);
或者,可以以 Eigen 格式发送四元数和位移值。
Eigen::Quaterniond quaternion(1, 0, 0, 0); Eigen::Vector3d translation(0.5, 0, 0.5); cartesian_pose_interface.setCommand(quaternion, translation);