Skip to content

Commit

Permalink
Change metadata output file name of get_summary_from_bag.py
Browse files Browse the repository at this point in the history
  • Loading branch information
YvesSchoenberg committed Sep 8, 2023
1 parent 4aff8cd commit ea0ca27
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 15 deletions.
2 changes: 1 addition & 1 deletion python/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "robologs-ros-utils"
version = "0.1.1a44"
version = "0.1.1a45"
description = "robologs-ros-utils is an open source library of containerized data transformations for the robotics and drone communities"
authors = ["roboto.ai <[email protected]>"]
license = "Apache-2.0"
Expand Down
13 changes: 8 additions & 5 deletions python/robologs_ros_utils/cli.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import click

from robologs_ros_utils.sources.ros1 import (clip_rosbag,
get_csv_data_from_bag,
get_images_from_bag,
get_summary_from_bag,
get_videos_from_bag, split_rosbag)
from robologs_ros_utils.sources.ros1 import (
clip_rosbag,
get_csv_data_from_bag,
get_images_from_bag,
get_summary_from_bag,
get_videos_from_bag,
split_rosbag,
)


@click.group(invoke_without_command=True)
Expand Down
3 changes: 1 addition & 2 deletions python/robologs_ros_utils/sources/ros1/commands.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import click

from . import (clip_rosbag, get_images_from_bag, get_summary_from_bag,
get_videos_from_bag, split_rosbag)
from . import clip_rosbag, get_images_from_bag, get_summary_from_bag, get_videos_from_bag, split_rosbag


@click.group()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def get_summary(input, output, file_name, split, hidden):
if split:
for bag_path, bag_info in rosbag_info_dict.items():
bag_dir = os.path.dirname(bag_path)
bag_name = os.path.basename(bag_path).replace(".bag", ".json")
bag_name = os.path.basename(bag_path) + ".json"
if hidden:
bag_name = "." + bag_name

Expand Down
16 changes: 10 additions & 6 deletions python/robologs_ros_utils/sources/ros1/ros_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def get_bag_info_from_file(rosbag_path: str) -> dict:
summary_dict["start_time"] = bag.start_time
summary_dict["end_time"] = bag.end_time
summary_dict["duration"] = bag.end_time - bag.start_time
summary_dict["file_size_mb"] = file_stats.st_size / (1024 * 1024)
summary_dict["file_size_mb"] = str(file_stats.st_size / (1024 * 1024))
summary_dict["topics"] = bag.topic_table.to_dict("records")

return summary_dict
Expand Down Expand Up @@ -118,7 +118,7 @@ def create_manifest_entry_dict(msg_timestamp: int, rosbag_timestamp: int, file_p
}


def get_image_topic_types():
def get_image_topic_types() -> list:
"""
Returns:
Expand Down Expand Up @@ -177,7 +177,7 @@ def replace_ros_topic_name(topic_name: str, replace_character: str = "_") -> str
return topic_name.replace("/", replace_character)[1:]


def get_filter_fraction(start_time: Optional[float], end_time: Optional[float], start_rosbag: float, end_rosbag: float):
def get_filter_fraction(start_time: Optional[float], end_time: Optional[float], start_rosbag: float, end_rosbag: float) -> Optional[float]:
"""
Args:
start_time (float or None):
Expand All @@ -191,7 +191,7 @@ def get_filter_fraction(start_time: Optional[float], end_time: Optional[float],
rosbag_duration = end_rosbag - start_rosbag

if rosbag_duration <= 0:
return
return None

if start_time and end_time:
return float((end_time - start_time) / rosbag_duration)
Expand All @@ -205,6 +205,8 @@ def get_filter_fraction(start_time: Optional[float], end_time: Optional[float],
if not end_time and not start_time:
return 1

return None


def check_if_in_time_range(t: float, start_time: float, end_time: float) -> bool:
"""
Expand Down Expand Up @@ -238,8 +240,10 @@ def check_if_in_time_range(t: float, start_time: float, end_time: float) -> bool
if not start_time and not end_time:
return True

return False

def get_name_img_manifest():

def get_name_img_manifest() -> str:
"""
Returns:
Expand Down Expand Up @@ -277,7 +281,7 @@ def get_images_from_bag(
sample: Optional[int] = None,
start_time: Optional[float] = None,
end_time: Optional[float] = None,
):
) -> list:
"""
Args:
rosbag_path (str):
Expand Down

0 comments on commit ea0ca27

Please sign in to comment.