Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async readFrameByTime(start, end) {
const bag = await open(this.bagPath);
const frame = {};
const options = {};
if (start) {
options.startTime = TimeUtil.fromDate(new Date(start * 1e3));
}
if (end) {
options.endTime = TimeUtil.fromDate(new Date(end * 1e3));
}
if (this.topics) {
options.topics = this.topics;
}
await bag.readMessages(options, async result => {
// rosbag.js reuses the data buffer for subsequent messages, so we need to make a copy
if (result.message.data) {
result.message.data = Buffer.from(result.message.data);
}
if (result.topic === this.keyTopic) {
frame.keyTopic = result;
}
async readFrameByTime(start, end) {
const bag = await open(this.bagPath);
const frame = {};
const options = {};
if (start) {
options.startTime = TimeUtil.fromDate(new Date(start * 1e3));
}
if (end) {
options.endTime = TimeUtil.fromDate(new Date(end * 1e3));
}
if (this.topics) {
options.topics = this.topics;
}
await bag.readMessages(options, async result => {
// rosbag.js reuses the data buffer for subsequent messages, so we need to make a copy
if (result.message.data) {
result.message.data = Buffer.from(result.message.data);
}
async readFrameByKeyTopic(start, end) {
const bag = await open(this.bagPath);
let frame = {};
async function flushFrame() {
if (frame.keyTopic) {
// This needs to be address, was used to flush on keyTopic message to sync
// await onFrame(frame);
frame = {};
}
}
const options = {
startTime: TimeUtil.fromDate(new Date(start * 1e3)),
endTime: TimeUtil.fromDate(new Date(end * 1e3))
};
if (this.topics) {
options.topics = this.topics;
}
await bag.readMessages(options, async result => {
// rosbag.js reuses the data buffer for subsequent messages, so we need to make a copy
if (result.message.data) {
result.message.data = Buffer.from(result.message.data);
}
if (result.topic === this.keyTopic) {
await flushFrame();
frame.keyTopic = result;
}
async readFrameByKeyTopic(start, end) {
const bag = await open(this.bagPath);
let frame = {};
async function flushFrame() {
if (frame.keyTopic) {
// This needs to be address, was used to flush on keyTopic message to sync
// await onFrame(frame);
frame = {};
}
}
const options = {
startTime: TimeUtil.fromDate(new Date(start * 1e3)),
endTime: TimeUtil.fromDate(new Date(end * 1e3))
};
if (this.topics) {
options.topics = this.topics;
}
await bag.readMessages(options, async result => {
// rosbag.js reuses the data buffer for subsequent messages, so we need to make a copy
if (result.message.data) {
result.message.data = Buffer.from(result.message.data);
}
if (result.topic === this.keyTopic) {
await flushFrame();
frame.keyTopic = result;
}
frame[result.topic] = frame[result.topic] || [];
async readMessages(start, end) {
const bag = await this._openBag();
const frame = {};
const options = {
topics: this.rosConfig.topics
};
if (start) {
options.startTime = TimeUtil.fromDate(new Date(start * 1e3));
}
if (end) {
options.endTime = TimeUtil.fromDate(new Date(end * 1e3));
}
await bag.readMessages(options, async result => {
// rosbag.js reuses the data buffer for subsequent messages, so we need to make a copy
if (result.message.data) {
// Used for binary data in images, point clouds, etc
// TODO(this needs to work in the browser)
result.message.data = Buffer.from(result.message.data);
}
frame[result.topic] = frame[result.topic] || [];
frame[result.topic].push(result);
async readMessages(start, end) {
const bag = await this._openBag();
const frame = {};
const options = {
topics: this.rosConfig.topics
};
if (start) {
options.startTime = TimeUtil.fromDate(new Date(start * 1e3));
}
if (end) {
options.endTime = TimeUtil.fromDate(new Date(end * 1e3));
}
await bag.readMessages(options, async result => {
// rosbag.js reuses the data buffer for subsequent messages, so we need to make a copy
if (result.message.data) {
// Used for binary data in images, point clouds, etc
// TODO(this needs to work in the browser)
result.message.data = Buffer.from(result.message.data);
}
frame[result.topic] = frame[result.topic] || [];
frame[result.topic].push(result);
});
return frame;
}