feat: 添加生成随机客户端ID的功能
This commit is contained in:
@@ -775,4 +775,20 @@ void CustomRobot::continuousMoveLoop() {
|
|||||||
controller_->Move(vx, vy, vyaw);
|
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
|
} // namespace custom
|
||||||
|
|||||||
Reference in New Issue
Block a user