feat: report arm motor current and servo state
This commit is contained in:
parent
45883d6ded
commit
1360746edb
@ -131,12 +131,14 @@ struct JointGroupState {
|
||||
std::vector<double> position;
|
||||
std::vector<double> velocity;
|
||||
std::vector<double> effort;
|
||||
std::vector<double> current;
|
||||
|
||||
bool validForModel(const RobotModel& model) const
|
||||
{
|
||||
return position.size() == model.dof &&
|
||||
velocity.size() == model.dof &&
|
||||
(effort.empty() || effort.size() == model.dof);
|
||||
(effort.empty() || effort.size() == model.dof) &&
|
||||
(current.empty() || current.size() == model.dof);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@ -27,6 +27,6 @@ task_manager {
|
||||
type: TASK_TYPE_QUIC_EDGE
|
||||
run_mode: TASK_RUN_MODE_BLOCKING_SERVICE
|
||||
config_file: "tasks/quic_edge_task/quic_edge_task.pb.txt"
|
||||
enable: true
|
||||
enable: false
|
||||
}
|
||||
}
|
||||
|
||||
@ -144,6 +144,7 @@ private:
|
||||
|
||||
mutable std::mutex mutex_;
|
||||
std::atomic<bool> busy_{false};
|
||||
std::atomic<bool> powered_on_{false};
|
||||
double speed_scaling_{1.0};
|
||||
std::atomic<bool> protective_stopped_{false};
|
||||
std::atomic<bool> emergency_stopped_{false};
|
||||
|
||||
@ -144,8 +144,8 @@ ArmState MotorRobotArm::getRobotState() const
|
||||
const bool emergency_stopped = emergency_stopped_.load();
|
||||
ArmState state;
|
||||
state.connected = motor_manager_ != nullptr;
|
||||
state.powered_on = true;
|
||||
state.brake_released = !emergency_stopped;
|
||||
state.powered_on = powered_on_.load();
|
||||
state.brake_released = powered_on_.load() && !emergency_stopped;
|
||||
state.moving = busy();
|
||||
state.protective_stopped = protective_stopped;
|
||||
state.emergency_stopped = emergency_stopped;
|
||||
@ -165,6 +165,7 @@ JointGroupState MotorRobotArm::getJointState() const
|
||||
state.position.reserve(joint_names_.size());
|
||||
state.velocity.reserve(joint_names_.size());
|
||||
state.effort.reserve(joint_names_.size());
|
||||
state.current.reserve(joint_names_.size());
|
||||
for (const auto& joint_name : joint_names_) {
|
||||
auto motor = getMotor_(joint_name);
|
||||
if (!motor) {
|
||||
@ -173,6 +174,7 @@ JointGroupState MotorRobotArm::getJointState() const
|
||||
state.position.push_back(motor->getQ());
|
||||
state.velocity.push_back(motor->getQd());
|
||||
state.effort.push_back(0.0);
|
||||
state.current.push_back(static_cast<double>(motor->getCurrent()));
|
||||
}
|
||||
return state;
|
||||
}
|
||||
@ -219,6 +221,7 @@ Result MotorRobotArm::torqueOn()
|
||||
}
|
||||
}
|
||||
emergency_stopped_.store(false);
|
||||
powered_on_.store(true);
|
||||
return Result::success();
|
||||
}
|
||||
|
||||
@ -234,6 +237,7 @@ Result MotorRobotArm::torqueOff()
|
||||
"failed to torque off motor for joint: " + joint_name);
|
||||
}
|
||||
}
|
||||
powered_on_.store(false);
|
||||
return Result::success();
|
||||
}
|
||||
|
||||
|
||||
@ -102,6 +102,7 @@ void fillJointState(api::JointState* dst,
|
||||
for (const double value : src.position) dst->add_position(value);
|
||||
for (const double value : src.velocity) dst->add_velocity(value);
|
||||
for (const double value : src.effort) dst->add_effort(value);
|
||||
for (const double value : src.current) dst->add_current(value);
|
||||
dst->set_timestamp(timestamp);
|
||||
}
|
||||
|
||||
@ -592,6 +593,7 @@ grpc::Status gRPCArmServiceImpl::getJointState(grpc::ServerContext*,
|
||||
for (double v : state.position) msg->add_position(v);
|
||||
for (double v : state.velocity) msg->add_velocity(v);
|
||||
for (double v : state.effort) msg->add_effort(v);
|
||||
for (double v : state.current) msg->add_current(v);
|
||||
fillFeedback(response->mutable_header(), true);
|
||||
// CMVR_LOG(DEBUG) << "[gRPCArmServiceImpl] (getJointState): success, id=" << device_id
|
||||
// << ", joints=" << msg->name_size()
|
||||
|
||||
@ -263,6 +263,8 @@ message JointState {
|
||||
repeated double effort = 4;
|
||||
// 状态采样的 Unix 时间戳,单位:s。
|
||||
double timestamp = 5;
|
||||
// 电机实际电流,单位:mA。
|
||||
repeated double current = 6;
|
||||
}
|
||||
|
||||
// 查询关节状态的请求。
|
||||
|
||||
Loading…
Reference in New Issue
Block a user