// // Created by lgv on 2025/8/25. // #include "../../../include/service/grpc_service/grpc_hlc_service.h" #include #include "robot/humanoid_robot/humanoid_robot.h" #include "controller/touch_controller.h" using namespace cmvr::service; using namespace cmvr::device; using namespace cmvr::api; using google::protobuf::util::TimeUtil; gRPCHlcServiceImpl::gRPCHlcServiceImpl():dmgr_(DeviceManager::getInstance()){} grpc::Status gRPCHlcServiceImpl::touch(grpc::ServerContext *context, const cmvr::api::Touch_Request *request, cmvr::api::Touch_Response *response) { grpc::Status ret = grpc::Status::OK; try { std::shared_ptr robot = nullptr; auto cam = dmgr_.getDevice("cam4"); auto hand = dmgr_.getDevice("hand1"); ctrl::TouchController touch_controller(robot,hand,cam);; touch_controller.touch(request->u(),request->v(),request->max_force()); response->mutable_header()->set_success(true); response->mutable_header()->set_error_message(""); }catch (const std::exception& e) { response->mutable_header()->set_success(false); response->mutable_header()->set_error_message(e.what()); ret = grpc::Status(grpc::StatusCode::INTERNAL, e.what()); } *response->mutable_header()->mutable_timestamp() = TimeUtil::GetCurrentTime(); return ret; }