Giter Club home page Giter Club logo

Comments (6)

aaronsnoswell avatar aaronsnoswell commented on May 29, 2024

It might be easier to get the gist of the UE4 log in an image;

ue4_bson_parse_fail

from rosintegration.

aaronsnoswell avatar aaronsnoswell commented on May 29, 2024

Another update here: I updated my ROS nodes so that I'm downsampling the point cloud massively (see https://github.com/aaronsnoswell/ue4_comms_test/blob/master/src/pcl_downsampler.cpp). When I do this, I am able to recieve the sensor_msgs/PointCloud2 messages fine. As such, this definitely seems to be a problem with receiving large bson messages that are split over multiple TCP packets.

Can we work out an approach to fixing this problem? I'm happy to do the work if you advise what needs to be done :) I'm not super familiar with the code in TCPConnection.cpp

from rosintegration.

Sanic avatar Sanic commented on May 29, 2024

Hi @aaronsnoswell
Thanks for opening this issue and sorry for the delay.
This problem might be indeed a problem with the TCPConnection class.
I think the relevant part starts at

if(_sock->HasPendingData(count) && count > 0){
. The main idea is to begin by reading the first 4 bytes. These bytes represent the length field of a bson packet: http://bsonspec.org/spec.html. By reading this length, we can instruct the next recv() calls to receive exactly that many bytes.
After these 4 four bytes have been read, bson_state_read_length will be false. This will cause the jump to
std::cout << "Message read mode" << std::endl;
to handle the actual message reception. I guess the problems begin there. Maybe if( _sock->Recv(binary_temp.GetData(), bson_msg_length - 4, bytes_read) ) can return less then the requested bson_msg_length - 4 bytes on fragmented packets. So one would have to reiterate to collect more data in the buffer.
Additionally, i'm not 100% sure if if(msg_size_in_buffer == bson_msg_length) is correct. msg_size_in_buffer is calculated by calling Num() on a TArray. However, this array is resized with SetNumUninitialized() :
binary_temp.SetNumUninitialized(bson_msg_length - 4);

So Num() may not count the actual elements in the list, but rather the received elements + uninitialized elements.

from rosintegration.

Hemofektik avatar Hemofektik commented on May 29, 2024

As a reference on how it could be done, you can check the implementation on the rosbridge_server side:
https://github.com/RobotWebTools/rosbridge_suite/blob/develop/rosbridge_server/src/rosbridge_server/tcp_handler.py#L62

from rosintegration.

TaylorDale avatar TaylorDale commented on May 29, 2024

Has this been fixed now? I am just reviewing the code for TCPConnection.cpp and it looks substantially different to what it did in 2018, and appears that it will correctly wait to fill a buffer based on the 4 byte BSON prefix.

However we are still receiving BSON decode issues with our pointcloud frames ("Error on BSON parse - Ignoring message"), using v0.11.10 of rosbridge server. Any clue if this could be related to it?

from rosintegration.

PetterVMC avatar PetterVMC commented on May 29, 2024

@Sanic

. The main idea is to begin by reading the first 4 bytes. These bytes represent the length field of a bson packet: http://bsonspec.org/spec.html. By reading this length, we can instruct the next recv() calls to receive exactly that many bytes.
After these 4 four bytes have been read, bson_state_read_length will be false. This will cause the jump to

std::cout << "Message read mode" << std::endl;

to handle the actual message reception. I guess the problems begin there. Maybe if( _sock->Recv(binary_temp.GetData(), bson_msg_length - 4, bytes_read) ) can return less then the requested bson_msg_length - 4 bytes on fragmented packets. So one would have to reiterate to collect more data in the buffer.

About a year ago I had this exact problem you're describing Sanic, so I modified TCPConnection.cpp to be able to read headers from fragmented packets. I have a pending pull request #179 on this . Would appreciate if someone could have a look at it and accept it if it seems OK. I've been using my modified version multiple times now over the last year without any apparent problem.

from rosintegration.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.