-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adding mcap to mat script for temp usage
- Loading branch information
Showing
6 changed files
with
41 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,4 @@ result | |
result/ | ||
.env | ||
.idea/ | ||
*.mat |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import sys | ||
from pathlib import Path | ||
from mcap.reader import make_reader | ||
from mcap_protobuf.reader import read_protobuf_messages | ||
from mcap_protobuf.decoder import DecoderFactory | ||
from scipy.io import savemat | ||
|
||
def main(): | ||
with open(sys.argv[1], "rb") as f: | ||
reader = make_reader(f, decoder_factories=[DecoderFactory()]) | ||
topics = [] | ||
for channel in reader.get_summary().channels: | ||
topics.append(reader.get_summary().channels[channel].topic) | ||
|
||
msgs_lists = [] | ||
for topic in topics: | ||
msgs = [] | ||
for schema, channel, message, proto_msg in reader.iter_decoded_messages(topics=[topic]): | ||
|
||
|
||
res = [f.name for f in proto_msg.DESCRIPTOR.fields] | ||
msg = {} | ||
msg["recvd_time"] = message.log_time | ||
for name in res: | ||
msg[name] = getattr(proto_msg, name) | ||
msgs.append(msg) | ||
msgs_lists.append(msgs) | ||
mdict= {} | ||
for index, topic in enumerate(topics): | ||
mdict[topic] = msgs_lists[index] | ||
out_name = Path(sys.argv[1]).stem | ||
savemat(out_name+".mat", mdict, long_field_names=True) | ||
|
||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters