franka_semantic_components

该软件包包含 franka_robot_model、franka_robot_state 和笛卡尔命令类。这些类用于转换存储在 hardware_state_interface 中的 franka_robot_model 对象和 franka_robot_state 对象(以双指针形式存储)。

有关如何使用这些类的更多参考,请参见:Franka Robot State BroadcasterFranka 示例控制器 (model_example_controller)

笛卡尔位姿接口

该接口用于通过借用的命令接口向机器人发送笛卡尔位姿命令。FrankaSemanticComponentInterface 类负责处理借用的命令接口和状态接口。在启动笛卡尔位姿接口时,用户需要向构造函数传递一个布尔标志,以指示该接口是否用于肘部。

auto is_elbow_active = false;
CartesianPoseInterface cartesian_pose_interface(is_elbow_active);

该接口允许用户读取由 franka 硬件接口设置的当前位姿命令接口值。

std::array<double, 16> pose;
pose = cartesian_pose_interface.getInitialPoseMatrix();

用户还可以以 Eigen 格式读取四元数和位移值。

Eigen::Quaterniond quaternion;
Eigen::Vector3d translation;
std::tie(quaternion, translation) = cartesian_pose_interface.getInitialOrientationAndTranslation();

在设置好笛卡尔接口后,需要在控制器中调用 assign_loaned_command_interfacesassign_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::array<double, 16> pose;
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);

笛卡尔速度接口

该接口用于通过借用的命令接口向机器人发送笛卡尔速度命令。FrankaSemanticComponentInterface 类负责管理这些借用的命令和状态接口。

auto is_elbow_active = false;
CartesianVelocityInterface cartesian_velocity_interface(is_elbow_active);

要向机器人发送速度命令,需要在自定义控制器中调用 assign_loaned_command_interface。

cartesian_velocity_interface.assign_loaned_command_interface(command_interfaces_);

在控制器的 update 函数中,可以向机器人发送笛卡尔速度命令。

std::array<double, 6> cartesian_velocity;
cartesian_velocity = {0, 0, 0, 0, 0, 0.1};
cartesian_velocity_interface.setCommand(cartesian_velocity);

机器人状态与模型访问

语义组件提供对存储在硬件接口中的机器人状态和模型对象的安全访问。这种方式在控制器中使用这些复杂对象时,能够确保正确的类型转换和内存管理。