cruise-automation / rosbag.js

ROS bag file reader for JavaScript 👜

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Issue for bags with the type Header in it

cjds opened this issue · comments

Any bag with the type Header in it seems to have an unresolvable issue when it comes to looking up its connections.

I can't remove Header as a type from the bag because https://wiki.ros.org/diagnostics package uses the Header type.

I've attached the bag that causes it

const lz4 = require("lz4js");
const { open, parseMessageDefinition } = require('rosbag');

function connections_returner(connections) {
    const emptyConnections = [];
    const op = [];
    for (const connection in Object.values(connections)) {
      const { messageDefinition, md5sum, topic, type } = connections[connection];
      if (messageDefinition && md5sum && topic && type) {
        op.push({ messageDefinition, md5sum, topic, type });
      }
    }
   return op;
}

async function checkConnections() {
  const bag = await open('test.bag');
  const connections = connections_returner(bag.connections);
  connections.forEach((connection) => {
    const connectionTypes = parseMessageDefinition(connection.messageDefinition);
  });
}

checkConnections();

This is the traceback I get

(node:442) UnhandledPromiseRejectionWarning: Error: Expected 1 top level type definition for 'Header' but found 0
    at findTypeByName (/test/node_modules/rosbag/dist/node/index.js:1450:11)
    at definitions.forEach.definition (/test/node_modules/rosbag/dist/node/index.js:1499:27)
    at Array.forEach (<anonymous>)
    at types.forEach (/test/node_modules/rosbag/dist/node/index.js:1497:17)
    at Array.forEach (<anonymous>)
    at parseMessageDefinition (/test/node_modules/rosbag/dist/node/index.js:1494:9)
    at connections.forEach (/test/test.js:39:29)
    at Array.forEach (<anonymous>)
    at checkConnections (/test/test.js:37:15)

Here's a link to the file that causes it
https://filebin.net/56sdttauoozk98i8/test.bag?t=ut7rwok9

This issue has been traced to an issue with rosgo. I'll close this one. Thanks

Ah sorry for not responding earlier, it was on my to-do list. Glad you figured it out though!

No worries. I figured it was a mess up on our end, I just didn't have good tooling to dig into it