#pragma once
#include "rust/cxx.h"
#include <memory>
#include <string>
#include <functional>
#include <unordered_map>
#include <unitree/robot/channel/channel_subscriber.hpp>
#include <unitree/robot/channel/channel_publisher.hpp>
namespace unitree {
class SubscriberBase {
public:
virtual ~SubscriberBase() = default;
};
template<typename DdsT>
class Subscriber : public SubscriberBase {
public:
Subscriber(std::string topic, std::function<void(rust::Vec<uint8_t>)> on_bytes);
private:
unitree::robot::ChannelSubscriber<DdsT> sub_;
};
template<typename DdsT>
class Publisher {
public:
explicit Publisher(std::string topic);
~Publisher() = default;
void write(const DdsT& msg) const { pub_.Write(msg); }
private:
mutable unitree::robot::ChannelPublisher<DdsT> pub_;
};
}
#include "../gen/gen_topics.h"
namespace unitree {
void boot_dds(int32_t domain_id, rust::Str network_interface, rust::Str config_file);
struct ByteHandler;
int32_t subscribe_any(rust::Str topic, rust::Str type_name, rust::Box<ByteHandler> handler);
void unsubscribe(int32_t id);
}