Giter Site home page Giter Site logo

Comments (4)

m-dahl avatar m-dahl commented on August 22, 2024 1

Yes now I understand better, thanks. I agree that it would be nice to have. I just pushed a quick fix (d5f2ef0) that should enable your usecase. Let me know if it works.

from r2r.

m-dahl avatar m-dahl commented on August 22, 2024

Hi,

If you know what you need I am open to exposing more functionality. I am not 100% clear on your usecase though. What will you do with the data eventually? Since you are using r2r I assume that eventually you want to publish some data as ros messages? If so I think the untyped set of functions would work, populate a serde_json::Object given the schema you have and publish the data that way. But the message type must exist and be built on the ros side for this to work, so you cannot for example create a bridge that supports an artibrary schema on the fly.

from r2r.

tfoldi avatar tfoldi commented on August 22, 2024

Thank you for your answer, let me add a quick clarification:

  • I have a few mcap files (ros bags) stored on file system
  • I want to make the data available for post processing (running ML models, etc.). Think about reshaping the messages in the rosbag to align multiple camera images to the same frequency/timestamps, experimenting with different model parameters, etc. on the collected data.
  • I want to execute this post processing inside the ROS2 environment (libraries can be/will be preloaded/linked), but not as a node. To do this, I need the from_serialized_bytes function to be available. See the code below:
    for message in mcap::MessageStream::new(&mapped)? {
        let message = message?;

        let schema_name = message
            .channel
            .schema
            .as_ref()
            .map(|schema| schema.name.as_str())
            .unwrap_or_default();

        if schema_name == "sensor_msgs/msg/Imu" {
            // message.data is [u8] 
            let data = from_serialized_bytes::<sensor_msgs::msg::Imu>(&message.data)?;
        }
    }

Now my challenge is that the from_serialized_bytes is not publicly available. Making it public will unlock this use case.

In addition to this, it would be great to access data from messages without hardcoding schema types, just by type names. As you mentioned, the messages must be defined at compilation time (which is ok). Imagine something like:

        let native =
            WrappedNativeMsgUntyped::new_from("sensor_msgs/msg/Imu").unwrap();
        native.from_serialized_bytes(&message.data).unwrap();

It will help me to create tools like topic_tools where I can cat the contents of files, downsample, etc. without hardcode each and every type. If you can help point me to the right direction I can try to implement myself.

Hope this makes a bit more sense.

from r2r.

tfoldi avatar tfoldi commented on August 22, 2024

This was quick! Thank you, I will a give a try but based on the example it is exactly what I needed.

Thanks again!

from r2r.

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.