Remove Windows MQTT setup guide and update Navigation class to include custom namespace. Increment version in main application log message to v0.0.2.
This commit is contained in:
@@ -1,85 +0,0 @@
|
|||||||
# Windows MQTT库安装指南
|
|
||||||
|
|
||||||
## 方法1: 使用vcpkg (推荐)
|
|
||||||
|
|
||||||
### 1. 安装vcpkg
|
|
||||||
```cmd
|
|
||||||
git clone https://github.com/Microsoft/vcpkg.git
|
|
||||||
cd vcpkg
|
|
||||||
.\bootstrap-vcpkg.bat
|
|
||||||
```
|
|
||||||
|
|
||||||
### 2. 安装MQTT库
|
|
||||||
```cmd
|
|
||||||
.\vcpkg install paho-mqtt:x64-windows
|
|
||||||
.\vcpkg install paho-mqttpp3:x64-windows
|
|
||||||
.\vcpkg install nlohmann-json:x64-windows
|
|
||||||
```
|
|
||||||
|
|
||||||
### 3. 集成到CMake
|
|
||||||
```cmd
|
|
||||||
.\vcpkg integrate install
|
|
||||||
```
|
|
||||||
|
|
||||||
### 4. 修改CMake命令
|
|
||||||
在构建时添加vcpkg工具链:
|
|
||||||
```cmd
|
|
||||||
mkdir build
|
|
||||||
cd build
|
|
||||||
cmake .. -DCMAKE_TOOLCHAIN_FILE=[vcpkg根目录]/scripts/buildsystems/vcpkg.cmake
|
|
||||||
cmake --build .
|
|
||||||
```
|
|
||||||
|
|
||||||
## 方法2: 手动编译
|
|
||||||
|
|
||||||
### 1. 编译Paho MQTT C库
|
|
||||||
```cmd
|
|
||||||
git clone https://github.com/eclipse/paho.mqtt.c.git
|
|
||||||
cd paho.mqtt.c
|
|
||||||
mkdir build
|
|
||||||
cd build
|
|
||||||
cmake .. -DPAHO_BUILD_STATIC=TRUE -DPAHO_BUILD_SHARED=FALSE
|
|
||||||
cmake --build . --config Release
|
|
||||||
cmake --install . --prefix C:/mqtt/c
|
|
||||||
```
|
|
||||||
|
|
||||||
### 2. 编译Paho MQTT C++库
|
|
||||||
```cmd
|
|
||||||
git clone https://github.com/eclipse/paho.mqtt.cpp.git
|
|
||||||
cd paho.mqtt.cpp
|
|
||||||
mkdir build
|
|
||||||
cd build
|
|
||||||
cmake .. -DPAHO_MQTT_C_PATH=C:/mqtt/c -DPAHO_BUILD_STATIC=TRUE
|
|
||||||
cmake --build . --config Release
|
|
||||||
cmake --install . --prefix C:/mqtt/cpp
|
|
||||||
```
|
|
||||||
|
|
||||||
### 3. 修改CMakeLists.txt
|
|
||||||
添加库路径:
|
|
||||||
```cmake
|
|
||||||
set(CMAKE_PREFIX_PATH "C:/mqtt/cpp;C:/mqtt/c")
|
|
||||||
find_package(PahoMqttCpp REQUIRED)
|
|
||||||
```
|
|
||||||
|
|
||||||
## 验证安装
|
|
||||||
|
|
||||||
运行以下命令验证:
|
|
||||||
```cmd
|
|
||||||
cd build
|
|
||||||
cmake ..
|
|
||||||
```
|
|
||||||
|
|
||||||
如果没有错误,说明MQTT库已正确配置。
|
|
||||||
|
|
||||||
## 使用示例
|
|
||||||
|
|
||||||
在您的代码中导入MQTT:
|
|
||||||
```cpp
|
|
||||||
#include <mqtt/async_client.h>
|
|
||||||
#include "mqtt.hpp"
|
|
||||||
|
|
||||||
// 创建MQTT客户端
|
|
||||||
auto mqttClient = std::make_unique<custom::MqttClient>("localhost", 1883, "test_client");
|
|
||||||
mqttClient->connect();
|
|
||||||
mqttClient->subscribe("test/topic");
|
|
||||||
```
|
|
||||||
@@ -6,6 +6,8 @@
|
|||||||
#include <nlohmann/json.hpp>
|
#include <nlohmann/json.hpp>
|
||||||
#include "unitree/robot/client/client.hpp"
|
#include "unitree/robot/client/client.hpp"
|
||||||
|
|
||||||
|
namespace custom {
|
||||||
|
|
||||||
class Navigation {
|
class Navigation {
|
||||||
public:
|
public:
|
||||||
Navigation();
|
Navigation();
|
||||||
@@ -26,4 +28,6 @@ private:
|
|||||||
bool callSlamService(int api_id, const nlohmann::json& data);
|
bool callSlamService(int api_id, const nlohmann::json& data);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace custom
|
||||||
|
|
||||||
#endif // NAVIGATION_HPP
|
#endif // NAVIGATION_HPP
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ void signalHandler(int signal) {
|
|||||||
int main(int argc, char** argv) {
|
int main(int argc, char** argv) {
|
||||||
Logger::getInstance().setLevel(LogLevel::INFO);
|
Logger::getInstance().setLevel(LogLevel::INFO);
|
||||||
|
|
||||||
LOG_INFO("Starting Unitree GO2 System v0.0.1");
|
LOG_INFO("Starting Unitree GO2 System v0.0.2");
|
||||||
|
|
||||||
signal(SIGINT, signalHandler);
|
signal(SIGINT, signalHandler);
|
||||||
signal(SIGTERM, signalHandler);
|
signal(SIGTERM, signalHandler);
|
||||||
|
|||||||
@@ -5,6 +5,8 @@
|
|||||||
|
|
||||||
const std::string SLAM_SERVICE_NAME = "slam_operate";
|
const std::string SLAM_SERVICE_NAME = "slam_operate";
|
||||||
|
|
||||||
|
namespace custom {
|
||||||
|
|
||||||
Navigation::Navigation() : client_(nullptr) {}
|
Navigation::Navigation() : client_(nullptr) {}
|
||||||
|
|
||||||
Navigation::~Navigation() {}
|
Navigation::~Navigation() {}
|
||||||
@@ -110,3 +112,5 @@ bool Navigation::closeSlam() {
|
|||||||
nlohmann::json data;
|
nlohmann::json data;
|
||||||
return callSlamService(1901, data);
|
return callSlamService(1901, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace custom
|
||||||
|
|||||||
Reference in New Issue
Block a user