diff --git a/src/RSIPI/config_parser.py b/src/RSIPI/config_parser.py index a35198d..705fea1 100644 --- a/src/RSIPI/config_parser.py +++ b/src/RSIPI/config_parser.py @@ -134,7 +134,8 @@ class ConfigParser: var_dict[tag] = self.get_default_value(var_type) print(f"📄 Assigned Standard Value: '{tag}' -> {var_dict[tag]}") - def rename_tech_keys(self, var_dict): + @staticmethod + def rename_tech_keys(var_dict): """Rename Tech.XX keys to Tech in send and receive variables at the last step.""" tech_data = {} for key in list(var_dict.keys()): @@ -144,7 +145,8 @@ class ConfigParser: var_dict["Tech"] = tech_data # ✅ Store under Tech print(f"✅ Renamed Tech.XX keys to 'Tech': {var_dict['Tech']}") - def get_default_value(self, var_type): + @staticmethod + def get_default_value(var_type): """Returns a default value based on TYPE.""" if var_type == "BOOL": return False diff --git a/src/RSIPI/krl_to_csv_parser.py b/src/RSIPI/krl_to_csv_parser.py index a2c79c0..4c49f91 100644 --- a/src/RSIPI/krl_to_csv_parser.py +++ b/src/RSIPI/krl_to_csv_parser.py @@ -3,6 +3,7 @@ import re from collections import OrderedDict +# noinspection PyTypeChecker class KRLParser: """Parses KUKA KRL .src and .dat files, extracting Cartesian coordinates into CSV.""" diff --git a/src/RSIPI/kuka_visualizer.py b/src/RSIPI/kuka_visualizer.py index 78c5e27..edff8b4 100644 --- a/src/RSIPI/kuka_visualizer.py +++ b/src/RSIPI/kuka_visualizer.py @@ -32,6 +32,9 @@ class KukaRSIVisualizer: plt.savefig(save_path) plt.show() + def has_column(self, col): + return col in self.df.columns + def plot_joint_positions(self, save_path=None): """Plots joint positions over time with safety limit overlays.""" plt.figure() diff --git a/src/RSIPI/network_handler.py b/src/RSIPI/network_handler.py index b756760..d96a102 100644 --- a/src/RSIPI/network_handler.py +++ b/src/RSIPI/network_handler.py @@ -41,7 +41,8 @@ class NetworkProcess(multiprocessing.Process): self.controller_ip_and_port = None - def is_valid_ip(self, ip): + @staticmethod + def is_valid_ip(ip): """Check if an IP address is valid and can be bound on this machine.""" try: socket.inet_aton(ip) # Validate format diff --git a/src/RSIPI/rsi_api.py b/src/RSIPI/rsi_api.py index 02cdd95..078cf46 100644 --- a/src/RSIPI/rsi_api.py +++ b/src/RSIPI/rsi_api.py @@ -240,7 +240,8 @@ class RSIAPI: if export: visualizer.export_graphs() - def parse_krl_to_csv(self, src_file, dat_file, output_file): + @staticmethod + def parse_krl_to_csv(src_file, dat_file, output_file): """ Parses KRL files (.src, .dat) and exports coordinates to CSV. @@ -258,7 +259,8 @@ class RSIAPI: except Exception as e: return f"❌ Error parsing KRL files: {e}" - def inject_rsi(self, input_krl, output_krl=None, rsi_config="RSIGatewayv1.rsi"): + @staticmethod + def inject_rsi(input_krl, output_krl=None, rsi_config="RSIGatewayv1.rsi"): """ Inject RSI commands into a KRL (.src) program file. @@ -274,7 +276,8 @@ class RSIAPI: except Exception as e: return f"❌ RSI injection failed: {e}" - def generate_trajectory(self, start, end, steps=100, space="cartesian"): + @staticmethod + def generate_trajectory(start, end, steps=100, space="cartesian"): """Generates a linear trajectory (Cartesian or Joint).""" return generate_trajectory(start, end, steps, space) diff --git a/src/RSIPI/rsi_config.py b/src/RSIPI/rsi_config.py index a29fd31..9555018 100644 --- a/src/RSIPI/rsi_config.py +++ b/src/RSIPI/rsi_config.py @@ -57,7 +57,8 @@ class RSIConfig: logging.warning(f"⚠️ Failed to load RSI safety limits: {e}") self.safety_limits = {} - def strip_def_prefix(self, tag): + @staticmethod + def strip_def_prefix(tag): """Remove 'DEF_' prefix from a variable name.""" return tag.replace("DEF_", "") @@ -81,7 +82,8 @@ class RSIConfig: else: var_dict[tag] = self.get_default_value(var_type) - def get_default_value(self, var_type): + @staticmethod + def get_default_value(var_type): """Returns a default value based on TYPE.""" if var_type == "BOOL": return False diff --git a/src/RSIPI/safety_manager.py b/src/RSIPI/safety_manager.py index f652c63..d67b59b 100644 --- a/src/RSIPI/safety_manager.py +++ b/src/RSIPI/safety_manager.py @@ -22,14 +22,14 @@ class SafetyManager: Raises ValueError if out of allowed bounds. """ if self.e_stop: - raise RuntimeError(f"SafetyManager: E-STOP active, motion blocked for {path}.") + logging.warning(f"SafetyManager: {path} update blocked (E-STOP active)") + raise RuntimeError(f"SafetyManager: E-STOP active. Motion blocked for {path}.") if path in self.limits: min_val, max_val = self.limits[path] if not (min_val <= value <= max_val): - raise ValueError( - f"SafetyManager: {path}={value} is out of bounds ({min_val} to {max_val})" - ) + logging.warning(f"SafetyManager: {path}={value} blocked (out of bounds {min_val} to {max_val})") + raise ValueError(f"SafetyManager: {path}={value} is out of bounds ({min_val} to {max_val})") return value @@ -52,15 +52,3 @@ class SafetyManager: def is_stopped(self): return self.e_stop - def validate(self, path: str, value: float) -> float: - if self.e_stop: - logging.warning(f"Safety violation: {path} update blocked (E-STOP active)") - raise RuntimeError(f"E-STOP active. Motion blocked for {path}.") - - if path in self.limits: - min_val, max_val = self.limits[path] - if not (min_val <= value <= max_val): - logging.warning(f"Safety violation: {path}={value} blocked (out of bounds {min_val} to {max_val})") - raise ValueError(f"{path}={value} is out of bounds ({min_val} to {max_val})") - - return value