controller.cpp 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. // NavParameter::Version nav_version;
  27. // if(proto_tool::get_instance_pointer()->read_proto_param(parameter_file,nav_version)==false) {
  28. // return -2;
  29. // }
  30. // printf(" version: %s\n",nav_version.version().c_str());
  31. Navigation* g_navigator= nullptr;
  32. if(parameter.main_agv()==true)
  33. g_navigator=new NavigationMain();
  34. else
  35. g_navigator=new Navigation();
  36. if(g_navigator->Init(parameter))
  37. printf(" navigation inited\n");
  38. else{
  39. printf(" navigation init failed\n");
  40. return -1;
  41. }
  42. //启动rpc server
  43. grpc::ServerBuilder builder;
  44. NavServer service(g_navigator);
  45. builder.AddListeningPort(parameter.rpc_ipport(), grpc::InsecureServerCredentials());
  46. builder.RegisterService(&service);
  47. std::unique_ptr<grpc::Server> server(builder.BuildAndStart());
  48. std::cout << "Server Listening on port: " << std::endl;
  49. server->Wait();
  50. delete g_navigator;
  51. return 0;
  52. }