feat: 添加生成随机客户端ID的功能

This commit is contained in:
2025-10-09 19:48:24 +08:00
parent 73ce74ab04
commit 6e669bb027

View File

@@ -775,4 +775,20 @@ void CustomRobot::continuousMoveLoop() {
controller_->Move(vx, vy, vyaw);
}
std::string CustomRobot::generateRandomClientId() const {
std::random_device rd;
std::mt19937 gen(rd());
std::uniform_int_distribution<> dis(0, 15);
std::stringstream ss;
ss << "go2_client_";
// 生成8位随机十六进制字符
for (int i = 0; i < 8; ++i) {
ss << std::hex << dis(gen);
}
return ss.str();
}
} // namespace custom