Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}
const {timestamp, message} = msg[msg.length - 1];
// Every frame *MUST* have a pose. The pose can be considered
// the core reference point for other data and usually drives the timing
// of the system.
// Position, decimal degrees
const rotation = quaternionToEuler(message.pose.orientation);
const {position} = message.pose;
xvizBuilder
.pose(this.xvizStream)
.mapOrigin(this.origin.longitude, this.origin.latitude, this.origin.altitude)
.position(position.x, position.y, 0)
.orientation(rotation.roll, rotation.pitch, rotation.yaw)
.timestamp(TimeUtil.toDate(timestamp).getTime() / 1e3);
}
export async function BagDump(args) {
const {bag: bagPath, topic: mainTopic} = args;
const bag = await open(bagPath);
if (args.dumpTime) {
console.log(`start_time: ${TimeUtil.toDate(bag.startTime).getTime() / 1e3}`);
console.log(`end_time: ${TimeUtil.toDate(bag.endTime).getTime() / 1e3}`);
}
if (args.dumpAllTopics) {
for (const conn in bag.connections) {
const {topic, type} = bag.connections[conn];
console.log(topic, type);
}
}
if (args.dumpMessages) {
await bag.readMessages({}, ({topic, message}) => {
if (!mainTopic || topic === mainTopic) {
console.log(JSON.stringify(message, null, 2));
}
});
export async function BagDump(args) {
const {bag: bagPath, topic: mainTopic} = args;
const bag = await open(bagPath);
if (args.dumpTime) {
console.log(`start_time: ${TimeUtil.toDate(bag.startTime).getTime() / 1e3}`);
console.log(`end_time: ${TimeUtil.toDate(bag.endTime).getTime() / 1e3}`);
}
if (args.dumpAllTopics) {
for (const conn in bag.connections) {
const {topic, type} = bag.connections[conn];
console.log(topic, type);
}
}
if (args.dumpMessages) {
await bag.readMessages({}, ({topic, message}) => {
if (!mainTopic || topic === mainTopic) {
console.log(JSON.stringify(message, null, 2));
}
});
}
async _initBag(bag) {
const TF = '/tf';
const TF_STATIC = '/tf_static';
this.bagContext.start_time = TimeUtil.toDate(bag.startTime).getTime() / 1e3;
this.bagContext.end_time = TimeUtil.toDate(bag.endTime).getTime() / 1e3;
const frameIdToPoseMap = {};
await bag.readMessages({topics: [TF, TF_STATIC]}, ({topic, message}) => {
message.transforms.forEach(t => {
frameIdToPoseMap[t.child_frame_id] = {
...t.transform.translation,
...quaternionToEuler(t.transform.rotation)
};
});
});
this.bagContext.frameIdToPoseMap = frameIdToPoseMap;
}
async _initBag(bag) {
const TF = '/tf';
const TF_STATIC = '/tf_static';
this.bagContext.start_time = TimeUtil.toDate(bag.startTime).getTime() / 1e3;
this.bagContext.end_time = TimeUtil.toDate(bag.endTime).getTime() / 1e3;
const frameIdToPoseMap = {};
await bag.readMessages({topics: [TF, TF_STATIC]}, ({topic, message}) => {
message.transforms.forEach(t => {
frameIdToPoseMap[t.child_frame_id] = {
...t.transform.translation,
...quaternionToEuler(t.transform.rotation)
};
});
});
this.bagContext.frameIdToPoseMap = frameIdToPoseMap;
}
async collectMetadata() {
const TF = '/tf';
let origin = {latitude: 0, longitude: 0, altitude: 0};
const frameIdToPoseMap = {};
await this.open();
const start_time = TimeUtil.toDate(this.bag.startTime).getTime() / 1e3;
const end_time = TimeUtil.toDate(this.bag.endTime).getTime() / 1e3;
await this.bag.readMessages({topics: [CONFIGURATION, TF]}, ({topic, message}) => {
if (topic === CONFIGURATION) {
const config = message.keyvalues.reduce((memo, kv) => {
memo[kv.key] = kv.value;
return memo;
}, {});
if (config.map_lat) {
origin = {
latitude: parseFloat(config.map_lat),
longitude: parseFloat(config.map_lng),
altitude: parseFloat(config.map_alt)
};
}
} else if (topic === TF) {
async collectMetadata() {
const TF = '/tf';
let origin = {latitude: 0, longitude: 0, altitude: 0};
const frameIdToPoseMap = {};
await this.open();
const start_time = TimeUtil.toDate(this.bag.startTime).getTime() / 1e3;
const end_time = TimeUtil.toDate(this.bag.endTime).getTime() / 1e3;
await this.bag.readMessages({topics: [CONFIGURATION, TF]}, ({topic, message}) => {
if (topic === CONFIGURATION) {
const config = message.keyvalues.reduce((memo, kv) => {
memo[kv.key] = kv.value;
return memo;
}, {});
if (config.map_lat) {
origin = {
latitude: parseFloat(config.map_lat),
longitude: parseFloat(config.map_lng),
altitude: parseFloat(config.map_alt)
};
}