From 02a0496cb6812d3092d998848d3370d89fc15b0f Mon Sep 17 00:00:00 2001 From: Rooholla-Khorrambakht Date: Wed, 3 Jan 2024 22:51:12 -0500 Subject: [PATCH] lowlevel bridge added --- Dockerfile | 16 + cpp_bridge/.vscode/settings.json | 9 + cpp_bridge/CMakeLists.txt | 3 +- .../include/unitree/idl/go2/LowCmd_-orig.hpp | 999 ------------------ .../include/unitree/idl/go2/LowCmd_.hpp | 769 +------------- cpp_bridge/src/lowlevel/bridge.cpp | 126 ++- 6 files changed, 162 insertions(+), 1760 deletions(-) create mode 100644 Dockerfile create mode 100644 cpp_bridge/.vscode/settings.json delete mode 100644 cpp_bridge/include/unitree/idl/go2/LowCmd_-orig.hpp diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..e00b446 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,16 @@ +FROM ubuntu:20.04 +ENV DEBIAN_FRONTEND=noninteractive +# uodate and install dependencies +RUN apt-get update && apt-get install -y \ + build-essential \ + cmake \ + git \ + && rm -rf /var/lib/apt/lists/* + +# make and install the project +COPY cpp_bridge /cpp_bridge +WORKDIR /cpp_bridge +RUN ./install.sh && mkdir build && cd build && cmake .. && make + +# set the entrypoint to bash +ENTRYPOINT ["/bin/bash"] diff --git a/cpp_bridge/.vscode/settings.json b/cpp_bridge/.vscode/settings.json new file mode 100644 index 0000000..39d2543 --- /dev/null +++ b/cpp_bridge/.vscode/settings.json @@ -0,0 +1,9 @@ +{ + "cmake.configureOnOpen": true, + "files.associations": { + "thread": "cpp", + "chrono": "cpp", + "ostream": "cpp", + "list": "cpp" + } +} \ No newline at end of file diff --git a/cpp_bridge/CMakeLists.txt b/cpp_bridge/CMakeLists.txt index aa64f64..77471ae 100644 --- a/cpp_bridge/CMakeLists.txt +++ b/cpp_bridge/CMakeLists.txt @@ -2,8 +2,9 @@ project(go2py_bridge) cmake_minimum_required(VERSION 3.5) SET(CMAKE_CXX_STANDARD 17) +add_library(msgs STATIC include/go2py/LowCmd.cpp include/go2py/LowState.cpp) include_directories(/usr/local/include/ddscxx /usr/local/include/iceoryx/v2.0.2) -link_libraries(unitree_sdk2 ddsc ddscxx rt pthread) +link_libraries(unitree_sdk2 ddsc ddscxx rt pthread msgs) add_executable(lowlevel_bridge src/lowlevel/bridge.cpp) diff --git a/cpp_bridge/include/unitree/idl/go2/LowCmd_-orig.hpp b/cpp_bridge/include/unitree/idl/go2/LowCmd_-orig.hpp deleted file mode 100644 index 24df6da..0000000 --- a/cpp_bridge/include/unitree/idl/go2/LowCmd_-orig.hpp +++ /dev/null @@ -1,999 +0,0 @@ -/**************************************************************** - - Generated by Eclipse Cyclone DDS IDL to CXX Translator - File name: LowCmd_.idl - Source: LowCmd_.hpp - Cyclone DDS: v0.10.2 - -*****************************************************************/ -#ifndef DDSCXX_LOWCMD__HPP -#define DDSCXX_LOWCMD__HPP - -#include "BmsCmd_.hpp" - -#include "MotorCmd_.hpp" - -#include -#include - -namespace unitree_go -{ -namespace msg -{ -namespace dds_ -{ -class LowCmd_ -{ -private: - std::array head_ = { }; - uint8_t level_flag_ = 0; - uint8_t frame_reserve_ = 0; - std::array sn_ = { }; - std::array version_ = { }; - uint16_t bandwidth_ = 0; - std::array<::unitree_go::msg::dds_::MotorCmd_, 20> motor_cmd_ = { }; - ::unitree_go::msg::dds_::BmsCmd_ bms_cmd_; - std::array wireless_remote_ = { }; - std::array led_ = { }; - std::array fan_ = { }; - uint8_t gpio_ = 0; - uint32_t reserve_ = 0; - uint32_t crc_ = 0; - -public: - LowCmd_() = default; - - explicit LowCmd_( - const std::array& head, - uint8_t level_flag, - uint8_t frame_reserve, - const std::array& sn, - const std::array& version, - uint16_t bandwidth, - const std::array<::unitree_go::msg::dds_::MotorCmd_, 20>& motor_cmd, - const ::unitree_go::msg::dds_::BmsCmd_& bms_cmd, - const std::array& wireless_remote, - const std::array& led, - const std::array& fan, - uint8_t gpio, - uint32_t reserve, - uint32_t crc) : - head_(head), - level_flag_(level_flag), - frame_reserve_(frame_reserve), - sn_(sn), - version_(version), - bandwidth_(bandwidth), - motor_cmd_(motor_cmd), - bms_cmd_(bms_cmd), - wireless_remote_(wireless_remote), - led_(led), - fan_(fan), - gpio_(gpio), - reserve_(reserve), - crc_(crc) { } - - const std::array& head() const { return this->head_; } - std::array& head() { return this->head_; } - void head(const std::array& _val_) { this->head_ = _val_; } - void head(std::array&& _val_) { this->head_ = _val_; } - uint8_t level_flag() const { return this->level_flag_; } - uint8_t& level_flag() { return this->level_flag_; } - void level_flag(uint8_t _val_) { this->level_flag_ = _val_; } - uint8_t frame_reserve() const { return this->frame_reserve_; } - uint8_t& frame_reserve() { return this->frame_reserve_; } - void frame_reserve(uint8_t _val_) { this->frame_reserve_ = _val_; } - const std::array& sn() const { return this->sn_; } - std::array& sn() { return this->sn_; } - void sn(const std::array& _val_) { this->sn_ = _val_; } - void sn(std::array&& _val_) { this->sn_ = _val_; } - const std::array& version() const { return this->version_; } - std::array& version() { return this->version_; } - void version(const std::array& _val_) { this->version_ = _val_; } - void version(std::array&& _val_) { this->version_ = _val_; } - uint16_t bandwidth() const { return this->bandwidth_; } - uint16_t& bandwidth() { return this->bandwidth_; } - void bandwidth(uint16_t _val_) { this->bandwidth_ = _val_; } - const std::array<::unitree_go::msg::dds_::MotorCmd_, 20>& motor_cmd() const { return this->motor_cmd_; } - std::array<::unitree_go::msg::dds_::MotorCmd_, 20>& motor_cmd() { return this->motor_cmd_; } - void motor_cmd(const std::array<::unitree_go::msg::dds_::MotorCmd_, 20>& _val_) { this->motor_cmd_ = _val_; } - void motor_cmd(std::array<::unitree_go::msg::dds_::MotorCmd_, 20>&& _val_) { this->motor_cmd_ = _val_; } - const ::unitree_go::msg::dds_::BmsCmd_& bms_cmd() const { return this->bms_cmd_; } - ::unitree_go::msg::dds_::BmsCmd_& bms_cmd() { return this->bms_cmd_; } - void bms_cmd(const ::unitree_go::msg::dds_::BmsCmd_& _val_) { this->bms_cmd_ = _val_; } - void bms_cmd(::unitree_go::msg::dds_::BmsCmd_&& _val_) { this->bms_cmd_ = _val_; } - const std::array& wireless_remote() const { return this->wireless_remote_; } - std::array& wireless_remote() { return this->wireless_remote_; } - void wireless_remote(const std::array& _val_) { this->wireless_remote_ = _val_; } - void wireless_remote(std::array&& _val_) { this->wireless_remote_ = _val_; } - const std::array& led() const { return this->led_; } - std::array& led() { return this->led_; } - void led(const std::array& _val_) { this->led_ = _val_; } - void led(std::array&& _val_) { this->led_ = _val_; } - const std::array& fan() const { return this->fan_; } - std::array& fan() { return this->fan_; } - void fan(const std::array& _val_) { this->fan_ = _val_; } - void fan(std::array&& _val_) { this->fan_ = _val_; } - uint8_t gpio() const { return this->gpio_; } - uint8_t& gpio() { return this->gpio_; } - void gpio(uint8_t _val_) { this->gpio_ = _val_; } - uint32_t reserve() const { return this->reserve_; } - uint32_t& reserve() { return this->reserve_; } - void reserve(uint32_t _val_) { this->reserve_ = _val_; } - uint32_t crc() const { return this->crc_; } - uint32_t& crc() { return this->crc_; } - void crc(uint32_t _val_) { this->crc_ = _val_; } - - bool operator==(const LowCmd_& _other) const - { - (void) _other; - return head_ == _other.head_ && - level_flag_ == _other.level_flag_ && - frame_reserve_ == _other.frame_reserve_ && - sn_ == _other.sn_ && - version_ == _other.version_ && - bandwidth_ == _other.bandwidth_ && - motor_cmd_ == _other.motor_cmd_ && - bms_cmd_ == _other.bms_cmd_ && - wireless_remote_ == _other.wireless_remote_ && - led_ == _other.led_ && - fan_ == _other.fan_ && - gpio_ == _other.gpio_ && - reserve_ == _other.reserve_ && - crc_ == _other.crc_; - } - - bool operator!=(const LowCmd_& _other) const - { - return !(*this == _other); - } - -}; - -} - -} - -} - -#include "dds/topic/TopicTraits.hpp" -#include "org/eclipse/cyclonedds/topic/datatopic.hpp" - -namespace org { -namespace eclipse { -namespace cyclonedds { -namespace topic { - -template <> constexpr const char* TopicTraits<::unitree_go::msg::dds_::LowCmd_>::getTypeName() -{ - return "unitree_go::msg::dds_::LowCmd_"; -} - -template <> constexpr bool TopicTraits<::unitree_go::msg::dds_::LowCmd_>::isKeyless() -{ - return true; -} - -#ifdef DDSCXX_HAS_TYPE_DISCOVERY -template<> constexpr unsigned int TopicTraits<::unitree_go::msg::dds_::LowCmd_>::type_map_blob_sz() { return 1710; } -template<> constexpr unsigned int TopicTraits<::unitree_go::msg::dds_::LowCmd_>::type_info_blob_sz() { return 196; } -template<> inline const uint8_t * TopicTraits<::unitree_go::msg::dds_::LowCmd_>::type_map_blob() { - static const uint8_t blob[] = { - 0x72, 0x02, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0xf1, 0x83, 0x28, 0x76, 0xce, 0xec, 0x97, 0x37, - 0xd6, 0x9f, 0x6e, 0xd6, 0x2a, 0x3f, 0x63, 0x00, 0x63, 0x01, 0x00, 0x00, 0xf1, 0x51, 0x01, 0x00, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x53, 0x01, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, - 0x16, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x90, 0xf3, 0x01, 0x00, 0x00, 0x00, - 0x01, 0x00, 0x00, 0x00, 0x02, 0x02, 0x96, 0xe8, 0x9a, 0x29, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, - 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0xa2, 0x18, 0x71, 0x24, 0x00, 0x0b, 0x00, 0x00, 0x00, - 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0xf0, 0xd2, 0xa4, 0x1c, 0x00, 0x16, 0x00, 0x00, 0x00, - 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x90, 0xf3, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, - 0x02, 0x07, 0xaf, 0xbe, 0x94, 0xcd, 0x00, 0x00, 0x16, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, - 0x01, 0x00, 0x90, 0xf3, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x07, 0x2a, 0xf7, - 0x2f, 0x10, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x01, 0x00, 0x06, 0x36, - 0x67, 0x6c, 0x2b, 0x00, 0x24, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x01, 0x00, 0x90, 0xf1, - 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x14, 0xf1, 0xc8, 0xe5, 0x83, 0x5b, 0x0f, 0x0c, - 0x17, 0x65, 0xbc, 0x23, 0x1d, 0xfa, 0x02, 0xff, 0x5b, 0xcf, 0x19, 0xa4, 0x19, 0x00, 0x00, 0x00, - 0x07, 0x00, 0x00, 0x00, 0x01, 0x00, 0xf1, 0x3e, 0x8e, 0xb6, 0x7c, 0x25, 0xfd, 0xe0, 0x7e, 0x52, - 0xcf, 0x51, 0xed, 0x4a, 0x23, 0x11, 0x50, 0x97, 0xc7, 0x00, 0x00, 0x00, 0x16, 0x00, 0x00, 0x00, - 0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x90, 0xf3, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, - 0x28, 0x02, 0xa8, 0x2f, 0x18, 0xc9, 0x00, 0x00, 0x16, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, - 0x01, 0x00, 0x90, 0xf3, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0c, 0x02, 0x0b, 0x98, - 0xf7, 0xbc, 0x00, 0x00, 0x16, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x01, 0x00, 0x90, 0xf3, - 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x02, 0x50, 0xbd, 0x8c, 0x21, 0x00, 0x00, - 0x0b, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x95, 0x58, 0x71, 0xc9, 0x00, - 0x0b, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x01, 0x00, 0x07, 0x9c, 0x3b, 0x62, 0x94, 0x00, - 0x0b, 0x00, 0x00, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x01, 0x00, 0x07, 0xf5, 0xad, 0x59, 0xc5, 0xf1, - 0xc8, 0xe5, 0x83, 0x5b, 0x0f, 0x0c, 0x17, 0x65, 0xbc, 0x23, 0x1d, 0xfa, 0x02, 0xff, 0x00, 0x00, - 0x8e, 0x00, 0x00, 0x00, 0xf1, 0x51, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x7e, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x01, 0x00, 0x02, 0x15, 0xd6, 0x17, 0x12, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, - 0x01, 0x00, 0x09, 0x76, 0x94, 0xf4, 0xa6, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, - 0x01, 0x00, 0x09, 0x47, 0xbc, 0xdc, 0xd7, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, - 0x01, 0x00, 0x09, 0x45, 0x80, 0xc2, 0x74, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, - 0x01, 0x00, 0x09, 0x26, 0xb5, 0x68, 0xe4, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, - 0x01, 0x00, 0x09, 0x87, 0x22, 0x16, 0x52, 0x00, 0x16, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x01, 0x00, 0x90, 0xf3, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, 0x07, 0x9c, 0x3b, - 0x62, 0x94, 0xf1, 0x3e, 0x8e, 0xb6, 0x7c, 0x25, 0xfd, 0xe0, 0x7e, 0x52, 0xcf, 0x51, 0xed, 0x4a, - 0x23, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00, 0xf1, 0x51, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x2e, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x32, 0x62, 0xd4, 0x8d, 0x00, 0x16, 0x00, 0x00, 0x00, - 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x90, 0xf3, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, - 0x03, 0x02, 0x9c, 0x3b, 0x62, 0x94, 0x00, 0x00, 0xce, 0x03, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, - 0xf2, 0x52, 0xcc, 0x8e, 0xb0, 0xd4, 0x27, 0xd6, 0x92, 0xaa, 0x2b, 0x20, 0xa9, 0x05, 0x40, 0x00, - 0x26, 0x02, 0x00, 0x00, 0xf2, 0x51, 0x01, 0x00, 0x27, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x1f, 0x00, 0x00, 0x00, 0x75, 0x6e, 0x69, 0x74, 0x72, 0x65, 0x65, 0x5f, 0x67, 0x6f, 0x3a, 0x3a, - 0x6d, 0x73, 0x67, 0x3a, 0x3a, 0x64, 0x64, 0x73, 0x5f, 0x3a, 0x3a, 0x4c, 0x6f, 0x77, 0x43, 0x6d, - 0x64, 0x5f, 0x00, 0x00, 0xf2, 0x01, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x90, 0xf3, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, - 0x02, 0x02, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x68, 0x65, 0x61, 0x64, 0x00, 0x00, 0x00, 0x00, - 0x19, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x0b, 0x00, 0x00, 0x00, - 0x6c, 0x65, 0x76, 0x65, 0x6c, 0x5f, 0x66, 0x6c, 0x61, 0x67, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x1c, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x0e, 0x00, 0x00, 0x00, - 0x66, 0x72, 0x61, 0x6d, 0x65, 0x5f, 0x72, 0x65, 0x73, 0x65, 0x72, 0x76, 0x65, 0x00, 0x00, 0x00, - 0x1d, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x90, 0xf3, 0x01, 0x00, 0x00, 0x00, - 0x01, 0x00, 0x00, 0x00, 0x02, 0x07, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x73, 0x6e, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x90, 0xf3, - 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x07, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, - 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, - 0x05, 0x00, 0x00, 0x00, 0x01, 0x00, 0x06, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x62, 0x61, 0x6e, 0x64, - 0x77, 0x69, 0x64, 0x74, 0x68, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x01, 0x00, 0x90, 0xf2, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x14, 0xf2, 0x42, 0x1f, - 0xa5, 0xb2, 0xdb, 0x2d, 0xef, 0xf5, 0xc0, 0x3f, 0xff, 0x16, 0x30, 0x3b, 0x0a, 0x00, 0x00, 0x00, - 0x6d, 0x6f, 0x74, 0x6f, 0x72, 0x5f, 0x63, 0x6d, 0x64, 0x00, 0x00, 0x00, 0x26, 0x00, 0x00, 0x00, - 0x07, 0x00, 0x00, 0x00, 0x01, 0x00, 0xf2, 0x31, 0xa8, 0x59, 0x24, 0x05, 0x6b, 0x7a, 0xf3, 0xd3, - 0xf1, 0x6b, 0x34, 0x22, 0x33, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x62, 0x6d, 0x73, 0x5f, - 0x63, 0x6d, 0x64, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, - 0x01, 0x00, 0x90, 0xf3, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x28, 0x02, 0x00, 0x00, - 0x10, 0x00, 0x00, 0x00, 0x77, 0x69, 0x72, 0x65, 0x6c, 0x65, 0x73, 0x73, 0x5f, 0x72, 0x65, 0x6d, - 0x6f, 0x74, 0x65, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, - 0x01, 0x00, 0x90, 0xf3, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0c, 0x02, 0x00, 0x00, - 0x04, 0x00, 0x00, 0x00, 0x6c, 0x65, 0x64, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, - 0x0a, 0x00, 0x00, 0x00, 0x01, 0x00, 0x90, 0xf3, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, - 0x02, 0x02, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x66, 0x61, 0x6e, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x13, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x05, 0x00, 0x00, 0x00, - 0x67, 0x70, 0x69, 0x6f, 0x00, 0x00, 0x00, 0x00, 0x16, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, - 0x01, 0x00, 0x07, 0x00, 0x08, 0x00, 0x00, 0x00, 0x72, 0x65, 0x73, 0x65, 0x72, 0x76, 0x65, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x12, 0x00, 0x00, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x01, 0x00, 0x07, 0x00, - 0x04, 0x00, 0x00, 0x00, 0x63, 0x72, 0x63, 0x00, 0x00, 0x00, 0xf2, 0x42, 0x1f, 0xa5, 0xb2, 0xdb, - 0x2d, 0xef, 0xf5, 0xc0, 0x3f, 0xff, 0x16, 0x30, 0x3b, 0x00, 0x00, 0x00, 0xee, 0x00, 0x00, 0x00, - 0xf2, 0x51, 0x01, 0x00, 0x29, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, - 0x75, 0x6e, 0x69, 0x74, 0x72, 0x65, 0x65, 0x5f, 0x67, 0x6f, 0x3a, 0x3a, 0x6d, 0x73, 0x67, 0x3a, - 0x3a, 0x64, 0x64, 0x73, 0x5f, 0x3a, 0x3a, 0x4d, 0x6f, 0x74, 0x6f, 0x72, 0x43, 0x6d, 0x64, 0x5f, - 0x00, 0x00, 0x00, 0x00, 0xb6, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x05, 0x00, 0x00, 0x00, 0x6d, 0x6f, 0x64, 0x65, - 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x09, 0x00, - 0x02, 0x00, 0x00, 0x00, 0x71, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, - 0x01, 0x00, 0x09, 0x00, 0x03, 0x00, 0x00, 0x00, 0x64, 0x71, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x12, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x09, 0x00, 0x04, 0x00, 0x00, 0x00, - 0x74, 0x61, 0x75, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, - 0x01, 0x00, 0x09, 0x00, 0x03, 0x00, 0x00, 0x00, 0x6b, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x11, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x01, 0x00, 0x09, 0x00, 0x03, 0x00, 0x00, 0x00, - 0x6b, 0x64, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x01, 0x00, 0x90, 0xf3, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, 0x07, 0x00, 0x00, - 0x08, 0x00, 0x00, 0x00, 0x72, 0x65, 0x73, 0x65, 0x72, 0x76, 0x65, 0x00, 0x00, 0x00, 0xf2, 0x31, - 0xa8, 0x59, 0x24, 0x05, 0x6b, 0x7a, 0xf3, 0xd3, 0xf1, 0x6b, 0x34, 0x22, 0x33, 0x00, 0x00, 0x00, - 0x76, 0x00, 0x00, 0x00, 0xf2, 0x51, 0x01, 0x00, 0x27, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x1f, 0x00, 0x00, 0x00, 0x75, 0x6e, 0x69, 0x74, 0x72, 0x65, 0x65, 0x5f, 0x67, 0x6f, 0x3a, 0x3a, - 0x6d, 0x73, 0x67, 0x3a, 0x3a, 0x64, 0x64, 0x73, 0x5f, 0x3a, 0x3a, 0x42, 0x6d, 0x73, 0x43, 0x6d, - 0x64, 0x5f, 0x00, 0x00, 0x42, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x12, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x04, 0x00, 0x00, 0x00, 0x6f, 0x66, 0x66, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x90, 0xf3, - 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, 0x02, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, - 0x72, 0x65, 0x73, 0x65, 0x72, 0x76, 0x65, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5e, 0x00, 0x00, 0x00, - 0x03, 0x00, 0x00, 0x00, 0xf2, 0x52, 0xcc, 0x8e, 0xb0, 0xd4, 0x27, 0xd6, 0x92, 0xaa, 0x2b, 0x20, - 0xa9, 0x05, 0x40, 0xf1, 0x83, 0x28, 0x76, 0xce, 0xec, 0x97, 0x37, 0xd6, 0x9f, 0x6e, 0xd6, 0x2a, - 0x3f, 0x63, 0xf2, 0x42, 0x1f, 0xa5, 0xb2, 0xdb, 0x2d, 0xef, 0xf5, 0xc0, 0x3f, 0xff, 0x16, 0x30, - 0x3b, 0xf1, 0xc8, 0xe5, 0x83, 0x5b, 0x0f, 0x0c, 0x17, 0x65, 0xbc, 0x23, 0x1d, 0xfa, 0x02, 0xff, - 0xf2, 0x31, 0xa8, 0x59, 0x24, 0x05, 0x6b, 0x7a, 0xf3, 0xd3, 0xf1, 0x6b, 0x34, 0x22, 0x33, 0xf1, - 0x3e, 0x8e, 0xb6, 0x7c, 0x25, 0xfd, 0xe0, 0x7e, 0x52, 0xcf, 0x51, 0xed, 0x4a, 0x23, }; - return blob; -} -template<> inline const uint8_t * TopicTraits<::unitree_go::msg::dds_::LowCmd_>::type_info_blob() { - static const uint8_t blob[] = { - 0xc0, 0x00, 0x00, 0x00, 0x01, 0x10, 0x00, 0x40, 0x58, 0x00, 0x00, 0x00, 0x54, 0x00, 0x00, 0x00, - 0x14, 0x00, 0x00, 0x00, 0xf1, 0x83, 0x28, 0x76, 0xce, 0xec, 0x97, 0x37, 0xd6, 0x9f, 0x6e, 0xd6, - 0x2a, 0x3f, 0x63, 0x00, 0x67, 0x01, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00, - 0x02, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0xf1, 0xc8, 0xe5, 0x83, 0x5b, 0x0f, 0x0c, 0x17, - 0x65, 0xbc, 0x23, 0x1d, 0xfa, 0x02, 0xff, 0x00, 0x92, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, - 0xf1, 0x3e, 0x8e, 0xb6, 0x7c, 0x25, 0xfd, 0xe0, 0x7e, 0x52, 0xcf, 0x51, 0xed, 0x4a, 0x23, 0x00, - 0x42, 0x00, 0x00, 0x00, 0x02, 0x10, 0x00, 0x40, 0x58, 0x00, 0x00, 0x00, 0x54, 0x00, 0x00, 0x00, - 0x14, 0x00, 0x00, 0x00, 0xf2, 0x52, 0xcc, 0x8e, 0xb0, 0xd4, 0x27, 0xd6, 0x92, 0xaa, 0x2b, 0x20, - 0xa9, 0x05, 0x40, 0x00, 0x2a, 0x02, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00, - 0x02, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0xf2, 0x42, 0x1f, 0xa5, 0xb2, 0xdb, 0x2d, 0xef, - 0xf5, 0xc0, 0x3f, 0xff, 0x16, 0x30, 0x3b, 0x00, 0xf2, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, - 0xf2, 0x31, 0xa8, 0x59, 0x24, 0x05, 0x6b, 0x7a, 0xf3, 0xd3, 0xf1, 0x6b, 0x34, 0x22, 0x33, 0x00, - 0x7a, 0x00, 0x00, 0x00, }; - return blob; -} -#endif //DDSCXX_HAS_TYPE_DISCOVERY - -} //namespace topic -} //namespace cyclonedds -} //namespace eclipse -} //namespace org - -namespace dds { -namespace topic { - -template <> -struct topic_type_name<::unitree_go::msg::dds_::LowCmd_> -{ - static std::string value() - { - return org::eclipse::cyclonedds::topic::TopicTraits<::unitree_go::msg::dds_::LowCmd_>::getTypeName(); - } -}; - -} -} - -REGISTER_TOPIC_TYPE(::unitree_go::msg::dds_::LowCmd_) - -namespace org{ -namespace eclipse{ -namespace cyclonedds{ -namespace core{ -namespace cdr{ - -template<> -propvec &get_type_props<::unitree_go::msg::dds_::LowCmd_>(); - -template::value, bool> = true > -bool write(T& streamer, const ::unitree_go::msg::dds_::LowCmd_& instance, entity_properties_t *props) { - (void)instance; - if (!streamer.start_struct(*props)) - return false; - auto prop = streamer.first_entity(props); - while (prop) { - switch (prop->m_id) { - case 0: - if (!streamer.start_member(*prop)) - return false; - if (!streamer.start_consecutive(true, true)) - return false; - if (!write(streamer, instance.head()[0], instance.head().size())) - return false; - if (!streamer.finish_consecutive()) - return false; - if (!streamer.finish_member(*prop)) - return false; - break; - case 1: - if (!streamer.start_member(*prop)) - return false; - if (!write(streamer, instance.level_flag())) - return false; - if (!streamer.finish_member(*prop)) - return false; - break; - case 2: - if (!streamer.start_member(*prop)) - return false; - if (!write(streamer, instance.frame_reserve())) - return false; - if (!streamer.finish_member(*prop)) - return false; - break; - case 3: - if (!streamer.start_member(*prop)) - return false; - if (!streamer.start_consecutive(true, true)) - return false; - if (!write(streamer, instance.sn()[0], instance.sn().size())) - return false; - if (!streamer.finish_consecutive()) - return false; - if (!streamer.finish_member(*prop)) - return false; - break; - case 4: - if (!streamer.start_member(*prop)) - return false; - if (!streamer.start_consecutive(true, true)) - return false; - if (!write(streamer, instance.version()[0], instance.version().size())) - return false; - if (!streamer.finish_consecutive()) - return false; - if (!streamer.finish_member(*prop)) - return false; - break; - case 5: - if (!streamer.start_member(*prop)) - return false; - if (!write(streamer, instance.bandwidth())) - return false; - if (!streamer.finish_member(*prop)) - return false; - break; - case 6: - if (!streamer.start_member(*prop)) - return false; - if (!streamer.start_consecutive(true, false)) - return false; - for (const auto & a_1:instance.motor_cmd()) { //array depth 1 - if (!write(streamer, a_1, prop)) - return false; - } //array depth 1 - if (!streamer.finish_consecutive()) - return false; - if (!streamer.finish_member(*prop)) - return false; - break; - case 7: - if (!streamer.start_member(*prop)) - return false; - if (!write(streamer, instance.bms_cmd(), prop)) - return false; - if (!streamer.finish_member(*prop)) - return false; - break; - case 8: - if (!streamer.start_member(*prop)) - return false; - if (!streamer.start_consecutive(true, true)) - return false; - if (!write(streamer, instance.wireless_remote()[0], instance.wireless_remote().size())) - return false; - if (!streamer.finish_consecutive()) - return false; - if (!streamer.finish_member(*prop)) - return false; - break; - case 9: - if (!streamer.start_member(*prop)) - return false; - if (!streamer.start_consecutive(true, true)) - return false; - if (!write(streamer, instance.led()[0], instance.led().size())) - return false; - if (!streamer.finish_consecutive()) - return false; - if (!streamer.finish_member(*prop)) - return false; - break; - case 10: - if (!streamer.start_member(*prop)) - return false; - if (!streamer.start_consecutive(true, true)) - return false; - if (!write(streamer, instance.fan()[0], instance.fan().size())) - return false; - if (!streamer.finish_consecutive()) - return false; - if (!streamer.finish_member(*prop)) - return false; - break; - case 11: - if (!streamer.start_member(*prop)) - return false; - if (!write(streamer, instance.gpio())) - return false; - if (!streamer.finish_member(*prop)) - return false; - break; - case 12: - if (!streamer.start_member(*prop)) - return false; - if (!write(streamer, instance.reserve())) - return false; - if (!streamer.finish_member(*prop)) - return false; - break; - case 13: - if (!streamer.start_member(*prop)) - return false; - if (!write(streamer, instance.crc())) - return false; - if (!streamer.finish_member(*prop)) - return false; - break; - } - prop = streamer.next_entity(prop); - } - return streamer.finish_struct(*props); -} - -template::value, bool> = true > -bool write(S& str, const ::unitree_go::msg::dds_::LowCmd_& instance, bool as_key) { - auto &props = get_type_props<::unitree_go::msg::dds_::LowCmd_>(); - str.set_mode(cdr_stream::stream_mode::write, as_key); - return write(str, instance, props.data()); -} - -template::value, bool> = true > -bool read(T& streamer, ::unitree_go::msg::dds_::LowCmd_& instance, entity_properties_t *props) { - (void)instance; - if (!streamer.start_struct(*props)) - return false; - auto prop = streamer.first_entity(props); - while (prop) { - switch (prop->m_id) { - case 0: - if (!streamer.start_member(*prop)) - return false; - if (!streamer.start_consecutive(true, true)) - return false; - if (!read(streamer, instance.head()[0], instance.head().size())) - return false; - if (!streamer.finish_consecutive()) - return false; - if (!streamer.finish_member(*prop)) - return false; - break; - case 1: - if (!streamer.start_member(*prop)) - return false; - if (!read(streamer, instance.level_flag())) - return false; - if (!streamer.finish_member(*prop)) - return false; - break; - case 2: - if (!streamer.start_member(*prop)) - return false; - if (!read(streamer, instance.frame_reserve())) - return false; - if (!streamer.finish_member(*prop)) - return false; - break; - case 3: - if (!streamer.start_member(*prop)) - return false; - if (!streamer.start_consecutive(true, true)) - return false; - if (!read(streamer, instance.sn()[0], instance.sn().size())) - return false; - if (!streamer.finish_consecutive()) - return false; - if (!streamer.finish_member(*prop)) - return false; - break; - case 4: - if (!streamer.start_member(*prop)) - return false; - if (!streamer.start_consecutive(true, true)) - return false; - if (!read(streamer, instance.version()[0], instance.version().size())) - return false; - if (!streamer.finish_consecutive()) - return false; - if (!streamer.finish_member(*prop)) - return false; - break; - case 5: - if (!streamer.start_member(*prop)) - return false; - if (!read(streamer, instance.bandwidth())) - return false; - if (!streamer.finish_member(*prop)) - return false; - break; - case 6: - if (!streamer.start_member(*prop)) - return false; - if (!streamer.start_consecutive(true, false)) - return false; - for (auto & a_1:instance.motor_cmd()) { //array depth 1 - if (!read(streamer, a_1, prop)) - return false; - } //array depth 1 - if (!streamer.finish_consecutive()) - return false; - if (!streamer.finish_member(*prop)) - return false; - break; - case 7: - if (!streamer.start_member(*prop)) - return false; - if (!read(streamer, instance.bms_cmd(), prop)) - return false; - if (!streamer.finish_member(*prop)) - return false; - break; - case 8: - if (!streamer.start_member(*prop)) - return false; - if (!streamer.start_consecutive(true, true)) - return false; - if (!read(streamer, instance.wireless_remote()[0], instance.wireless_remote().size())) - return false; - if (!streamer.finish_consecutive()) - return false; - if (!streamer.finish_member(*prop)) - return false; - break; - case 9: - if (!streamer.start_member(*prop)) - return false; - if (!streamer.start_consecutive(true, true)) - return false; - if (!read(streamer, instance.led()[0], instance.led().size())) - return false; - if (!streamer.finish_consecutive()) - return false; - if (!streamer.finish_member(*prop)) - return false; - break; - case 10: - if (!streamer.start_member(*prop)) - return false; - if (!streamer.start_consecutive(true, true)) - return false; - if (!read(streamer, instance.fan()[0], instance.fan().size())) - return false; - if (!streamer.finish_consecutive()) - return false; - if (!streamer.finish_member(*prop)) - return false; - break; - case 11: - if (!streamer.start_member(*prop)) - return false; - if (!read(streamer, instance.gpio())) - return false; - if (!streamer.finish_member(*prop)) - return false; - break; - case 12: - if (!streamer.start_member(*prop)) - return false; - if (!read(streamer, instance.reserve())) - return false; - if (!streamer.finish_member(*prop)) - return false; - break; - case 13: - if (!streamer.start_member(*prop)) - return false; - if (!read(streamer, instance.crc())) - return false; - if (!streamer.finish_member(*prop)) - return false; - break; - } - prop = streamer.next_entity(prop); - } - return streamer.finish_struct(*props); -} - -template::value, bool> = true > -bool read(S& str, ::unitree_go::msg::dds_::LowCmd_& instance, bool as_key) { - auto &props = get_type_props<::unitree_go::msg::dds_::LowCmd_>(); - str.set_mode(cdr_stream::stream_mode::read, as_key); - return read(str, instance, props.data()); -} - -template::value, bool> = true > -bool move(T& streamer, const ::unitree_go::msg::dds_::LowCmd_& instance, entity_properties_t *props) { - (void)instance; - if (!streamer.start_struct(*props)) - return false; - auto prop = streamer.first_entity(props); - while (prop) { - switch (prop->m_id) { - case 0: - if (!streamer.start_member(*prop)) - return false; - if (!streamer.start_consecutive(true, true)) - return false; - if (!move(streamer, instance.head()[0], instance.head().size())) - return false; - if (!streamer.finish_consecutive()) - return false; - if (!streamer.finish_member(*prop)) - return false; - break; - case 1: - if (!streamer.start_member(*prop)) - return false; - if (!move(streamer, instance.level_flag())) - return false; - if (!streamer.finish_member(*prop)) - return false; - break; - case 2: - if (!streamer.start_member(*prop)) - return false; - if (!move(streamer, instance.frame_reserve())) - return false; - if (!streamer.finish_member(*prop)) - return false; - break; - case 3: - if (!streamer.start_member(*prop)) - return false; - if (!streamer.start_consecutive(true, true)) - return false; - if (!move(streamer, instance.sn()[0], instance.sn().size())) - return false; - if (!streamer.finish_consecutive()) - return false; - if (!streamer.finish_member(*prop)) - return false; - break; - case 4: - if (!streamer.start_member(*prop)) - return false; - if (!streamer.start_consecutive(true, true)) - return false; - if (!move(streamer, instance.version()[0], instance.version().size())) - return false; - if (!streamer.finish_consecutive()) - return false; - if (!streamer.finish_member(*prop)) - return false; - break; - case 5: - if (!streamer.start_member(*prop)) - return false; - if (!move(streamer, instance.bandwidth())) - return false; - if (!streamer.finish_member(*prop)) - return false; - break; - case 6: - if (!streamer.start_member(*prop)) - return false; - if (!streamer.start_consecutive(true, false)) - return false; - for (const auto & a_1:instance.motor_cmd()) { //array depth 1 - if (!move(streamer, a_1, prop)) - return false; - } //array depth 1 - if (!streamer.finish_consecutive()) - return false; - if (!streamer.finish_member(*prop)) - return false; - break; - case 7: - if (!streamer.start_member(*prop)) - return false; - if (!move(streamer, instance.bms_cmd(), prop)) - return false; - if (!streamer.finish_member(*prop)) - return false; - break; - case 8: - if (!streamer.start_member(*prop)) - return false; - if (!streamer.start_consecutive(true, true)) - return false; - if (!move(streamer, instance.wireless_remote()[0], instance.wireless_remote().size())) - return false; - if (!streamer.finish_consecutive()) - return false; - if (!streamer.finish_member(*prop)) - return false; - break; - case 9: - if (!streamer.start_member(*prop)) - return false; - if (!streamer.start_consecutive(true, true)) - return false; - if (!move(streamer, instance.led()[0], instance.led().size())) - return false; - if (!streamer.finish_consecutive()) - return false; - if (!streamer.finish_member(*prop)) - return false; - break; - case 10: - if (!streamer.start_member(*prop)) - return false; - if (!streamer.start_consecutive(true, true)) - return false; - if (!move(streamer, instance.fan()[0], instance.fan().size())) - return false; - if (!streamer.finish_consecutive()) - return false; - if (!streamer.finish_member(*prop)) - return false; - break; - case 11: - if (!streamer.start_member(*prop)) - return false; - if (!move(streamer, instance.gpio())) - return false; - if (!streamer.finish_member(*prop)) - return false; - break; - case 12: - if (!streamer.start_member(*prop)) - return false; - if (!move(streamer, instance.reserve())) - return false; - if (!streamer.finish_member(*prop)) - return false; - break; - case 13: - if (!streamer.start_member(*prop)) - return false; - if (!move(streamer, instance.crc())) - return false; - if (!streamer.finish_member(*prop)) - return false; - break; - } - prop = streamer.next_entity(prop); - } - return streamer.finish_struct(*props); -} - -template::value, bool> = true > -bool move(S& str, const ::unitree_go::msg::dds_::LowCmd_& instance, bool as_key) { - auto &props = get_type_props<::unitree_go::msg::dds_::LowCmd_>(); - str.set_mode(cdr_stream::stream_mode::move, as_key); - return move(str, instance, props.data()); -} - -template::value, bool> = true > -bool max(T& streamer, const ::unitree_go::msg::dds_::LowCmd_& instance, entity_properties_t *props) { - (void)instance; - if (!streamer.start_struct(*props)) - return false; - auto prop = streamer.first_entity(props); - while (prop) { - switch (prop->m_id) { - case 0: - if (!streamer.start_member(*prop)) - return false; - if (!streamer.start_consecutive(true, true)) - return false; - if (!max(streamer, instance.head()[0], instance.head().size())) - return false; - if (!streamer.finish_consecutive()) - return false; - if (!streamer.finish_member(*prop)) - return false; - break; - case 1: - if (!streamer.start_member(*prop)) - return false; - if (!max(streamer, instance.level_flag())) - return false; - if (!streamer.finish_member(*prop)) - return false; - break; - case 2: - if (!streamer.start_member(*prop)) - return false; - if (!max(streamer, instance.frame_reserve())) - return false; - if (!streamer.finish_member(*prop)) - return false; - break; - case 3: - if (!streamer.start_member(*prop)) - return false; - if (!streamer.start_consecutive(true, true)) - return false; - if (!max(streamer, instance.sn()[0], instance.sn().size())) - return false; - if (!streamer.finish_consecutive()) - return false; - if (!streamer.finish_member(*prop)) - return false; - break; - case 4: - if (!streamer.start_member(*prop)) - return false; - if (!streamer.start_consecutive(true, true)) - return false; - if (!max(streamer, instance.version()[0], instance.version().size())) - return false; - if (!streamer.finish_consecutive()) - return false; - if (!streamer.finish_member(*prop)) - return false; - break; - case 5: - if (!streamer.start_member(*prop)) - return false; - if (!max(streamer, instance.bandwidth())) - return false; - if (!streamer.finish_member(*prop)) - return false; - break; - case 6: - if (!streamer.start_member(*prop)) - return false; - if (!streamer.start_consecutive(true, false)) - return false; - for (const auto & a_1:instance.motor_cmd()) { //array depth 1 - if (!max(streamer, a_1, prop)) - return false; - } //array depth 1 - if (!streamer.finish_consecutive()) - return false; - if (!streamer.finish_member(*prop)) - return false; - break; - case 7: - if (!streamer.start_member(*prop)) - return false; - if (!max(streamer, instance.bms_cmd(), prop)) - return false; - if (!streamer.finish_member(*prop)) - return false; - break; - case 8: - if (!streamer.start_member(*prop)) - return false; - if (!streamer.start_consecutive(true, true)) - return false; - if (!max(streamer, instance.wireless_remote()[0], instance.wireless_remote().size())) - return false; - if (!streamer.finish_consecutive()) - return false; - if (!streamer.finish_member(*prop)) - return false; - break; - case 9: - if (!streamer.start_member(*prop)) - return false; - if (!streamer.start_consecutive(true, true)) - return false; - if (!max(streamer, instance.led()[0], instance.led().size())) - return false; - if (!streamer.finish_consecutive()) - return false; - if (!streamer.finish_member(*prop)) - return false; - break; - case 10: - if (!streamer.start_member(*prop)) - return false; - if (!streamer.start_consecutive(true, true)) - return false; - if (!max(streamer, instance.fan()[0], instance.fan().size())) - return false; - if (!streamer.finish_consecutive()) - return false; - if (!streamer.finish_member(*prop)) - return false; - break; - case 11: - if (!streamer.start_member(*prop)) - return false; - if (!max(streamer, instance.gpio())) - return false; - if (!streamer.finish_member(*prop)) - return false; - break; - case 12: - if (!streamer.start_member(*prop)) - return false; - if (!max(streamer, instance.reserve())) - return false; - if (!streamer.finish_member(*prop)) - return false; - break; - case 13: - if (!streamer.start_member(*prop)) - return false; - if (!max(streamer, instance.crc())) - return false; - if (!streamer.finish_member(*prop)) - return false; - break; - } - prop = streamer.next_entity(prop); - } - return streamer.finish_struct(*props); -} - -template::value, bool> = true > -bool max(S& str, const ::unitree_go::msg::dds_::LowCmd_& instance, bool as_key) { - auto &props = get_type_props<::unitree_go::msg::dds_::LowCmd_>(); - str.set_mode(cdr_stream::stream_mode::max, as_key); - return max(str, instance, props.data()); -} - -} //namespace cdr -} //namespace core -} //namespace cyclonedds -} //namespace eclipse -} //namespace org - -#endif // DDSCXX_LOWCMD__HPP diff --git a/cpp_bridge/include/unitree/idl/go2/LowCmd_.hpp b/cpp_bridge/include/unitree/idl/go2/LowCmd_.hpp index 11ccacd..24df6da 100644 --- a/cpp_bridge/include/unitree/idl/go2/LowCmd_.hpp +++ b/cpp_bridge/include/unitree/idl/go2/LowCmd_.hpp @@ -9,6 +9,10 @@ #ifndef DDSCXX_LOWCMD__HPP #define DDSCXX_LOWCMD__HPP +#include "BmsCmd_.hpp" + +#include "MotorCmd_.hpp" + #include #include @@ -18,115 +22,6 @@ namespace msg { namespace dds_ { -class MotorCmd_ -{ -private: - uint8_t mode_ = 0; - float q_ = 0.0f; - float dq_ = 0.0f; - float tau_ = 0.0f; - float kp_ = 0.0f; - float kd_ = 0.0f; - std::array reserve_ = { }; - -public: - MotorCmd_() = default; - - explicit MotorCmd_( - uint8_t mode, - float q, - float dq, - float tau, - float kp, - float kd, - const std::array& reserve) : - mode_(mode), - q_(q), - dq_(dq), - tau_(tau), - kp_(kp), - kd_(kd), - reserve_(reserve) { } - - uint8_t mode() const { return this->mode_; } - uint8_t& mode() { return this->mode_; } - void mode(uint8_t _val_) { this->mode_ = _val_; } - float q() const { return this->q_; } - float& q() { return this->q_; } - void q(float _val_) { this->q_ = _val_; } - float dq() const { return this->dq_; } - float& dq() { return this->dq_; } - void dq(float _val_) { this->dq_ = _val_; } - float tau() const { return this->tau_; } - float& tau() { return this->tau_; } - void tau(float _val_) { this->tau_ = _val_; } - float kp() const { return this->kp_; } - float& kp() { return this->kp_; } - void kp(float _val_) { this->kp_ = _val_; } - float kd() const { return this->kd_; } - float& kd() { return this->kd_; } - void kd(float _val_) { this->kd_ = _val_; } - const std::array& reserve() const { return this->reserve_; } - std::array& reserve() { return this->reserve_; } - void reserve(const std::array& _val_) { this->reserve_ = _val_; } - void reserve(std::array&& _val_) { this->reserve_ = _val_; } - - bool operator==(const MotorCmd_& _other) const - { - (void) _other; - return mode_ == _other.mode_ && - q_ == _other.q_ && - dq_ == _other.dq_ && - tau_ == _other.tau_ && - kp_ == _other.kp_ && - kd_ == _other.kd_ && - reserve_ == _other.reserve_; - } - - bool operator!=(const MotorCmd_& _other) const - { - return !(*this == _other); - } - -}; - -class BmsCmd_ -{ -private: - uint8_t off_ = 0; - std::array reserve_ = { }; - -public: - BmsCmd_() = default; - - explicit BmsCmd_( - uint8_t off, - const std::array& reserve) : - off_(off), - reserve_(reserve) { } - - uint8_t off() const { return this->off_; } - uint8_t& off() { return this->off_; } - void off(uint8_t _val_) { this->off_ = _val_; } - const std::array& reserve() const { return this->reserve_; } - std::array& reserve() { return this->reserve_; } - void reserve(const std::array& _val_) { this->reserve_ = _val_; } - void reserve(std::array&& _val_) { this->reserve_ = _val_; } - - bool operator==(const BmsCmd_& _other) const - { - (void) _other; - return off_ == _other.off_ && - reserve_ == _other.reserve_; - } - - bool operator!=(const BmsCmd_& _other) const - { - return !(*this == _other); - } - -}; - class LowCmd_ { private: @@ -135,7 +30,7 @@ private: uint8_t frame_reserve_ = 0; std::array sn_ = { }; std::array version_ = { }; - int16_t bandwidth_ = 0; + uint16_t bandwidth_ = 0; std::array<::unitree_go::msg::dds_::MotorCmd_, 20> motor_cmd_ = { }; ::unitree_go::msg::dds_::BmsCmd_ bms_cmd_; std::array wireless_remote_ = { }; @@ -154,7 +49,7 @@ public: uint8_t frame_reserve, const std::array& sn, const std::array& version, - int16_t bandwidth, + uint16_t bandwidth, const std::array<::unitree_go::msg::dds_::MotorCmd_, 20>& motor_cmd, const ::unitree_go::msg::dds_::BmsCmd_& bms_cmd, const std::array& wireless_remote, @@ -196,9 +91,9 @@ public: std::array& version() { return this->version_; } void version(const std::array& _val_) { this->version_ = _val_; } void version(std::array&& _val_) { this->version_ = _val_; } - int16_t bandwidth() const { return this->bandwidth_; } - int16_t& bandwidth() { return this->bandwidth_; } - void bandwidth(int16_t _val_) { this->bandwidth_ = _val_; } + uint16_t bandwidth() const { return this->bandwidth_; } + uint16_t& bandwidth() { return this->bandwidth_; } + void bandwidth(uint16_t _val_) { this->bandwidth_ = _val_; } const std::array<::unitree_go::msg::dds_::MotorCmd_, 20>& motor_cmd() const { return this->motor_cmd_; } std::array<::unitree_go::msg::dds_::MotorCmd_, 20>& motor_cmd() { return this->motor_cmd_; } void motor_cmd(const std::array<::unitree_go::msg::dds_::MotorCmd_, 20>& _val_) { this->motor_cmd_ = _val_; } @@ -269,114 +164,6 @@ namespace eclipse { namespace cyclonedds { namespace topic { -template <> constexpr const char* TopicTraits<::unitree_go::msg::dds_::MotorCmd_>::getTypeName() -{ - return "unitree_go::msg::dds_::MotorCmd_"; -} - -template <> constexpr bool TopicTraits<::unitree_go::msg::dds_::MotorCmd_>::isKeyless() -{ - return true; -} - -#ifdef DDSCXX_HAS_TYPE_DISCOVERY -template<> constexpr unsigned int TopicTraits<::unitree_go::msg::dds_::MotorCmd_>::type_map_blob_sz() { return 478; } -template<> constexpr unsigned int TopicTraits<::unitree_go::msg::dds_::MotorCmd_>::type_info_blob_sz() { return 100; } -template<> inline const uint8_t * TopicTraits<::unitree_go::msg::dds_::MotorCmd_>::type_map_blob() { - static const uint8_t blob[] = { - 0xa6, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0xf1, 0xc8, 0xe5, 0x83, 0x5b, 0x0f, 0x0c, 0x17, - 0x65, 0xbc, 0x23, 0x1d, 0xfa, 0x02, 0xff, 0x00, 0x8e, 0x00, 0x00, 0x00, 0xf1, 0x51, 0x01, 0x00, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, - 0x0b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x15, 0xd6, 0x17, 0x12, 0x00, - 0x0b, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x09, 0x76, 0x94, 0xf4, 0xa6, 0x00, - 0x0b, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x09, 0x47, 0xbc, 0xdc, 0xd7, 0x00, - 0x0b, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x09, 0x45, 0x80, 0xc2, 0x74, 0x00, - 0x0b, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x09, 0x26, 0xb5, 0x68, 0xe4, 0x00, - 0x0b, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x01, 0x00, 0x09, 0x87, 0x22, 0x16, 0x52, 0x00, - 0x16, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x01, 0x00, 0x90, 0xf3, 0x01, 0x00, 0x00, 0x00, - 0x01, 0x00, 0x00, 0x00, 0x03, 0x07, 0x9c, 0x3b, 0x62, 0x94, 0x00, 0x00, 0x06, 0x01, 0x00, 0x00, - 0x01, 0x00, 0x00, 0x00, 0xf2, 0x42, 0x1f, 0xa5, 0xb2, 0xdb, 0x2d, 0xef, 0xf5, 0xc0, 0x3f, 0xff, - 0x16, 0x30, 0x3b, 0x00, 0xee, 0x00, 0x00, 0x00, 0xf2, 0x51, 0x01, 0x00, 0x29, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, 0x75, 0x6e, 0x69, 0x74, 0x72, 0x65, 0x65, 0x5f, - 0x67, 0x6f, 0x3a, 0x3a, 0x6d, 0x73, 0x67, 0x3a, 0x3a, 0x64, 0x64, 0x73, 0x5f, 0x3a, 0x3a, 0x4d, - 0x6f, 0x74, 0x6f, 0x72, 0x43, 0x6d, 0x64, 0x5f, 0x00, 0x00, 0x00, 0x00, 0xb6, 0x00, 0x00, 0x00, - 0x07, 0x00, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, - 0x05, 0x00, 0x00, 0x00, 0x6d, 0x6f, 0x64, 0x65, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, - 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x09, 0x00, 0x02, 0x00, 0x00, 0x00, 0x71, 0x00, 0x00, 0x00, - 0x11, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x09, 0x00, 0x03, 0x00, 0x00, 0x00, - 0x64, 0x71, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x12, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, - 0x01, 0x00, 0x09, 0x00, 0x04, 0x00, 0x00, 0x00, 0x74, 0x61, 0x75, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x11, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x09, 0x00, 0x03, 0x00, 0x00, 0x00, - 0x6b, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, - 0x01, 0x00, 0x09, 0x00, 0x03, 0x00, 0x00, 0x00, 0x6b, 0x64, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x22, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x01, 0x00, 0x90, 0xf3, 0x01, 0x00, 0x00, 0x00, - 0x01, 0x00, 0x00, 0x00, 0x03, 0x07, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x72, 0x65, 0x73, 0x65, - 0x72, 0x76, 0x65, 0x00, 0x00, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, - 0xf2, 0x42, 0x1f, 0xa5, 0xb2, 0xdb, 0x2d, 0xef, 0xf5, 0xc0, 0x3f, 0xff, 0x16, 0x30, 0x3b, 0xf1, - 0xc8, 0xe5, 0x83, 0x5b, 0x0f, 0x0c, 0x17, 0x65, 0xbc, 0x23, 0x1d, 0xfa, 0x02, 0xff, }; - return blob; -} -template<> inline const uint8_t * TopicTraits<::unitree_go::msg::dds_::MotorCmd_>::type_info_blob() { - static const uint8_t blob[] = { - 0x60, 0x00, 0x00, 0x00, 0x01, 0x10, 0x00, 0x40, 0x28, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, - 0x14, 0x00, 0x00, 0x00, 0xf1, 0xc8, 0xe5, 0x83, 0x5b, 0x0f, 0x0c, 0x17, 0x65, 0xbc, 0x23, 0x1d, - 0xfa, 0x02, 0xff, 0x00, 0x92, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x02, 0x10, 0x00, 0x40, 0x28, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, - 0x14, 0x00, 0x00, 0x00, 0xf2, 0x42, 0x1f, 0xa5, 0xb2, 0xdb, 0x2d, 0xef, 0xf5, 0xc0, 0x3f, 0xff, - 0x16, 0x30, 0x3b, 0x00, 0xf2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, }; - return blob; -} -#endif //DDSCXX_HAS_TYPE_DISCOVERY - -template <> constexpr const char* TopicTraits<::unitree_go::msg::dds_::BmsCmd_>::getTypeName() -{ - return "unitree_go::msg::dds_::BmsCmd_"; -} - -template <> constexpr bool TopicTraits<::unitree_go::msg::dds_::BmsCmd_>::isKeyless() -{ - return true; -} - -#ifdef DDSCXX_HAS_TYPE_DISCOVERY -template<> constexpr unsigned int TopicTraits<::unitree_go::msg::dds_::BmsCmd_>::type_map_blob_sz() { return 278; } -template<> constexpr unsigned int TopicTraits<::unitree_go::msg::dds_::BmsCmd_>::type_info_blob_sz() { return 100; } -template<> inline const uint8_t * TopicTraits<::unitree_go::msg::dds_::BmsCmd_>::type_map_blob() { - static const uint8_t blob[] = { - 0x56, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0xf1, 0x3e, 0x8e, 0xb6, 0x7c, 0x25, 0xfd, 0xe0, - 0x7e, 0x52, 0xcf, 0x51, 0xed, 0x4a, 0x23, 0x00, 0x3e, 0x00, 0x00, 0x00, 0xf1, 0x51, 0x01, 0x00, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2e, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, - 0x0b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x32, 0x62, 0xd4, 0x8d, 0x00, - 0x16, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x90, 0xf3, 0x01, 0x00, 0x00, 0x00, - 0x01, 0x00, 0x00, 0x00, 0x03, 0x02, 0x9c, 0x3b, 0x62, 0x94, 0x00, 0x00, 0x8e, 0x00, 0x00, 0x00, - 0x01, 0x00, 0x00, 0x00, 0xf2, 0x31, 0xa8, 0x59, 0x24, 0x05, 0x6b, 0x7a, 0xf3, 0xd3, 0xf1, 0x6b, - 0x34, 0x22, 0x33, 0x00, 0x76, 0x00, 0x00, 0x00, 0xf2, 0x51, 0x01, 0x00, 0x27, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x75, 0x6e, 0x69, 0x74, 0x72, 0x65, 0x65, 0x5f, - 0x67, 0x6f, 0x3a, 0x3a, 0x6d, 0x73, 0x67, 0x3a, 0x3a, 0x64, 0x64, 0x73, 0x5f, 0x3a, 0x3a, 0x42, - 0x6d, 0x73, 0x43, 0x6d, 0x64, 0x5f, 0x00, 0x00, 0x42, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, - 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x04, 0x00, 0x00, 0x00, - 0x6f, 0x66, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, - 0x01, 0x00, 0x90, 0xf3, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, 0x02, 0x00, 0x00, - 0x08, 0x00, 0x00, 0x00, 0x72, 0x65, 0x73, 0x65, 0x72, 0x76, 0x65, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x22, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0xf2, 0x31, 0xa8, 0x59, 0x24, 0x05, 0x6b, 0x7a, - 0xf3, 0xd3, 0xf1, 0x6b, 0x34, 0x22, 0x33, 0xf1, 0x3e, 0x8e, 0xb6, 0x7c, 0x25, 0xfd, 0xe0, 0x7e, - 0x52, 0xcf, 0x51, 0xed, 0x4a, 0x23, }; - return blob; -} -template<> inline const uint8_t * TopicTraits<::unitree_go::msg::dds_::BmsCmd_>::type_info_blob() { - static const uint8_t blob[] = { - 0x60, 0x00, 0x00, 0x00, 0x01, 0x10, 0x00, 0x40, 0x28, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, - 0x14, 0x00, 0x00, 0x00, 0xf1, 0x3e, 0x8e, 0xb6, 0x7c, 0x25, 0xfd, 0xe0, 0x7e, 0x52, 0xcf, 0x51, - 0xed, 0x4a, 0x23, 0x00, 0x42, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x02, 0x10, 0x00, 0x40, 0x28, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, - 0x14, 0x00, 0x00, 0x00, 0xf2, 0x31, 0xa8, 0x59, 0x24, 0x05, 0x6b, 0x7a, 0xf3, 0xd3, 0xf1, 0x6b, - 0x34, 0x22, 0x33, 0x00, 0x7a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, }; - return blob; -} -#endif //DDSCXX_HAS_TYPE_DISCOVERY - template <> constexpr const char* TopicTraits<::unitree_go::msg::dds_::LowCmd_>::getTypeName() { return "unitree_go::msg::dds_::LowCmd_"; @@ -392,8 +179,8 @@ template<> constexpr unsigned int TopicTraits<::unitree_go::msg::dds_::LowCmd_>: template<> constexpr unsigned int TopicTraits<::unitree_go::msg::dds_::LowCmd_>::type_info_blob_sz() { return 196; } template<> inline const uint8_t * TopicTraits<::unitree_go::msg::dds_::LowCmd_>::type_map_blob() { static const uint8_t blob[] = { - 0x72, 0x02, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0xf1, 0xe7, 0x53, 0x69, 0x89, 0x3d, 0x2a, 0x83, - 0x5c, 0x43, 0x1d, 0x5a, 0x56, 0x4e, 0x4d, 0x00, 0x63, 0x01, 0x00, 0x00, 0xf1, 0x51, 0x01, 0x00, + 0x72, 0x02, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0xf1, 0x83, 0x28, 0x76, 0xce, 0xec, 0x97, 0x37, + 0xd6, 0x9f, 0x6e, 0xd6, 0x2a, 0x3f, 0x63, 0x00, 0x63, 0x01, 0x00, 0x00, 0xf1, 0x51, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x53, 0x01, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x16, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x90, 0xf3, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x02, 0x96, 0xe8, 0x9a, 0x29, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, @@ -402,7 +189,7 @@ template<> inline const uint8_t * TopicTraits<::unitree_go::msg::dds_::LowCmd_>: 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x90, 0xf3, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x07, 0xaf, 0xbe, 0x94, 0xcd, 0x00, 0x00, 0x16, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x90, 0xf3, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x07, 0x2a, 0xf7, - 0x2f, 0x10, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x01, 0x00, 0x03, 0x36, + 0x2f, 0x10, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x01, 0x00, 0x06, 0x36, 0x67, 0x6c, 0x2b, 0x00, 0x24, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x01, 0x00, 0x90, 0xf1, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x14, 0xf1, 0xc8, 0xe5, 0x83, 0x5b, 0x0f, 0x0c, 0x17, 0x65, 0xbc, 0x23, 0x1d, 0xfa, 0x02, 0xff, 0x5b, 0xcf, 0x19, 0xa4, 0x19, 0x00, 0x00, 0x00, @@ -432,7 +219,7 @@ template<> inline const uint8_t * TopicTraits<::unitree_go::msg::dds_::LowCmd_>: 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x32, 0x62, 0xd4, 0x8d, 0x00, 0x16, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x90, 0xf3, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, 0x02, 0x9c, 0x3b, 0x62, 0x94, 0x00, 0x00, 0xce, 0x03, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, - 0xf2, 0xf6, 0x9c, 0x3d, 0x59, 0xff, 0x30, 0xa9, 0xc6, 0xdf, 0xfe, 0xcf, 0x3c, 0x04, 0x12, 0x00, + 0xf2, 0x52, 0xcc, 0x8e, 0xb0, 0xd4, 0x27, 0xd6, 0x92, 0xaa, 0x2b, 0x20, 0xa9, 0x05, 0x40, 0x00, 0x26, 0x02, 0x00, 0x00, 0xf2, 0x51, 0x01, 0x00, 0x27, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x75, 0x6e, 0x69, 0x74, 0x72, 0x65, 0x65, 0x5f, 0x67, 0x6f, 0x3a, 0x3a, 0x6d, 0x73, 0x67, 0x3a, 0x3a, 0x64, 0x64, 0x73, 0x5f, 0x3a, 0x3a, 0x4c, 0x6f, 0x77, 0x43, 0x6d, @@ -448,7 +235,7 @@ template<> inline const uint8_t * TopicTraits<::unitree_go::msg::dds_::LowCmd_>: 0x00, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x90, 0xf3, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x07, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, - 0x05, 0x00, 0x00, 0x00, 0x01, 0x00, 0x03, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x62, 0x61, 0x6e, 0x64, + 0x05, 0x00, 0x00, 0x00, 0x01, 0x00, 0x06, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x62, 0x61, 0x6e, 0x64, 0x77, 0x69, 0x64, 0x74, 0x68, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x01, 0x00, 0x90, 0xf2, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x14, 0xf2, 0x42, 0x1f, 0xa5, 0xb2, 0xdb, 0x2d, 0xef, 0xf5, 0xc0, 0x3f, 0xff, 0x16, 0x30, 0x3b, 0x0a, 0x00, 0x00, 0x00, @@ -493,9 +280,9 @@ template<> inline const uint8_t * TopicTraits<::unitree_go::msg::dds_::LowCmd_>: 0x00, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x90, 0xf3, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, 0x02, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x72, 0x65, 0x73, 0x65, 0x72, 0x76, 0x65, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5e, 0x00, 0x00, 0x00, - 0x03, 0x00, 0x00, 0x00, 0xf2, 0xf6, 0x9c, 0x3d, 0x59, 0xff, 0x30, 0xa9, 0xc6, 0xdf, 0xfe, 0xcf, - 0x3c, 0x04, 0x12, 0xf1, 0xe7, 0x53, 0x69, 0x89, 0x3d, 0x2a, 0x83, 0x5c, 0x43, 0x1d, 0x5a, 0x56, - 0x4e, 0x4d, 0xf2, 0x42, 0x1f, 0xa5, 0xb2, 0xdb, 0x2d, 0xef, 0xf5, 0xc0, 0x3f, 0xff, 0x16, 0x30, + 0x03, 0x00, 0x00, 0x00, 0xf2, 0x52, 0xcc, 0x8e, 0xb0, 0xd4, 0x27, 0xd6, 0x92, 0xaa, 0x2b, 0x20, + 0xa9, 0x05, 0x40, 0xf1, 0x83, 0x28, 0x76, 0xce, 0xec, 0x97, 0x37, 0xd6, 0x9f, 0x6e, 0xd6, 0x2a, + 0x3f, 0x63, 0xf2, 0x42, 0x1f, 0xa5, 0xb2, 0xdb, 0x2d, 0xef, 0xf5, 0xc0, 0x3f, 0xff, 0x16, 0x30, 0x3b, 0xf1, 0xc8, 0xe5, 0x83, 0x5b, 0x0f, 0x0c, 0x17, 0x65, 0xbc, 0x23, 0x1d, 0xfa, 0x02, 0xff, 0xf2, 0x31, 0xa8, 0x59, 0x24, 0x05, 0x6b, 0x7a, 0xf3, 0xd3, 0xf1, 0x6b, 0x34, 0x22, 0x33, 0xf1, 0x3e, 0x8e, 0xb6, 0x7c, 0x25, 0xfd, 0xe0, 0x7e, 0x52, 0xcf, 0x51, 0xed, 0x4a, 0x23, }; @@ -504,14 +291,14 @@ template<> inline const uint8_t * TopicTraits<::unitree_go::msg::dds_::LowCmd_>: template<> inline const uint8_t * TopicTraits<::unitree_go::msg::dds_::LowCmd_>::type_info_blob() { static const uint8_t blob[] = { 0xc0, 0x00, 0x00, 0x00, 0x01, 0x10, 0x00, 0x40, 0x58, 0x00, 0x00, 0x00, 0x54, 0x00, 0x00, 0x00, - 0x14, 0x00, 0x00, 0x00, 0xf1, 0xe7, 0x53, 0x69, 0x89, 0x3d, 0x2a, 0x83, 0x5c, 0x43, 0x1d, 0x5a, - 0x56, 0x4e, 0x4d, 0x00, 0x67, 0x01, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00, + 0x14, 0x00, 0x00, 0x00, 0xf1, 0x83, 0x28, 0x76, 0xce, 0xec, 0x97, 0x37, 0xd6, 0x9f, 0x6e, 0xd6, + 0x2a, 0x3f, 0x63, 0x00, 0x67, 0x01, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0xf1, 0xc8, 0xe5, 0x83, 0x5b, 0x0f, 0x0c, 0x17, 0x65, 0xbc, 0x23, 0x1d, 0xfa, 0x02, 0xff, 0x00, 0x92, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0xf1, 0x3e, 0x8e, 0xb6, 0x7c, 0x25, 0xfd, 0xe0, 0x7e, 0x52, 0xcf, 0x51, 0xed, 0x4a, 0x23, 0x00, 0x42, 0x00, 0x00, 0x00, 0x02, 0x10, 0x00, 0x40, 0x58, 0x00, 0x00, 0x00, 0x54, 0x00, 0x00, 0x00, - 0x14, 0x00, 0x00, 0x00, 0xf2, 0xf6, 0x9c, 0x3d, 0x59, 0xff, 0x30, 0xa9, 0xc6, 0xdf, 0xfe, 0xcf, - 0x3c, 0x04, 0x12, 0x00, 0x2a, 0x02, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00, + 0x14, 0x00, 0x00, 0x00, 0xf2, 0x52, 0xcc, 0x8e, 0xb0, 0xd4, 0x27, 0xd6, 0x92, 0xaa, 0x2b, 0x20, + 0xa9, 0x05, 0x40, 0x00, 0x2a, 0x02, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0xf2, 0x42, 0x1f, 0xa5, 0xb2, 0xdb, 0x2d, 0xef, 0xf5, 0xc0, 0x3f, 0xff, 0x16, 0x30, 0x3b, 0x00, 0xf2, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0xf2, 0x31, 0xa8, 0x59, 0x24, 0x05, 0x6b, 0x7a, 0xf3, 0xd3, 0xf1, 0x6b, 0x34, 0x22, 0x33, 0x00, @@ -528,24 +315,6 @@ template<> inline const uint8_t * TopicTraits<::unitree_go::msg::dds_::LowCmd_>: namespace dds { namespace topic { -template <> -struct topic_type_name<::unitree_go::msg::dds_::MotorCmd_> -{ - static std::string value() - { - return org::eclipse::cyclonedds::topic::TopicTraits<::unitree_go::msg::dds_::MotorCmd_>::getTypeName(); - } -}; - -template <> -struct topic_type_name<::unitree_go::msg::dds_::BmsCmd_> -{ - static std::string value() - { - return org::eclipse::cyclonedds::topic::TopicTraits<::unitree_go::msg::dds_::BmsCmd_>::getTypeName(); - } -}; - template <> struct topic_type_name<::unitree_go::msg::dds_::LowCmd_> { @@ -558,8 +327,6 @@ struct topic_type_name<::unitree_go::msg::dds_::LowCmd_> } } -REGISTER_TOPIC_TYPE(::unitree_go::msg::dds_::MotorCmd_) -REGISTER_TOPIC_TYPE(::unitree_go::msg::dds_::BmsCmd_) REGISTER_TOPIC_TYPE(::unitree_go::msg::dds_::LowCmd_) namespace org{ @@ -568,500 +335,6 @@ namespace cyclonedds{ namespace core{ namespace cdr{ -template<> -propvec &get_type_props<::unitree_go::msg::dds_::MotorCmd_>(); - -template::value, bool> = true > -bool write(T& streamer, const ::unitree_go::msg::dds_::MotorCmd_& instance, entity_properties_t *props) { - (void)instance; - if (!streamer.start_struct(*props)) - return false; - auto prop = streamer.first_entity(props); - while (prop) { - switch (prop->m_id) { - case 0: - if (!streamer.start_member(*prop)) - return false; - if (!write(streamer, instance.mode())) - return false; - if (!streamer.finish_member(*prop)) - return false; - break; - case 1: - if (!streamer.start_member(*prop)) - return false; - if (!write(streamer, instance.q())) - return false; - if (!streamer.finish_member(*prop)) - return false; - break; - case 2: - if (!streamer.start_member(*prop)) - return false; - if (!write(streamer, instance.dq())) - return false; - if (!streamer.finish_member(*prop)) - return false; - break; - case 3: - if (!streamer.start_member(*prop)) - return false; - if (!write(streamer, instance.tau())) - return false; - if (!streamer.finish_member(*prop)) - return false; - break; - case 4: - if (!streamer.start_member(*prop)) - return false; - if (!write(streamer, instance.kp())) - return false; - if (!streamer.finish_member(*prop)) - return false; - break; - case 5: - if (!streamer.start_member(*prop)) - return false; - if (!write(streamer, instance.kd())) - return false; - if (!streamer.finish_member(*prop)) - return false; - break; - case 6: - if (!streamer.start_member(*prop)) - return false; - if (!streamer.start_consecutive(true, true)) - return false; - if (!write(streamer, instance.reserve()[0], instance.reserve().size())) - return false; - if (!streamer.finish_consecutive()) - return false; - if (!streamer.finish_member(*prop)) - return false; - break; - } - prop = streamer.next_entity(prop); - } - return streamer.finish_struct(*props); -} - -template::value, bool> = true > -bool write(S& str, const ::unitree_go::msg::dds_::MotorCmd_& instance, bool as_key) { - auto &props = get_type_props<::unitree_go::msg::dds_::MotorCmd_>(); - str.set_mode(cdr_stream::stream_mode::write, as_key); - return write(str, instance, props.data()); -} - -template::value, bool> = true > -bool read(T& streamer, ::unitree_go::msg::dds_::MotorCmd_& instance, entity_properties_t *props) { - (void)instance; - if (!streamer.start_struct(*props)) - return false; - auto prop = streamer.first_entity(props); - while (prop) { - switch (prop->m_id) { - case 0: - if (!streamer.start_member(*prop)) - return false; - if (!read(streamer, instance.mode())) - return false; - if (!streamer.finish_member(*prop)) - return false; - break; - case 1: - if (!streamer.start_member(*prop)) - return false; - if (!read(streamer, instance.q())) - return false; - if (!streamer.finish_member(*prop)) - return false; - break; - case 2: - if (!streamer.start_member(*prop)) - return false; - if (!read(streamer, instance.dq())) - return false; - if (!streamer.finish_member(*prop)) - return false; - break; - case 3: - if (!streamer.start_member(*prop)) - return false; - if (!read(streamer, instance.tau())) - return false; - if (!streamer.finish_member(*prop)) - return false; - break; - case 4: - if (!streamer.start_member(*prop)) - return false; - if (!read(streamer, instance.kp())) - return false; - if (!streamer.finish_member(*prop)) - return false; - break; - case 5: - if (!streamer.start_member(*prop)) - return false; - if (!read(streamer, instance.kd())) - return false; - if (!streamer.finish_member(*prop)) - return false; - break; - case 6: - if (!streamer.start_member(*prop)) - return false; - if (!streamer.start_consecutive(true, true)) - return false; - if (!read(streamer, instance.reserve()[0], instance.reserve().size())) - return false; - if (!streamer.finish_consecutive()) - return false; - if (!streamer.finish_member(*prop)) - return false; - break; - } - prop = streamer.next_entity(prop); - } - return streamer.finish_struct(*props); -} - -template::value, bool> = true > -bool read(S& str, ::unitree_go::msg::dds_::MotorCmd_& instance, bool as_key) { - auto &props = get_type_props<::unitree_go::msg::dds_::MotorCmd_>(); - str.set_mode(cdr_stream::stream_mode::read, as_key); - return read(str, instance, props.data()); -} - -template::value, bool> = true > -bool move(T& streamer, const ::unitree_go::msg::dds_::MotorCmd_& instance, entity_properties_t *props) { - (void)instance; - if (!streamer.start_struct(*props)) - return false; - auto prop = streamer.first_entity(props); - while (prop) { - switch (prop->m_id) { - case 0: - if (!streamer.start_member(*prop)) - return false; - if (!move(streamer, instance.mode())) - return false; - if (!streamer.finish_member(*prop)) - return false; - break; - case 1: - if (!streamer.start_member(*prop)) - return false; - if (!move(streamer, instance.q())) - return false; - if (!streamer.finish_member(*prop)) - return false; - break; - case 2: - if (!streamer.start_member(*prop)) - return false; - if (!move(streamer, instance.dq())) - return false; - if (!streamer.finish_member(*prop)) - return false; - break; - case 3: - if (!streamer.start_member(*prop)) - return false; - if (!move(streamer, instance.tau())) - return false; - if (!streamer.finish_member(*prop)) - return false; - break; - case 4: - if (!streamer.start_member(*prop)) - return false; - if (!move(streamer, instance.kp())) - return false; - if (!streamer.finish_member(*prop)) - return false; - break; - case 5: - if (!streamer.start_member(*prop)) - return false; - if (!move(streamer, instance.kd())) - return false; - if (!streamer.finish_member(*prop)) - return false; - break; - case 6: - if (!streamer.start_member(*prop)) - return false; - if (!streamer.start_consecutive(true, true)) - return false; - if (!move(streamer, instance.reserve()[0], instance.reserve().size())) - return false; - if (!streamer.finish_consecutive()) - return false; - if (!streamer.finish_member(*prop)) - return false; - break; - } - prop = streamer.next_entity(prop); - } - return streamer.finish_struct(*props); -} - -template::value, bool> = true > -bool move(S& str, const ::unitree_go::msg::dds_::MotorCmd_& instance, bool as_key) { - auto &props = get_type_props<::unitree_go::msg::dds_::MotorCmd_>(); - str.set_mode(cdr_stream::stream_mode::move, as_key); - return move(str, instance, props.data()); -} - -template::value, bool> = true > -bool max(T& streamer, const ::unitree_go::msg::dds_::MotorCmd_& instance, entity_properties_t *props) { - (void)instance; - if (!streamer.start_struct(*props)) - return false; - auto prop = streamer.first_entity(props); - while (prop) { - switch (prop->m_id) { - case 0: - if (!streamer.start_member(*prop)) - return false; - if (!max(streamer, instance.mode())) - return false; - if (!streamer.finish_member(*prop)) - return false; - break; - case 1: - if (!streamer.start_member(*prop)) - return false; - if (!max(streamer, instance.q())) - return false; - if (!streamer.finish_member(*prop)) - return false; - break; - case 2: - if (!streamer.start_member(*prop)) - return false; - if (!max(streamer, instance.dq())) - return false; - if (!streamer.finish_member(*prop)) - return false; - break; - case 3: - if (!streamer.start_member(*prop)) - return false; - if (!max(streamer, instance.tau())) - return false; - if (!streamer.finish_member(*prop)) - return false; - break; - case 4: - if (!streamer.start_member(*prop)) - return false; - if (!max(streamer, instance.kp())) - return false; - if (!streamer.finish_member(*prop)) - return false; - break; - case 5: - if (!streamer.start_member(*prop)) - return false; - if (!max(streamer, instance.kd())) - return false; - if (!streamer.finish_member(*prop)) - return false; - break; - case 6: - if (!streamer.start_member(*prop)) - return false; - if (!streamer.start_consecutive(true, true)) - return false; - if (!max(streamer, instance.reserve()[0], instance.reserve().size())) - return false; - if (!streamer.finish_consecutive()) - return false; - if (!streamer.finish_member(*prop)) - return false; - break; - } - prop = streamer.next_entity(prop); - } - return streamer.finish_struct(*props); -} - -template::value, bool> = true > -bool max(S& str, const ::unitree_go::msg::dds_::MotorCmd_& instance, bool as_key) { - auto &props = get_type_props<::unitree_go::msg::dds_::MotorCmd_>(); - str.set_mode(cdr_stream::stream_mode::max, as_key); - return max(str, instance, props.data()); -} - -template<> -propvec &get_type_props<::unitree_go::msg::dds_::BmsCmd_>(); - -template::value, bool> = true > -bool write(T& streamer, const ::unitree_go::msg::dds_::BmsCmd_& instance, entity_properties_t *props) { - (void)instance; - if (!streamer.start_struct(*props)) - return false; - auto prop = streamer.first_entity(props); - while (prop) { - switch (prop->m_id) { - case 0: - if (!streamer.start_member(*prop)) - return false; - if (!write(streamer, instance.off())) - return false; - if (!streamer.finish_member(*prop)) - return false; - break; - case 1: - if (!streamer.start_member(*prop)) - return false; - if (!streamer.start_consecutive(true, true)) - return false; - if (!write(streamer, instance.reserve()[0], instance.reserve().size())) - return false; - if (!streamer.finish_consecutive()) - return false; - if (!streamer.finish_member(*prop)) - return false; - break; - } - prop = streamer.next_entity(prop); - } - return streamer.finish_struct(*props); -} - -template::value, bool> = true > -bool write(S& str, const ::unitree_go::msg::dds_::BmsCmd_& instance, bool as_key) { - auto &props = get_type_props<::unitree_go::msg::dds_::BmsCmd_>(); - str.set_mode(cdr_stream::stream_mode::write, as_key); - return write(str, instance, props.data()); -} - -template::value, bool> = true > -bool read(T& streamer, ::unitree_go::msg::dds_::BmsCmd_& instance, entity_properties_t *props) { - (void)instance; - if (!streamer.start_struct(*props)) - return false; - auto prop = streamer.first_entity(props); - while (prop) { - switch (prop->m_id) { - case 0: - if (!streamer.start_member(*prop)) - return false; - if (!read(streamer, instance.off())) - return false; - if (!streamer.finish_member(*prop)) - return false; - break; - case 1: - if (!streamer.start_member(*prop)) - return false; - if (!streamer.start_consecutive(true, true)) - return false; - if (!read(streamer, instance.reserve()[0], instance.reserve().size())) - return false; - if (!streamer.finish_consecutive()) - return false; - if (!streamer.finish_member(*prop)) - return false; - break; - } - prop = streamer.next_entity(prop); - } - return streamer.finish_struct(*props); -} - -template::value, bool> = true > -bool read(S& str, ::unitree_go::msg::dds_::BmsCmd_& instance, bool as_key) { - auto &props = get_type_props<::unitree_go::msg::dds_::BmsCmd_>(); - str.set_mode(cdr_stream::stream_mode::read, as_key); - return read(str, instance, props.data()); -} - -template::value, bool> = true > -bool move(T& streamer, const ::unitree_go::msg::dds_::BmsCmd_& instance, entity_properties_t *props) { - (void)instance; - if (!streamer.start_struct(*props)) - return false; - auto prop = streamer.first_entity(props); - while (prop) { - switch (prop->m_id) { - case 0: - if (!streamer.start_member(*prop)) - return false; - if (!move(streamer, instance.off())) - return false; - if (!streamer.finish_member(*prop)) - return false; - break; - case 1: - if (!streamer.start_member(*prop)) - return false; - if (!streamer.start_consecutive(true, true)) - return false; - if (!move(streamer, instance.reserve()[0], instance.reserve().size())) - return false; - if (!streamer.finish_consecutive()) - return false; - if (!streamer.finish_member(*prop)) - return false; - break; - } - prop = streamer.next_entity(prop); - } - return streamer.finish_struct(*props); -} - -template::value, bool> = true > -bool move(S& str, const ::unitree_go::msg::dds_::BmsCmd_& instance, bool as_key) { - auto &props = get_type_props<::unitree_go::msg::dds_::BmsCmd_>(); - str.set_mode(cdr_stream::stream_mode::move, as_key); - return move(str, instance, props.data()); -} - -template::value, bool> = true > -bool max(T& streamer, const ::unitree_go::msg::dds_::BmsCmd_& instance, entity_properties_t *props) { - (void)instance; - if (!streamer.start_struct(*props)) - return false; - auto prop = streamer.first_entity(props); - while (prop) { - switch (prop->m_id) { - case 0: - if (!streamer.start_member(*prop)) - return false; - if (!max(streamer, instance.off())) - return false; - if (!streamer.finish_member(*prop)) - return false; - break; - case 1: - if (!streamer.start_member(*prop)) - return false; - if (!streamer.start_consecutive(true, true)) - return false; - if (!max(streamer, instance.reserve()[0], instance.reserve().size())) - return false; - if (!streamer.finish_consecutive()) - return false; - if (!streamer.finish_member(*prop)) - return false; - break; - } - prop = streamer.next_entity(prop); - } - return streamer.finish_struct(*props); -} - -template::value, bool> = true > -bool max(S& str, const ::unitree_go::msg::dds_::BmsCmd_& instance, bool as_key) { - auto &props = get_type_props<::unitree_go::msg::dds_::BmsCmd_>(); - str.set_mode(cdr_stream::stream_mode::max, as_key); - return max(str, instance, props.data()); -} - template<> propvec &get_type_props<::unitree_go::msg::dds_::LowCmd_>(); diff --git a/cpp_bridge/src/lowlevel/bridge.cpp b/cpp_bridge/src/lowlevel/bridge.cpp index e610a05..f2e3423 100644 --- a/cpp_bridge/src/lowlevel/bridge.cpp +++ b/cpp_bridge/src/lowlevel/bridge.cpp @@ -9,35 +9,46 @@ #include #include #include +#include +#include "dds/dds.hpp" +#include "dds/dds.h" +#include + using namespace unitree::common; using namespace unitree::robot; - +using namespace org::eclipse::cyclonedds; #define TOPIC_LOWCMD "rt/lowcmd" #define TOPIC_LOWSTATE "rt/lowstate" constexpr double PosStopF = (2.146E+9f); constexpr double VelStopF = (16000.0f); - class Bridge { public: explicit Bridge() - {} + { + } ~Bridge() - {} - + { + } + // participant = dds::domain::DomainParticipant(domain_id); void Init(); private: void InitLowCmd(); void LowStateMessageHandler(const void* messages); void LowCmdWrite(); + std::thread go2py_thread; + bool running = true; + void go2py_callback(); + // Go2PyListener go2py_listener; + // dds::sub::qos::DataReaderQos rqos; + private: float dt = 0.002; // 0.001~0.01 - unitree_go::msg::dds_::LowCmd_ low_cmd{}; // default init unitree_go::msg::dds_::LowState_ low_state{}; // default init @@ -45,9 +56,9 @@ private: ChannelPublisherPtr lowcmd_publisher; /*subscriber*/ ChannelSubscriberPtr lowstate_subscriber; - /*LowCmd write thread*/ ThreadPtr lowCmdWriteThreadPtr; + // dds::topic::Topic topic(participant, "go2py/lowcmd"); }; uint32_t crc32_core(uint32_t* ptr, uint32_t len) @@ -85,17 +96,58 @@ uint32_t crc32_core(uint32_t* ptr, uint32_t len) void Bridge::Init() { InitLowCmd(); - /*create publisher*/ lowcmd_publisher.reset(new ChannelPublisher(TOPIC_LOWCMD)); lowcmd_publisher->InitChannel(); - /*create subscriber*/ lowstate_subscriber.reset(new ChannelSubscriber(TOPIC_LOWSTATE)); lowstate_subscriber->InitChannel(std::bind(&Bridge::LowStateMessageHandler, this, std::placeholders::_1), 1); - /*loop publishing thread*/ - lowCmdWriteThreadPtr = CreateRecurrentThreadEx("writebasiccmd", UT_CPU_ID_NONE, 2000, &Bridge::LowCmdWrite, this); + lowCmdWriteThreadPtr = CreateRecurrentThreadEx("writebasiccmd", UT_CPU_ID_NONE, 2000, &Bridge::LowCmdWrite, this); + go2py_thread = std::thread(&Bridge::go2py_callback, this); +} + +void Bridge::go2py_callback() +{ + // dds::domain::DomainParticipant participant(domain::default_id()); + // /* To subscribe to something, a topic is needed. */ + // dds::topic::Topic topic(participant, "go2py/lowcmd"); + // /* A reader also needs a subscriber. */ + // // dds::sub::Subscriber subscriber(participant); + // dds::sub::NoOpSubscriberListener qlistener; /*you need to create your own class that derives from this listener, and implement your own callbacks*/ + // /*the listener implementation should implement the on_subscription_matched virtual function as we will rely on it later*/ + // dds::sub::qos::SubscriberQos subqos; /*add custom QoS policies that you want for this subscriber*/ + // dds::sub::Subscriber sub(participant, subqos, &qlistener, dds::core::status::StatusMask::subscription_matched()); + // /* Now, the reader can be created to subscribe to a HelloWorld message. */ + // dds::sub::NoOpAnyDataReaderListener listener; /*you need to create your own class that derives from this listener, and implement your own callback functions*/ + // /*the listener implementation should implement the on_data_available virtual function as we will rely on it later*/ + // dds::sub::qos::DataReaderQos rqos; + // // dds::sub::DataReader reader(subscriber, topic, rqos, &listener, dds::core::status::StatusMask::data_available()); + // dds::sub::DataReader reader(sub, topic, rqos, &listener, dds::core::status::StatusMask::data_available()); + // dds::sub::LoanedSamples samples; + + while (running) + { + + // /* Try taking samples from the reader. */ + // samples = reader.take(); + + // /* Are samples read? */ + // if (samples.length() > 0) { + // /* Use an iterator to run over the set of samples. */ + // dds::sub::LoanedSamples::const_iterator sample_iter; + // for (sample_iter = samples.begin(); + // sample_iter < samples.end(); + // ++sample_iter) { + // /* Get the message and sample information. */ + // const msgs::LowCmd& msg = sample_iter->data(); + // const dds::sub::SampleInfo& info = sample_iter->info(); + // std::cout << "go2py_callback got a sample..." << std::endl; + // } + // } + std::this_thread::sleep_for(std::chrono::seconds(1)); + } + std::cout << "go2py_callback stopped." << std::endl; } void Bridge::InitLowCmd() @@ -132,8 +184,59 @@ void Bridge::LowCmdWrite() lowcmd_publisher->Write(low_cmd); } +class Go2PyListener: public dds::sub::NoOpDataReaderListener +{ + public: + using callback_func = std::function&, + dds::pub::DataWriter&)>; + Go2PyListener() = delete; + Go2PyListener( const callback_func &f): + dds::sub::DataReaderListener(), _f(f) { ; } + + void on_data_available(dds::sub::DataReader& rd, + dds::pub::DataWriter& rw) { + (void)_f(rd, rw); + } + private: + callback_func _f; // Private member variable to store the callback function +}; + +static bool data_available(dds::sub::DataReader& rd, + dds::pub::DataWriter& rw) +{ + return true; +} int main(int argc, const char** argv) { + dds::domain::DomainParticipant participant(domain::default_id()); + + dds::topic::qos::TopicQos tqos; + tqos << dds::core::policy::Reliability::Reliable(dds::core::Duration::from_secs(10)); + dds::topic::Topic cmd_topic(participant, "go2py/lowcmd", tqos); + dds::topic::Topic state_topic(participant, "go2py/lowstate", tqos); + + dds::pub::qos::PublisherQos pqos; + pqos << dds::core::policy::Partition("pong"); + dds::pub::Publisher publisher(participant, pqos); + + dds::sub::qos::SubscriberQos sqos; + sqos << dds::core::policy::Partition("ping"); + dds::sub::Subscriber subscriber(participant, sqos); + + dds::pub::qos::DataWriterQos wqos; + wqos << dds::core::policy::WriterDataLifecycle::ManuallyDisposeUnregisteredInstances(); + dds::pub::DataWriter writer(publisher, state_topic, wqos); + + Go2PyListener listener(&data_available); + + dds::sub::DataReader + reader( + subscriber, + cmd_topic, + dds::sub::qos::DataReaderQos(), + &listener, + dds::core::status::StatusMask::data_available()); + if (argc < 2) { std::cout << "Usage: " << argv[0] << " networkInterface" << std::endl; @@ -144,7 +247,6 @@ int main(int argc, const char** argv) Bridge bridge; bridge.Init(); - while (1) { sleep(10);