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:
2025-09-08 18:35:02 +08:00
parent 926d88972d
commit 90228e4ab9
4 changed files with 174 additions and 43 deletions

View File

@@ -3,7 +3,6 @@
namespace custom {
void CustomConfig::loadDefaults() {
// 网络和MQTT连接
network_interface = std::string(NETWORK_INTERFACE);
mqtt_broker = std::string(MQTT_BROKER);
mqtt_port = MQTT_PORT;
@@ -11,14 +10,10 @@ void CustomConfig::loadDefaults() {
mqtt_password = std::string(MQTT_PASSWORD);
mqtt_client_id = std::string(MQTT_CLIENT_ID);
// MQTT话题
topic_prefix = std::string(TOPIC_PREFIX);
topic_cmd = std::string(TOPIC_CMD);
topic_state = std::string(TOPIC_STATE);
topic_video = std::string(TOPIC_VIDEO);
topic_audio = std::string(TOPIC_AUDIO);
// 机器人控制和安全
control_frequency = CONTROL_FREQUENCY;
state_publish_frequency = STATE_PUBLISH_FREQUENCY;
max_linear_velocity = MAX_LINEAR_VELOCITY;
@@ -27,16 +22,6 @@ void CustomConfig::loadDefaults() {
stand_height = STAND_HEIGHT;
default_gait = static_cast<int>(DEFAULT_GAIT);
// 多媒体
enable_video = VIDEO_ENABLED;
enable_audio = AUDIO_ENABLED;
video_width = VIDEO_WIDTH;
video_height = VIDEO_HEIGHT;
video_fps = VIDEO_FPS;
video_format = std::string(VIDEO_FORMAT);
audio_sample_rate = AUDIO_SAMPLE_RATE;
audio_channels = AUDIO_CHANNELS;
audio_format = std::string(AUDIO_FORMAT);
}
} // namespace custom