机械臂与灵巧手驱动已构建完成 #1

Merged
weipengzhe merged 18 commits from feature/2026-9-20 into main 2026-09-20 13:46:34 +08:00
Showing only changes of commit 8b997e1e79 - Show all commits
@@ -150,6 +150,14 @@ bool LBot::connect_robot() {
// 获取机械臂信息
get_robot_info();
bool left_enable_ok = lbot_api.lbot_enable_arm(lbot_handle, LBOT_LEFT_ARM, true);
bool right_enable_ok = lbot_api.lbot_enable_arm(lbot_handle, LBOT_RIGHT_ARM, true);
if (left_enable_ok && right_enable_ok) {
RCLCPP_INFO(this->get_logger(), "Left and right arms enabled successfully");
} else {
RCLCPP_ERROR(this->get_logger(), "Failed to enable arms: %s", lbot_api.lbot_get_last_error(lbot_handle).c_str());
}
// 启动状态监控
if (lbot_api.lbot_start_state_monitor(lbot_state_callback_wrapper, lbot_error_callback_wrapper)) {
is_state_monitor_started_ = true;
@@ -177,6 +185,14 @@ void LBot::disconnect_robot() {
if (conn_state_ == GlobalConnState::DISCONNECTED) return;
RCLCPP_INFO(this->get_logger(), "Disconnecting from LBot...");
bool left_disable_ok = lbot_api.lbot_enable_arm(lbot_handle, LBOT_LEFT_ARM, false);
bool right_disable_ok = lbot_api.lbot_enable_arm(lbot_handle, LBOT_RIGHT_ARM, false);
if (left_disable_ok && right_disable_ok) {
RCLCPP_INFO(this->get_logger(), "Left and right arms disabled successfully");
} else {
RCLCPP_ERROR(this->get_logger(), "Failed to disable arms: %s", lbot_api.lbot_get_last_error(lbot_handle).c_str());
}
// 先设置状态,避免其他线程继续操作
conn_state_ = GlobalConnState::DISCONNECTED;