Skip to content
This repository has been archived by the owner on Dec 20, 2024. It is now read-only.

Commit

Permalink
fix: bug
Browse files Browse the repository at this point in the history
  • Loading branch information
hayato-m126 committed Oct 20, 2023
1 parent e8a0c03 commit 5e2bfec
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 24 deletions.
51 changes: 28 additions & 23 deletions driving_log_replayer_cli/simulation/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import termcolor
import yaml


@dataclass(frozen=True)
class AutowareEssentialParameter:
map_path: Path = Path("/dlr_not_exist_path")
Expand Down Expand Up @@ -56,22 +57,24 @@ def clean_up_cmd(cls) -> str:
# kill zombie ros2 process
# kill rviz
# sleep 1 sec
return """echo $?
pgrep ros | awk \'{ print "kill -9 $(pgrep -P ", $1, ") > /dev/null 2>&1" }\' | sh
pgrep ros | awk \'{ print "kill -9 ", $1, " > /dev/null 2>&1" }\' | sh
pgrep rviz | awk \'{ print "kill -9 $(pgrep -P ", $1, ") > /dev/null 2>&1" }\' | sh
pgrep rviz | awk \'{ print "kill -9 ", $1, " > /dev/null 2>&1" }\' | sh
sleep 1
"""
return """
echo $?
pgrep ros | awk \'{ print "kill -9 $(pgrep -P ", $1, ") > /dev/null 2>&1" }\' | sh
pgrep ros | awk \'{ print "kill -9 ", $1, " > /dev/null 2>&1" }\' | sh
pgrep rviz | awk \'{ print "kill -9 $(pgrep -P ", $1, ") > /dev/null 2>&1" }\' | sh
pgrep rviz | awk \'{ print "kill -9 ", $1, " > /dev/null 2>&1" }\' | sh
sleep 1
"""

def run(self) -> bool:
if not self.__output_directory.exists():
return False
generated_cmd = (
f"source {self.__autoware_path.joinpath('install', 'setup.bash').as_posix()}\n"
)
for dataset_path in self.__data_directory.glob("**"):
# pathlib.Path.glob("**") detect directories only
for dataset_path in self.__data_directory.glob("*"):
if not dataset_path.is_dir():
continue
launch_command = self._create_launch_cmd(dataset_path)
if launch_command is None:
continue
Expand Down Expand Up @@ -117,18 +120,18 @@ def _create_common_arg(
essential_param: AutowareEssentialParameter,
) -> str:
return f"""{optional_arg}\
scenario_path:={scenario_path.as_posix()} \
result_json_path:={output_path.joinpath("result.json").as_posix()} \
play_rate:={self.__rate} \
play_delay:={self.__delay} \
input_bag:={input_bag.as_posix()} \
result_bag_path:={output_path.joinpath("result_bag").as_posix()} \
map_path:={essential_param.map_path} \
vehicle_model:={essential_param.vehicle_model} \
sensor_model:={essential_param.sensor_model} \
vehicle_id:={essential_param.vehicle_id} \
rviz:=true
"""
scenario_path:={scenario_path.as_posix()} \
result_json_path:={output_path.joinpath("result.json").as_posix()} \
play_rate:={self.__rate} \
play_delay:={self.__delay} \
input_bag:={input_bag.as_posix()} \
result_bag_path:={output_path.joinpath("result_bag").as_posix()} \
map_path:={essential_param.map_path} \
vehicle_model:={essential_param.vehicle_model} \
sensor_model:={essential_param.sensor_model} \
vehicle_id:={essential_param.vehicle_id} \
rviz:=true\
"""

def _cmd_use_bag_only(
self,
Expand Down Expand Up @@ -212,7 +215,7 @@ def _cmd_use_t4_dataset(
continue

use_case_name = scenario_yaml_obj["Evaluation"]["UseCaseName"]
launch_base_command = f"ros2 launch driving_log_replayer {use_case_name}.launch.py"
launch_base_command = f"ros2 launch driving_log_replayer {use_case_name}.launch.py "
optional_arg = ""
perception_mode: str | None = scenario_yaml_obj.get("PerceptionMode")
if perception_mode is not None:
Expand All @@ -235,7 +238,9 @@ def _cmd_use_t4_dataset(
)
# t4_dataset
launch_args += f" t4_dataset_path:={t4_dataset_path}"
launch_args += f" result_archive_path:={output_dir_per_dataset.joinpath("result_archive")}"
launch_args += (
f" result_archive_path:={output_dir_per_dataset.joinpath('result_archive')}"
)
launch_args += f" sensing:={dataset[key].get('LaunchSensing', True)}"
launch_command = launch_base_command + launch_args + "\n"
launch_command_for_all_dataset += launch_command
Expand Down
2 changes: 1 addition & 1 deletion driving_log_replayer_cli/simulation/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def __init__(
)
is_executable = generator.run()
if is_executable:
cmd = "/bin/bash " + generator.script_path
cmd = "/bin/bash " + generator.script_path.as_posix()
subprocess.run(cmd, shell=True)
if self.__output_json:
convert(self.__output_directory)
Expand Down

0 comments on commit 5e2bfec

Please sign in to comment.