controller.cpp 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. //
  2. // Created by zx on 23-4-11.
  3. //
  4. #include "define/timedlockdata.hpp"
  5. #include "MPC/navigation_main.h"
  6. #include "define/TimerRecord.h"
  7. #include <glog/logging.h>
  8. #include "tool/pathcreator.h"
  9. #include "tool/proto_tool.h"
  10. #include "nav_server.h"
  11. #include <grpcpp/grpcpp.h>
  12. int main(int argc,char* argv[])
  13. {
  14. if(argc<2)
  15. {
  16. printf(" argc must == 2, exe parameter_file\n");
  17. return -1;
  18. }
  19. std::string parameter_file=argv[1];
  20. NavParameter::Navigation_parameter parameter;
  21. if(proto_tool::get_instance_pointer()->read_proto_param(parameter_file,parameter)==false)
  22. {
  23. printf(" read proto parameter failed:%s\n",parameter_file.c_str());
  24. return -2;
  25. }
  26. Navigation* g_navigator= nullptr;
  27. if(parameter.main_agv()==true)
  28. g_navigator=new NavigationMain();
  29. else
  30. g_navigator=new Navigation();
  31. if(g_navigator->Init(parameter))
  32. printf(" navigation inited\n");
  33. else{
  34. printf(" navigation init failed");
  35. return -1;
  36. }
  37. //启动rpc server
  38. grpc::ServerBuilder builder;
  39. NavServer service(g_navigator);
  40. builder.AddListeningPort(parameter.rpc_ipport(), grpc::InsecureServerCredentials());
  41. builder.RegisterService(&service);
  42. std::unique_ptr<grpc::Server> server(builder.BuildAndStart());
  43. std::cout << "Server Listening on port: " << std::endl;
  44. server->Wait();
  45. delete g_navigator;
  46. return 0;
  47. }