Пример #1
0
        private static int ConvertBag(Verbs.ConvertOptions opts)
        {
            var watch     = System.Diagnostics.Stopwatch.StartNew();
            var bag       = new RosBag(opts.Input.ToList());
            var topicList = opts.Topics.Count() > 0 ? opts.Topics : bag.TopicList;

            TimeSpan offset = TimeSpan.Zero;

            // check if we should should restamp the time as current time.
            if (opts.RestampTime)
            {
                // This is a hack for now, we don't know the actual pipeline startime until it start
                // This is obviously break if the pipeline starts later etc.
                // One idea is to pass the bag.StartTime around, but this might be good enough.
                offset = DateTime.UtcNow - bag.StartTime;
            }

            // create a psi store
            using (var pipeline = Pipeline.Create(true)) //enable diagnostic
            {
                var store = Store.Create(pipeline, opts.Name, opts.Output);

                // We cannot write the diagnostics information because PsiStudio cannot
                // handle weirdly out of wack times.
                // store.Write(pipeline.Diagnostics, "ReaderDiagnostics");

                var dynamicSerializer = new DynamicSerializers(bag.KnownRosMessageDefinitions, opts.useHeaderTime, offset, useCustomSerializer: opts.useCustomSerializer);
                foreach (var topic in topicList)
                {
                    if (opts.ExcludeTopic.Contains(topic))
                    {
                        continue;
                    }
                    var messageDef = bag.GetMessageDefinition(topic);
                    var messages   = bag.ReadTopic(topic);
                    dynamicSerializer.SerializeMessages(pipeline, store, topic, messageDef.Type, messages);
                }
                pipeline.Run();
            }
            watch.Stop();
            Console.WriteLine($"Total elapsed time:{watch.ElapsedMilliseconds/1000.0} secs");

            return(1);
        }
Пример #2
0
        private static int ConvertBag(Verbs.ConvertOptions opts)
        {
            var bag       = new RosBag(opts.Input);
            var topicList = opts.Topics.Count() > 0 ? opts.Topics : bag.TopicList;

            // create a psi store
            using (var pipeline = Pipeline.Create())
            {
                var store             = Store.Create(pipeline, opts.Name, opts.Output);
                var dynamicSerializer = new DynamicSerializers(bag.KnownRosMessageDefinitions);
                foreach (var topic in topicList)
                {
                    var messages = bag.ReadTopic(topic);
                    dynamicSerializer.SerializeMessages(pipeline, store, topic, messages);
                }

                pipeline.Run();
            }

            return(1);
        }