From b73ea3269b4e0841cc3aaa25bdb10a7f5cd77ac1 Mon Sep 17 00:00:00 2001 From: devel Date: Wed, 11 Oct 2023 11:24:17 +0200 Subject: [PATCH] removed wirehair repair symbol additions --- nimbro_topic_transport/CMakeLists.txt | 4 - .../src/receiver/depacketizer.cpp | 78 ++++++++--------- .../src/sender/packetizer.cpp | 86 +++++++++---------- 3 files changed, 81 insertions(+), 87 deletions(-) diff --git a/nimbro_topic_transport/CMakeLists.txt b/nimbro_topic_transport/CMakeLists.txt index 7fa4953..df3fe57 100644 --- a/nimbro_topic_transport/CMakeLists.txt +++ b/nimbro_topic_transport/CMakeLists.txt @@ -40,10 +40,6 @@ set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall") add_library(nimbro_topic_transport - contrib/wirehair/wirehair.cpp - contrib/wirehair/gf256.cpp - contrib/wirehair/WirehairCodec.cpp - contrib/wirehair/WirehairTools.cpp src/sender/compressor.cpp src/sender/get_route.cpp src/sender/packetizer.cpp diff --git a/nimbro_topic_transport/src/receiver/depacketizer.cpp b/nimbro_topic_transport/src/receiver/depacketizer.cpp index 424184d..7bd44bb 100644 --- a/nimbro_topic_transport/src/receiver/depacketizer.cpp +++ b/nimbro_topic_transport/src/receiver/depacketizer.cpp @@ -7,7 +7,7 @@ #include -#include +/* #include */ #include "../topic_info.h" @@ -67,43 +67,43 @@ void Depacketizer::handleMessagePacket(std::list::iterator it, c std::vector recoveredData; // Do we need to do FEC decoding? - if(header.repair_symbols()) - { - if(header.source_symbols() > 1) - { - if(!msg->decoder) - { - msg->decoder.reset(wirehair_decoder_create(nullptr, header.source_symbols() * UDPPacket::MaxDataSize, UDPPacket::MaxDataSize), wirehair_free); - } - - WirehairResult res = wirehair_decode(msg->decoder.get(), header.symbol_id, packet->packet()->data, packet->length - sizeof(UDPPacket::Header)); - if(res == Wirehair_NeedMore) - return; - - if(res != Wirehair_Success) - { - ROS_ERROR("Wirehair decode() error: %s", wirehair_result_string(res)); - ROS_ERROR(" ^- on packet with symbol_id=%u, length=%lu", header.symbol_id(), packet->length); - ROS_ERROR(" ^- source_symbols=%u, repair_symbols=%u", header.source_symbols(), header.repair_symbols()); - return; - } - - recoveredData.resize(header.source_symbols() * UDPPacket::MaxDataSize); - res = wirehair_recover(msg->decoder.get(), recoveredData.data(), recoveredData.size()); - if(res != Wirehair_Success) - { - ROS_ERROR("Wirehair recover() error: %s", wirehair_result_string(res)); - return; - } - } - else - { - recoveredData.resize(packet->length - sizeof(UDPPacket::Header)); - memcpy(recoveredData.data(), packet->packet()->data, packet->length - sizeof(UDPPacket::Header)); - } - } - else - { + /* if(header.repair_symbols()) */ + /* { */ + /* if(header.source_symbols() > 1) */ + /* { */ + /* if(!msg->decoder) */ + /* { */ + /* msg->decoder.reset(wirehair_decoder_create(nullptr, header.source_symbols() * UDPPacket::MaxDataSize, UDPPacket::MaxDataSize), wirehair_free); */ + /* } */ + + /* WirehairResult res = wirehair_decode(msg->decoder.get(), header.symbol_id, packet->packet()->data, packet->length - sizeof(UDPPacket::Header)); */ + /* if(res == Wirehair_NeedMore) */ + /* return; */ + + /* if(res != Wirehair_Success) */ + /* { */ + /* ROS_ERROR("Wirehair decode() error: %s", wirehair_result_string(res)); */ + /* ROS_ERROR(" ^- on packet with symbol_id=%u, length=%lu", header.symbol_id(), packet->length); */ + /* ROS_ERROR(" ^- source_symbols=%u, repair_symbols=%u", header.source_symbols(), header.repair_symbols()); */ + /* return; */ + /* } */ + + /* recoveredData.resize(header.source_symbols() * UDPPacket::MaxDataSize); */ + /* res = wirehair_recover(msg->decoder.get(), recoveredData.data(), recoveredData.size()); */ + /* if(res != Wirehair_Success) */ + /* { */ + /* ROS_ERROR("Wirehair recover() error: %s", wirehair_result_string(res)); */ + /* return; */ + /* } */ + /* } */ + /* else */ + /* { */ + /* recoveredData.resize(packet->length - sizeof(UDPPacket::Header)); */ + /* memcpy(recoveredData.data(), packet->packet()->data, packet->length - sizeof(UDPPacket::Header)); */ + /* } */ + /* } */ + /* else */ + /* { */ msg->received_symbols++; if(msg->received_symbols < header.source_symbols()) return; @@ -129,7 +129,7 @@ void Depacketizer::handleMessagePacket(std::list::iterator it, c off += len; } } - } + /* } */ msg->complete = true; diff --git a/nimbro_topic_transport/src/sender/packetizer.cpp b/nimbro_topic_transport/src/sender/packetizer.cpp index 361bfde..c89060a 100644 --- a/nimbro_topic_transport/src/sender/packetizer.cpp +++ b/nimbro_topic_transport/src/sender/packetizer.cpp @@ -5,8 +5,6 @@ #include -#include - #include "../udp_packet.h" namespace nimbro_topic_transport @@ -48,8 +46,8 @@ TopicPacketizer::TopicPacketizer(const Packetizer::Ptr& packetizer, const Topic: throw std::runtime_error("Invalid FEC percentage."); } - if(wirehair_init() != Wirehair_Success) - throw std::runtime_error("Could not initialize wirehair FEC library"); + /* if(wirehair_init() != Wirehair_Success) */ + /* throw std::runtime_error("Could not initialize wirehair FEC library"); */ } TopicPacketizer::~TopicPacketizer() @@ -172,46 +170,46 @@ std::vector TopicPacketizer::packetize(const Message::ConstPtr& msg } else { - WirehairCodec encoder = wirehair_encoder_create(nullptr, messageData.data(), messageData.size(), UDPPacket::MaxDataSize); - if(!encoder) - { - ROS_ERROR("Could not create wirehair encoder!"); - return {}; - } - - for(std::size_t i = 0; i < repairSymbols; ++i) - { - auto buf = std::make_shared(); - UDPPacket* packet = buf->packet(); - - packet->header.msg_id = messageID; - packet->header.source_symbols = sourceSymbols; - packet->header.repair_symbols = repairSymbols; - packet->header.symbol_id = sourceSymbols + i; - packet->header.prng_seed = seed; - - uint32_t length = 0; - - WirehairResult res = wirehair_encode(encoder, sourceSymbols + i, packet->data, UDPPacket::MaxDataSize, &length); - if(res != Wirehair_Success) - { - ROS_ERROR("Wirehair encode() error: %s", wirehair_result_string(res)); - return {}; - } - - if(length != UDPPacket::MaxDataSize) - { - ROS_ERROR("Unexpected wirehair output size: %u, expected %u", - length, UDPPacket::MaxDataSize - ); - } - - buf->length = length + sizeof(UDPPacket::Header); - - packets.emplace_back(std::move(buf)); - } - - wirehair_free(encoder); + /* WirehairCodec encoder = wirehair_encoder_create(nullptr, messageData.data(), messageData.size(), UDPPacket::MaxDataSize); */ + /* if(!encoder) */ + /* { */ + /* ROS_ERROR("Could not create wirehair encoder!"); */ + /* return {}; */ + /* } */ + + /* for(std::size_t i = 0; i < repairSymbols; ++i) */ + /* { */ + /* auto buf = std::make_shared(); */ + /* UDPPacket* packet = buf->packet(); */ + + /* packet->header.msg_id = messageID; */ + /* packet->header.source_symbols = sourceSymbols; */ + /* packet->header.repair_symbols = repairSymbols; */ + /* packet->header.symbol_id = sourceSymbols + i; */ + /* packet->header.prng_seed = seed; */ + + /* uint32_t length = 0; */ + + /* WirehairResult res = wirehair_encode(encoder, sourceSymbols + i, packet->data, UDPPacket::MaxDataSize, &length); */ + /* if(res != Wirehair_Success) */ + /* { */ + /* ROS_ERROR("Wirehair encode() error: %s", wirehair_result_string(res)); */ + /* return {}; */ + /* } */ + + /* if(length != UDPPacket::MaxDataSize) */ + /* { */ + /* ROS_ERROR("Unexpected wirehair output size: %u, expected %u", */ + /* length, UDPPacket::MaxDataSize */ + /* ); */ + /* } */ + + /* buf->length = length + sizeof(UDPPacket::Header); */ + + /* packets.emplace_back(std::move(buf)); */ + /* } */ + + /* wirehair_free(encoder); */ } {