-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add
analyze_rosbags_parallel.py
(#217)
* Fixed storage_id Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp> * Added analyze_rosbags_parallel.sh Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp> * style(pre-commit): autofix * Rewrote in python Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp> * style(pre-commit): autofix * Fixed README.md Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp> * Create a main function of plot_diagnostics.py Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp> * style(pre-commit): autofix * Created a main function of extract_pose_from_rosbag.py Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp> * Created a main function of compare_trajectories.py Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp> * Removed unused variables Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp> * Fixed topic_reference Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp> * Updated README.md Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp> * style(pre-commit): autofix * Updated README.md Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp> * Added "and not d.is_symlink()" Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp> * style(pre-commit): autofix * Removed a storage option Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp> --------- Signed-off-by: Shintaro Sakoda <shintaro.sakoda@tier4.jp> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
- Loading branch information
1 parent
295fc01
commit aa398b1
Showing
6 changed files
with
124 additions
and
30 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
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
64 changes: 64 additions & 0 deletions
64
localization/autoware_localization_evaluation_scripts/scripts/analyze_rosbags_parallel.py
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,64 @@ | ||
#!/usr/bin/env python3 | ||
"""A script to analyze rosbags in parallel.""" | ||
|
||
import argparse | ||
from multiprocessing import Pool | ||
from pathlib import Path | ||
|
||
import compare_trajectories | ||
import extract_pose_from_rosbag | ||
import plot_diagnostics | ||
|
||
|
||
def parse_args() -> argparse.Namespace: | ||
parser = argparse.ArgumentParser() | ||
parser.add_argument("result_dir", type=Path) | ||
parser.add_argument("--parallel_num", type=int, default=1) | ||
parser.add_argument("--topic_subject", type=str, default="/localization/kinematic_state") | ||
parser.add_argument( | ||
"--topic_reference", type=str, default="/localization/pose_estimator/pose_with_covariance" | ||
) | ||
return parser.parse_args() | ||
|
||
|
||
def process_directory(directory: Path, topic_subject: str, topic_reference: str) -> None: | ||
target_rosbag = directory / "result_bag" | ||
compare_result_dir = directory / "compare_trajectories" | ||
compare_result_dir.mkdir(parents=True, exist_ok=True) | ||
|
||
plot_diagnostics.main(rosbag_path=target_rosbag) | ||
|
||
save_name_subject = extract_pose_from_rosbag.topic_name_to_save_name(topic_subject) | ||
save_name_reference = extract_pose_from_rosbag.topic_name_to_save_name(topic_reference) | ||
|
||
extract_pose_from_rosbag.main( | ||
rosbag_path=target_rosbag, | ||
target_topics=[ | ||
topic_subject, | ||
topic_reference, | ||
], | ||
save_dir=compare_result_dir, | ||
) | ||
|
||
compare_trajectories.main( | ||
subject_tsv=compare_result_dir / f"{save_name_subject}.tsv", | ||
reference_tsv=compare_result_dir / f"{save_name_reference}.tsv", | ||
) | ||
|
||
|
||
if __name__ == "__main__": | ||
args = parse_args() | ||
result_dir = args.result_dir | ||
parallel_num = args.parallel_num | ||
topic_subject = args.topic_subject | ||
topic_reference = args.topic_reference | ||
|
||
directories = sorted( | ||
[d for d in args.result_dir.iterdir() if d.is_dir() and not d.is_symlink()] | ||
) | ||
|
||
with Pool(args.parallel_num) as pool: | ||
pool.starmap( | ||
process_directory, | ||
[(d, topic_subject, topic_reference) for d in directories], | ||
) |
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