This commit is contained in:
linbo 2026-06-17 14:15:49 +08:00
parent ae8961f52a
commit 59944d6c0d
5 changed files with 25 additions and 13 deletions

View File

@ -96,7 +96,10 @@ void MotorsInfo::init(const XmlNode &cfg) {
};
// 创建 MotorManager
motor_manager_ = std::make_shared<MotorManager>();
if (!motor_manager_)
{
motor_manager_ = std::make_shared<MotorManager>();
}
std::vector<std::future<void> > tasks;
@ -234,7 +237,10 @@ void MotorsInfo::init(const cmvr::config::HumanRobotConfig& config) {
{"HEAD", head_enabled_, head_can_client_, head_can_sender_, head_can_receiver_, head_message_manager_, head_motors_cfg}
};
motor_manager_ = std::make_shared<MotorManager>();
if (!motor_manager_)
{
motor_manager_ = std::make_shared<MotorManager>();
}
std::vector<std::future<void>> tasks;
for (auto &limb : limbs) {

View File

@ -140,7 +140,7 @@ void HumanoidRobot<DOF>::init() {
std::vector<double>(7, 1.0));
ik_solver_ = std::make_shared<PinocchioDlsIKSolver>("/home/lgv/cmvr/cmvr-es/model/xiaoyan_description/dual_arm.urdf",
ik_solver_ = std::make_shared<PinocchioDlsIKSolver>("/home/cmvr/Projects/cmvr-es/model/xiaoyan_description/dual_arm.urdf",
"PELVIS_S",
"R_WRIST_R_S",
"R_FINGER_TIP_FIXED");

View File

@ -29,7 +29,8 @@ int main(int argc, char* argv[]) {
}
ServerRunner runner;
runner.start();
const XmlNode config(config_path);
runner.start(config);
runner.join();
google::ShutdownGoogleLogging();
return 0;

View File

@ -18,7 +18,7 @@ namespace cmvr::service {
class ServerRunner {
public:
ServerRunner();
ServerRunner(const cmvr::config::ServerConfig& config);
explicit ServerRunner(XmlNode cfg);
~ServerRunner();
ServerRunner(const ServerRunner&) = delete;
@ -26,7 +26,7 @@ namespace cmvr::service {
ServerRunner(ServerRunner&&) = delete;
ServerRunner& operator=(ServerRunner&&) = delete;
void start();
void start(XmlNode cfg);
void stop();
void join();
@ -41,7 +41,8 @@ namespace cmvr::service {
std::condition_variable cv_;
std::thread worker_;
cmvr::config::ServerConfig cfg_;
XmlNode cfg_;
cmvr::config::ServerConfig servercfg_;
std::unique_ptr<grpc::Server> server_;
std::string address_;

View File

@ -25,21 +25,23 @@
using namespace cmvr::service;
ServerRunner::ServerRunner() = default;
ServerRunner::ServerRunner(const cmvr::config::ServerConfig& config):cfg_(config)
{
// start();
ServerRunner::ServerRunner(XmlNode cfg) {
start(std::move(cfg));
}
ServerRunner::~ServerRunner() {
stop();
join();
}
void ServerRunner::start() {
void ServerRunner::start(XmlNode cfg) {
std::unique_lock<std::mutex> lk(mtx_);
if (worker_.joinable()) {
throw std::runtime_error("ServerRunner already started");
}
cfg_ = std::move(cfg);
stop_requested_ = false;
started_ = false;
start_failed_ = false;
@ -101,9 +103,11 @@ void ServerRunner::threadMain() {
std::call_once(reflection_once, []() {
grpc::reflection::InitProtoReflectionServerBuilderPlugin();
});
DeviceManager::getInstance();
std::string port = cfg_.grpc_server().port();
auto dmgr_cfg = cfg_.getChild("DeviceManager");
DeviceManager::getInstance(dmgr_cfg);
std::string port = servercfg_.grpc_server().port();
std::string local_address = "0.0.0.0:" + port;
auto camera_service = std::make_unique<gRPCCameraServiceImpl>();