/
vasandi
/
DroneControl
Обзор
Документация
Войти
/
vasandi
/
DroneControl
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
ControllDroneServerLinux/main.cpp
62 строки
1 KB
Андрей Васильченко
управление дроном в Airsim
08 июл 2026, 13:29
08 июл 2026, 13:29
d1a17d2
Код
Авторство
О чём код?
// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. #include "common/common_utils/StrictMode.hpp" STRICT_MODE_OFF #ifndef RPCLIB_MSGPACK #define RPCLIB_MSGPACK clmdep_msgpack #endif // !RPCLIB_MSGPACK #include "rpc/rpc_error.h" STRICT_MODE_ON #include "vehicles/multirotor/api/MultirotorRpcLibClient.hpp" #include "common/common_utils/FileSystem.hpp" #include <iostream> #include <chrono> #include <locale> #include <csignal> #include <nanomsg/nn.h> #include <nanomsg/reqrep.h> #include "DroneApplication.hpp" static drone::DroneApplication *g_app = nullptr; static void signalHandler(int sig) { std::cout << "\nПолучен сигнал " << sig << ", завершение работы...\n"; if (g_app) { g_app->stop(); } } static void installSignalHandlers() { struct sigaction sa{}; sa.sa_handler = signalHandler; sigemptyset(&sa.sa_mask); sa.sa_flags = 0; sigaction(SIGINT, &sa, nullptr); sigaction(SIGTERM, &sa, nullptr); sigaction(SIGHUP, &sa, nullptr); } int main() { std::locale::global(std::locale("")); std::wcout.imbue(std::locale("")); drone::DroneApplication app; g_app = &app; installSignalHandlers(); const std::string endpoint = "tcp://127.0.0.1:20001"; if (app.initRpcControllServer(endpoint) < 0) { return -1; } return app.run(); }