feat(arm): expose joint position limits in GetArmInfo

This commit is contained in:
linbo 2026-11-09 13:44:29 +08:00
parent 392281fe06
commit 89091dc435
4 changed files with 35 additions and 0 deletions

View File

@ -859,6 +859,21 @@ RobotModel AuboArm::queryRobotModel() const
result.joint_names = defaultJointNames(result.dof);
}
result.detected_from_sdk = true;
// Never reuse configured/URDF limits as controller readback for this snapshot.
result.joint_limits.clear();result.joint_limits_source="unavailable";
try {
const auto lower=config->getJointMinPositions();
const auto upper=config->getJointMaxPositions();
if(lower.size()==result.dof && upper.size()==result.dof){
result.joint_limits.resize(result.dof);
for(std::size_t i=0;i<result.dof;++i){
result.joint_limits[i].lower=lower[i];result.joint_limits[i].upper=upper[i];
}
result.joint_limits_source="aubo_sdk";
}
}catch(const std::exception& e){
CMVR_LOG(WARNING)<<"[AuboArm] GetArmInfo position limits unavailable: "<<e.what();
}
return result;
#else
throw std::runtime_error("[AuboArm] GetArmInfo requires the AUBO SDK");

View File

@ -52,6 +52,7 @@ struct RobotModel {
std::size_t dof{0};
std::vector<std::string> joint_names;
std::vector<JointLimit> joint_limits;
std::string joint_limits_source;
double max_tcp_speed{0.0};
double max_tcp_acceleration{0.0};
double max_payload{0.0};

View File

@ -3,6 +3,7 @@
#include "devices/arm/aubo_arm/include/user_coordinate_store.h"
#include <google/protobuf/util/time_util.h>
#include <cmath>
#include "common/base/logging/logger.h"
#include "service/grpc/action/include/control_command_arbiter.h"
@ -603,6 +604,14 @@ grpc::Status gRPCArmServiceImpl::GetArmInfo(grpc::ServerContext*,
response->set_description_id(model.description_id);
response->set_detected_from_sdk(model.detected_from_sdk);
response->set_driver_type(arm->typeName());
for(std::size_t i=0;i<model.joint_names.size();++i){
auto* limit=response->add_joint_limits();limit->set_joint_name(model.joint_names[i]);
limit->set_source(model.joint_limits_source.empty()?"driver_model":model.joint_limits_source);
if(model.joint_limits.size()!=model.joint_names.size())continue;
const auto& value=model.joint_limits[i];
if(!std::isfinite(value.lower)||!std::isfinite(value.upper)||value.lower>=value.upper)continue;
limit->set_position_limits_available(true);limit->set_lower(value.lower);limit->set_upper(value.upper);
}
fillFeedback(response->mutable_header(), true);
// CMVR_LOG(DEBUG) << "[gRPCArmServiceImpl] (GetArmInfo): success, id=" << device_id
// << ", manufacturer=" << model.manufacturer

View File

@ -396,6 +396,15 @@ message JointResponse {
}
// 机械臂静态能力与 SDK 自动识别信息。
// Per-joint position limits, matched by name; radians. Missing/invalid limits are not zero limits.
message ArmJointLimit {
string joint_name = 1;
bool position_limits_available = 2;
double lower = 3;
double upper = 4;
// aubo_sdk: controller readback; driver_model: driver model/configuration/URDF, not hardware readback.
string source = 5;
}
message GetArmInfo {
message Request {
CommandHeader.Request header = 1;
@ -414,6 +423,7 @@ message GetArmInfo {
string description_id = 10;
bool detected_from_sdk = 11;
string driver_type = 12;
repeated ArmJointLimit joint_limits = 13;
}
}