#ifndef __UT_ROBOT_SDK_CHANNEL_PUBLISHER_HPP__ #define __UT_ROBOT_SDK_CHANNEL_PUBLISHER_HPP__ #include namespace unitree { namespace robot { template class ChannelPublisher { public: explicit ChannelPublisher(const std::string& channelName) : mChannelName(channelName) {} void InitChannel() { mChannelPtr = ChannelFactory::Instance()->CreateSendChannel(mChannelName); } bool Write(const MSG& msg, int64_t waitMicrosec = 0) { if (mChannelPtr) { return mChannelPtr->Write(msg, waitMicrosec); } return false; } void CloseChannel() { mChannelPtr.reset(); } const std::string& GetChannelName() const { return mChannelName; } private: std::string mChannelName; ChannelPtr mChannelPtr; }; template using ChannelPublisherPtr = std::shared_ptr>; } } #endif//__UT_ROBOT_SDK_CHANNEL_PUBLISHER_HPP__