#include #include #include #include #include #include #include #include #include namespace po = boost::program_options; using unitree::robot::ChannelFactory; using unitree::robot::ChannelSubscriber; using unitree_hg::msg::dds_::LowState_; int main(int argc, char** argv) { po::options_description options("Unitree H2 termination functions testing."); options.add_options() ("network,n", po::value()->default_value(""), "dds network interface"); po::variables_map args; po::store(po::parse_command_line(argc, argv, options), args); po::notify(args); std::cout << options << std::endl; ChannelFactory::Instance()->Init(0, args["network"].as()); auto lowstate_subscriber = std::make_shared>("rt/lowstate"); LowState_ lowstate; lowstate_subscriber->InitChannel([&lowstate](const void* message) { lowstate = *static_cast(message); }); std::cout << "Checking terminations..." << std::endl; while (true) { if (unitree::robot::h2::bad_orientation(lowstate, 1.0f)) { std::cout << "Bad orientation detected!" << std::endl; } if (unitree::robot::h2::lost_connection(lowstate_subscriber, 1000)) { std::cout << "Lost connection!" << std::endl; } std::this_thread::sleep_for(std::chrono::milliseconds(100)); } }