From eb235f869737f2878445bcdf6c49f08467561158 Mon Sep 17 00:00:00 2001 From: Marina Moreira <67443181+marinagmoreira@users.noreply.github.com> Date: Tue, 27 Feb 2024 16:18:19 -0800 Subject: [PATCH] fixing path in granite (#149) * fixing path in granite * suggestion * changing env var name --- .../src/survey_planner/command_astrobee.py | 23 +++++++++++-------- .../src/survey_planner/problem_generator.py | 7 +++--- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/astrobee/survey_manager/survey_planner/src/survey_planner/command_astrobee.py b/astrobee/survey_manager/survey_planner/src/survey_planner/command_astrobee.py index 6ac6d0f4..c4f36e1f 100755 --- a/astrobee/survey_manager/survey_planner/src/survey_planner/command_astrobee.py +++ b/astrobee/survey_manager/survey_planner/src/survey_planner/command_astrobee.py @@ -118,9 +118,9 @@ def get_ops_plan_path(): return "/opt/astrobee/ops/gds/plans/" # Check if the environment variable $ASTROBEE_OPS exists - astrobee_ops_path = os.getenv("ASTROBEE_OPS") + astrobee_ops_path = os.getenv("OPS_REPO") if astrobee_ops_path: - return os.path.join(astrobee_ops_path, "gds/plans") + return os.path.join(astrobee_ops_path, "dock_scripts/hsc/gds/plans") # Check if the symlink ~/gds/latest/ControlStationConfig/IssWorld exists symlink_path = os.path.expanduser("~/gds/latest/ControlStationConfig/IssWorld") @@ -128,7 +128,7 @@ def get_ops_plan_path(): # Get the target of the symlink target_path = os.path.realpath(symlink_path) # Construct the relative path ../../plans - relative_path = os.path.join(target_path, "../../plans") + relative_path = os.path.join(target_path, "../../../dock_scripts/hsc/gds/plans") return relative_path # Return None if none of the conditions are met @@ -392,7 +392,7 @@ def send_command_recursive(self, command): while exit_code != 0 and not rospy.is_shutdown(): self.write_output_once( - "Exit code non-zero: Do you want to repeat the survey? (yes/no/skip): \n" + "Exit code non-zero: Do you want to repeat the send command? (yes/no/skip): \n" ) repeat = self.read_input_once().lower() loginfo(f"user input: {repeat}") @@ -581,6 +581,7 @@ def get_quick_stereo_survey(fplan_path: pathlib.Path) -> pathlib.Path: @dataclass class SurveyManagerExecutor: process_executor: ProcessExecutor + command_executor: CommandExecutor config_static: YamlMapping fsw_ns_args: List[str] cmd_exec_ns: str @@ -604,14 +605,16 @@ def move(self, from_name: str, to_name: str) -> int: to_name, ) if exposure_value != 0: - cexec = CommandExecutor(self.cmd_exec_ns) - exit_code = first_non_zero(exit_code, cexec.change_exposure(exposure_value)) + exit_code = first_non_zero( + exit_code, self.command_executor.change_exposure(exposure_value) + ) # Change map if needed map_name = map_change(self.config_static, from_name, to_name) if map_name != "": - cexec = CommandExecutor(self.cmd_exec_ns) - exit_code = first_non_zero(exit_code, cexec.change_map(map_name)) + exit_code = first_non_zero( + exit_code, self.command_executor.change_map(map_name) + ) return exit_code @@ -645,7 +648,9 @@ def survey_manager_executor(args, run, config_static, process_executor, quick: b cmd_exec_ns = "/" + args["robot"] command_executor = CommandExecutor(cmd_exec_ns) - sm_exec = SurveyManagerExecutor(process_executor, config_static, ns, cmd_exec_ns) + sm_exec = SurveyManagerExecutor( + process_executor, command_executor, config_static, ns, cmd_exec_ns + ) # Initialize exit code exit_code = 0 diff --git a/astrobee/survey_manager/survey_planner/src/survey_planner/problem_generator.py b/astrobee/survey_manager/survey_planner/src/survey_planner/problem_generator.py index 8d3db54e..2b19fa94 100755 --- a/astrobee/survey_manager/survey_planner/src/survey_planner/problem_generator.py +++ b/astrobee/survey_manager/survey_planner/src/survey_planner/problem_generator.py @@ -57,6 +57,7 @@ TypeVar, ) +import rospkg import yaml GOAL_TYPE_OPTIONS = ("panorama", "stereo", "robot_at", "let_other_robot_reach") @@ -70,13 +71,13 @@ "let-other-robot-reach", ) -THIS_DIR = pathlib.Path(__file__).resolve().parent CWD = pathlib.Path.cwd() +rospack = rospkg.RosPack() DATA_DIR = pathlib.Path( - os.path.relpath(str((THIS_DIR / ".." / ".." / "data").resolve()), CWD) + os.path.relpath(pathlib.Path(rospack.get_path("survey_planner")) / "data", CWD) ) PDDL_DIR = pathlib.Path( - os.path.relpath(str((THIS_DIR / ".." / ".." / "pddl").resolve()), CWD) + os.path.relpath(pathlib.Path(rospack.get_path("survey_planner")) / "pddl", CWD) ) DEFAULT_CONFIGS = [ DATA_DIR / "jem_survey_static.yaml",