删除aubo_arm.cpp中所有的宏

This commit is contained in:
xtkuang 2026-07-03 10:08:12 +08:00
parent 5015077cb5
commit 1c70819993

View File

@ -7,9 +7,7 @@
#include "common/base/logging/logger.h" #include "common/base/logging/logger.h"
#if defined(CMVR_HAS_AUBO_SDK)
#include "aubo_sdk/rpc.h" #include "aubo_sdk/rpc.h"
#endif
namespace cmvr::device { namespace cmvr::device {
namespace { namespace {
@ -40,7 +38,6 @@ std::string vendorBrandName(const config::VendorRobotArmBrand brand)
} }
} }
#if defined(CMVR_HAS_AUBO_SDK)
using arcs::common_interface::RobotModeType; using arcs::common_interface::RobotModeType;
using arcs::aubo_sdk::RobotInterfacePtr; using arcs::aubo_sdk::RobotInterfacePtr;
@ -74,15 +71,12 @@ int waitArrival(const RobotInterfacePtr& robot_interface)
} }
return 0; return 0;
} }
#endif
} // namespace } // namespace
#if defined(CMVR_HAS_AUBO_SDK)
struct AuboArm::SdkState { struct AuboArm::SdkState {
std::shared_ptr<arcs::aubo_sdk::RpcClient> rpc_client; std::shared_ptr<arcs::aubo_sdk::RpcClient> rpc_client;
}; };
#endif
AuboArm::AuboArm(const config::RobotArmConfig& cfg) AuboArm::AuboArm(const config::RobotArmConfig& cfg)
: cfg_(cfg) : cfg_(cfg)
@ -159,7 +153,6 @@ JointGroupState AuboArm::getJointState() const
state.velocity.assign(model_.dof, 0.0); state.velocity.assign(model_.dof, 0.0);
state.effort.assign(model_.dof, 0.0); state.effort.assign(model_.dof, 0.0);
#if defined(CMVR_HAS_AUBO_SDK)
if (!connected_.load() || !sdk_ || !sdk_->rpc_client) { if (!connected_.load() || !sdk_ || !sdk_->rpc_client) {
return state; return state;
} }
@ -188,7 +181,6 @@ JointGroupState AuboArm::getJointState() const
} catch (const std::exception& e) { } catch (const std::exception& e) {
CMVR_LOG(ERROR) << "[AuboArm] getJointState failed: " << e.what(); CMVR_LOG(ERROR) << "[AuboArm] getJointState failed: " << e.what();
} }
#endif
return state; return state;
} }
@ -197,7 +189,6 @@ CartesianPose AuboArm::getTcpPose(FrameType frame) const
(void)frame; (void)frame;
CartesianPose pose; CartesianPose pose;
#if defined(CMVR_HAS_AUBO_SDK)
if (!connected_.load() || !sdk_ || !sdk_->rpc_client) { if (!connected_.load() || !sdk_ || !sdk_->rpc_client) {
return pose; return pose;
} }
@ -224,7 +215,6 @@ CartesianPose AuboArm::getTcpPose(FrameType frame) const
} catch (const std::exception& e) { } catch (const std::exception& e) {
CMVR_LOG(ERROR) << "[AuboArm] getTcpPose failed: " << e.what(); CMVR_LOG(ERROR) << "[AuboArm] getTcpPose failed: " << e.what();
} }
#endif
return pose; return pose;
} }
@ -247,7 +237,6 @@ Result AuboArm::torqueOn()
return ready; return ready;
} }
#if defined(CMVR_HAS_AUBO_SDK)
try { try {
const auto robot_names = sdk_->rpc_client->getRobotNames(); const auto robot_names = sdk_->rpc_client->getRobotNames();
if (robot_names.empty()) { if (robot_names.empty()) {
@ -280,9 +269,6 @@ Result AuboArm::torqueOn()
} catch (const std::exception& e) { } catch (const std::exception& e) {
return Result::failure(ArmErrorCode::CommandFailed, std::string("[AuboArm] torqueOn failed: ") + e.what()); return Result::failure(ArmErrorCode::CommandFailed, std::string("[AuboArm] torqueOn failed: ") + e.what());
} }
#else
return unsupported_("torqueOn");
#endif
} }
Result AuboArm::torqueOff() Result AuboArm::torqueOff()
@ -292,7 +278,6 @@ Result AuboArm::torqueOff()
return ready; return ready;
} }
#if defined(CMVR_HAS_AUBO_SDK)
try { try {
const auto robot_names = sdk_->rpc_client->getRobotNames(); const auto robot_names = sdk_->rpc_client->getRobotNames();
if (robot_names.empty()) { if (robot_names.empty()) {
@ -310,9 +295,6 @@ Result AuboArm::torqueOff()
} catch (const std::exception& e) { } catch (const std::exception& e) {
return Result::failure(ArmErrorCode::CommandFailed, std::string("[AuboArm] torqueOff failed: ") + e.what()); return Result::failure(ArmErrorCode::CommandFailed, std::string("[AuboArm] torqueOff failed: ") + e.what());
} }
#else
return unsupported_("torqueOff");
#endif
} }
Result AuboArm::calibrateZeroQ(const std::string& joint_name) Result AuboArm::calibrateZeroQ(const std::string& joint_name)
@ -351,7 +333,6 @@ Result AuboArm::moveJ(const JointPositionCommand& target, const MotionOptions& o
} }
BusyGuard busy_guard{busy_}; BusyGuard busy_guard{busy_};
#if defined(CMVR_HAS_AUBO_SDK)
try { try {
const auto robot_names = sdk_->rpc_client->getRobotNames(); const auto robot_names = sdk_->rpc_client->getRobotNames();
if (robot_names.empty()) { if (robot_names.empty()) {
@ -375,9 +356,6 @@ Result AuboArm::moveJ(const JointPositionCommand& target, const MotionOptions& o
} catch (const std::exception& e) { } catch (const std::exception& e) {
return Result::failure(ArmErrorCode::CommandFailed, std::string("[AuboArm] moveJ failed: ") + e.what()); return Result::failure(ArmErrorCode::CommandFailed, std::string("[AuboArm] moveJ failed: ") + e.what());
} }
#else
return unsupported_("moveJ");
#endif
} }
Result AuboArm::speedJ(const JointVelocityCommand& velocity, double acceleration, double duration) Result AuboArm::speedJ(const JointVelocityCommand& velocity, double acceleration, double duration)
@ -406,7 +384,6 @@ Result AuboArm::moveL(const CartesianPose& target, const MotionOptions& options,
} }
BusyGuard busy_guard{busy_}; BusyGuard busy_guard{busy_};
#if defined(CMVR_HAS_AUBO_SDK)
try { try {
const auto robot_names = sdk_->rpc_client->getRobotNames(); const auto robot_names = sdk_->rpc_client->getRobotNames();
if (robot_names.empty()) { if (robot_names.empty()) {
@ -433,9 +410,6 @@ Result AuboArm::moveL(const CartesianPose& target, const MotionOptions& options,
} catch (const std::exception& e) { } catch (const std::exception& e) {
return Result::failure(ArmErrorCode::CommandFailed, std::string("[AuboArm] moveL failed: ") + e.what()); return Result::failure(ArmErrorCode::CommandFailed, std::string("[AuboArm] moveL failed: ") + e.what());
} }
#else
return unsupported_("moveL");
#endif
} }
Result AuboArm::speedL(const CartesianVelocity& velocity, double acceleration, double duration, FrameType frame) Result AuboArm::speedL(const CartesianVelocity& velocity, double acceleration, double duration, FrameType frame)
@ -455,7 +429,6 @@ Result AuboArm::stopL(double acceleration)
Result AuboArm::stopMotion() Result AuboArm::stopMotion()
{ {
#if defined(CMVR_HAS_AUBO_SDK)
if (!connected_.load() || !sdk_ || !sdk_->rpc_client) { if (!connected_.load() || !sdk_ || !sdk_->rpc_client) {
return Result::success(); return Result::success();
} }
@ -473,10 +446,6 @@ Result AuboArm::stopMotion()
} catch (const std::exception& e) { } catch (const std::exception& e) {
return Result::failure(ArmErrorCode::CommandFailed, std::string("[AuboArm] stopMotion failed: ") + e.what()); return Result::failure(ArmErrorCode::CommandFailed, std::string("[AuboArm] stopMotion failed: ") + e.what());
} }
#else
busy_.store(false);
return Result::success();
#endif
} }
Result AuboArm::startServoMode(const ServoOptions& options) Result AuboArm::startServoMode(const ServoOptions& options)
@ -525,7 +494,6 @@ Result AuboArm::connect(const std::string& ip, const int port)
return Result::failure(ArmErrorCode::InvalidArgument, "[AuboArm] ip is empty"); return Result::failure(ArmErrorCode::InvalidArgument, "[AuboArm] ip is empty");
} }
#if defined(CMVR_HAS_AUBO_SDK)
try { try {
const int resolved_port = port > 0 ? port : 30004; const int resolved_port = port > 0 ? port : 30004;
auto sdk_state = std::make_unique<SdkState>(); auto sdk_state = std::make_unique<SdkState>();
@ -582,16 +550,10 @@ Result AuboArm::connect(const std::string& ip, const int port)
return Result::failure(ArmErrorCode::ConnectionFailed, return Result::failure(ArmErrorCode::ConnectionFailed,
std::string("[AuboArm] connect failed: ") + e.what()); std::string("[AuboArm] connect failed: ") + e.what());
} }
#else
(void)port;
return Result::failure(ArmErrorCode::UnsupportedCommand,
"[AuboArm] Aubo SDK is not available in this build");
#endif
} }
Result AuboArm::disconnect() Result AuboArm::disconnect()
{ {
#if defined(CMVR_HAS_AUBO_SDK)
try { try {
if (sdk_ && sdk_->rpc_client) { if (sdk_ && sdk_->rpc_client) {
if (sdk_->rpc_client->hasLogined()) { if (sdk_->rpc_client->hasLogined()) {
@ -605,7 +567,6 @@ Result AuboArm::disconnect()
CMVR_LOG(ERROR) << "[AuboArm] disconnect failed: " << e.what(); CMVR_LOG(ERROR) << "[AuboArm] disconnect failed: " << e.what();
} }
sdk_.reset(); sdk_.reset();
#endif
connected_.store(false); connected_.store(false);
busy_.store(false); busy_.store(false);
return Result::success(); return Result::success();
@ -653,15 +614,12 @@ CartesianPose AuboArm::fk(const std::string& base_link, const std::string& ee_li
{ {
(void)base_link; (void)base_link;
(void)ee_link; (void)ee_link;
CMVR_LOG(ERROR) << "[AuboArm] fk(base,ee) is not implemented"; return getTcpPose(FrameType::Base);
return {};
} }
CartesianPose AuboArm::fk(bool is_tcp) CartesianPose AuboArm::fk(bool is_tcp)
{ {
(void)is_tcp; return getTcpPose(is_tcp ? FrameType::Base : FrameType::Tool);
CMVR_LOG(ERROR) << "[AuboArm] fk is not implemented";
return {};
} }
Result AuboArm::unsupported_(const std::string& name) const Result AuboArm::unsupported_(const std::string& name) const
@ -688,12 +646,10 @@ Result AuboArm::ensureConnected_(const std::string& context) const
return Result::failure(ArmErrorCode::NotConnected, return Result::failure(ArmErrorCode::NotConnected,
"[AuboArm] " + context + " failed: arm is not connected"); "[AuboArm] " + context + " failed: arm is not connected");
} }
#if defined(CMVR_HAS_AUBO_SDK)
if (!sdk_ || !sdk_->rpc_client) { if (!sdk_ || !sdk_->rpc_client) {
return Result::failure(ArmErrorCode::NotConnected, return Result::failure(ArmErrorCode::NotConnected,
"[AuboArm] " + context + " failed: SDK client is null"); "[AuboArm] " + context + " failed: SDK client is null");
} }
#endif
return Result::success(); return Result::success();
} }