Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: launch remap #94

Merged
merged 1 commit into from
Feb 22, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 33 additions & 22 deletions driving_log_replayer_v2/launch/driving_log_replayer_v2.launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,27 +363,8 @@ def launch_evaluator_node(context: LaunchContext) -> list:
]


def launch_bag_player(
context: LaunchContext,
) -> IncludeLaunchDescription:
conf = context.launch_configurations
play_cmd = [
"ros2",
"bag",
"play",
conf["input_bag"],
"--rate",
conf["play_rate"],
"--clock",
"200",
"--qos-profile-overrides-path",
Path(
get_package_share_directory("driving_log_replayer_v2"),
"config",
"qos.yaml",
).as_posix(),
]
remap_list = ["--remap"]
def system_defined_remap(conf: dict) -> list[str]:
remap_list = []
if conf.get("sensing", "true") == "true":
remap_list.append(
"/sensing/lidar/concatenated/pointcloud:=/unused/sensing/lidar/concatenated/pointcloud",
Expand All @@ -410,6 +391,11 @@ def launch_bag_player(
remap_list.append(
"/planning/mission_planning/route:=/unused/planning/mission_planning/route",
)
return remap_list


def user_defined_remap(conf: dict) -> list[str]:
remap_list = []
# user defined remap
user_remap_topics: list[str] = (
conf["remap_arg"].split(",")
Expand All @@ -421,15 +407,40 @@ def launch_bag_player(
remap_str = f"{topic}:=/unused{topic}"
if remap_str not in remap_list:
remap_list.append(remap_str)
return remap_list


def launch_bag_player(
context: LaunchContext,
) -> IncludeLaunchDescription:
conf = context.launch_configurations
play_cmd = [
"ros2",
"bag",
"play",
conf["input_bag"],
"--rate",
conf["play_rate"],
"--clock",
"200",
"--qos-profile-overrides-path",
Path(
get_package_share_directory("driving_log_replayer_v2"),
"config",
"qos.yaml",
).as_posix(),
]
remap_list = ["--remap"]
remap_list.extend(system_defined_remap(conf))
remap_list.extend(user_defined_remap(conf))
if len(remap_list) != 1:
play_cmd.extend(remap_list)
bag_player = (
ExecuteProcess(
cmd=play_cmd,
output="screen",
on_exit=[ExecuteProcess(cmd=["sleep", "3"], on_exit=[ShutdownOnce()])],
) # 圧縮入れると書き込みに時間かかってplayが終わって即終了だとrecordの終了間に合わない
) # If compression is enabled, it takes a long time to write the record, and if the play finishes immediately, the record will not be finished in time.
if conf["record_only"] == "true"
else ExecuteProcess(cmd=play_cmd, output="screen")
)
Expand Down
Loading