Implement MQTT functionality in CustomRobot class. Added methods for MQTT initialization, message handling, and connection management. Updated configuration to remove multimedia settings and streamline MQTT-related parameters. Enhanced logging for MQTT operations and ensured proper cleanup during shutdown.
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
#include "controller.hpp"
|
||||
#include "config.hpp"
|
||||
#include "logger.hpp"
|
||||
#include "mqtt.hpp"
|
||||
|
||||
#include <memory>
|
||||
#include <atomic>
|
||||
@@ -22,14 +23,21 @@ public:
|
||||
|
||||
Controller* getController() const { return controller_.get(); }
|
||||
|
||||
// Robot state methods
|
||||
bool GetServiceList(std::vector<unitree::robot::go2::ServiceState>& serviceList);
|
||||
bool SwitchService(const std::string& serviceName, bool enable);
|
||||
bool SetReportFreq(int32_t interval, int32_t duration);
|
||||
|
||||
// MQTT related methods
|
||||
bool initializeMqtt();
|
||||
void onMqttMessage(const std::string& topic, const std::string& payload);
|
||||
void onMqttConnection(bool connected);
|
||||
void publishStatus();
|
||||
|
||||
private:
|
||||
std::string generateRandomClientId() const;
|
||||
std::unique_ptr<Controller> controller_;
|
||||
std::unique_ptr<unitree::robot::go2::RobotStateClient> rsc_;
|
||||
std::unique_ptr<MqttClient> mqttClient_;
|
||||
|
||||
CustomConfig config_;
|
||||
std::atomic<bool> running_;
|
||||
|
||||
Reference in New Issue
Block a user