Files
lzwc-terminal-unitreeGo2/include/config.hpp

104 lines
2.6 KiB
C++

#pragma once
#include <string>
#include <string_view>
namespace custom {
/**
* @brief Robot motion gait types
*/
enum class Gait : int {
IDLE = 0, // Standing still
TROT = 1, // Normal walking
TROT_RUNNING = 2 // Fast running
};
// Network settings
constexpr std::string_view NETWORK_INTERFACE = "eth0";
// MQTT settings
constexpr std::string_view MQTT_BROKER = "localhost";
constexpr int MQTT_PORT = 1883;
constexpr std::string_view MQTT_CLIENT_ID = "unitree_go2_client";
constexpr std::string_view MQTT_USERNAME = "";
constexpr std::string_view MQTT_PASSWORD = "";
// Topic settings
constexpr std::string_view TOPIC_PREFIX = "unitree/go2";
constexpr std::string_view TOPIC_CMD = "cmd";
constexpr std::string_view TOPIC_STATE = "state";
constexpr std::string_view TOPIC_VIDEO = "video";
constexpr std::string_view TOPIC_AUDIO = "audio";
// Robot control settings
constexpr double CONTROL_FREQUENCY = 200.0; // Hz
constexpr double STATE_PUBLISH_FREQUENCY = 50.0; // Hz
// Safety settings
constexpr double MAX_LINEAR_VELOCITY = 1.5; // m/s
constexpr double MAX_ANGULAR_VELOCITY = 2.0; // rad/s
constexpr double EMERGENCY_STOP_TIMEOUT = 5.0; // seconds
// Motion settings
constexpr double STAND_HEIGHT = 0.0; // relative height
constexpr Gait DEFAULT_GAIT = Gait::IDLE;
// Video settings
constexpr int VIDEO_WIDTH = 1280;
constexpr int VIDEO_HEIGHT = 720;
constexpr int VIDEO_FPS = 30;
constexpr std::string_view VIDEO_FORMAT = "h264";
constexpr bool VIDEO_ENABLED = true;
// Audio settings
constexpr int AUDIO_SAMPLE_RATE = 16000;
constexpr int AUDIO_CHANNELS = 1;
constexpr std::string_view AUDIO_FORMAT = "pcm";
constexpr bool AUDIO_ENABLED = true;
class CustomConfig {
public:
// 网络和MQTT连接
std::string network_interface;
std::string mqtt_broker;
int mqtt_port;
std::string mqtt_username;
std::string mqtt_password;
std::string mqtt_client_id;
// MQTT话题
std::string topic_prefix;
std::string topic_cmd;
std::string topic_state;
std::string topic_video;
std::string topic_audio;
// 机器人控制和安全
double control_frequency;
double state_publish_frequency;
double max_linear_velocity;
double max_angular_velocity;
double emergency_stop_timeout;
double stand_height;
int default_gait;
// 多媒体
bool enable_video;
bool enable_audio;
int video_width;
int video_height;
int video_fps;
std::string video_format;
int audio_sample_rate;
int audio_channels;
std::string audio_format;
void loadDefaults();
};
} // namespace custom