#!/usr/bin/env python3 """ Robotic Arm Feasibility Test System Main entry point for the robotic arm simulation system. This system tests the feasibility of robotic arm operations in complex environments, specifically transporting objects through obstacles. """ import sys import json from pathlib import Path # Add src directory to Python path PROJECT_ROOT = Path(__file__).parent.absolute() sys.path.insert(0, str(PROJECT_ROOT / 'src')) from src.gui.main_window import MainWindow # Configuration constants CONFIG_FILE = "config.json" REQUIRED_MODULES = ['pybullet', 'tkinter', 'numpy'] def check_dependencies(): """Check if all required dependencies are installed""" missing = [] for module in REQUIRED_MODULES: try: __import__(module) except ImportError: missing.append(module) if not missing: return True print(f"Missing dependencies: {', '.join(missing)}") print(f"Install with: pip install {' '.join(missing)}") return False def verify_environment(): """Verify that the environment is properly configured""" # Check configuration file config_path = PROJECT_ROOT / CONFIG_FILE if not config_path.exists(): print(f"Error: {CONFIG_FILE} not found") return False # Check robot model file try: with open(config_path, 'r', encoding='utf-8') as f: config = json.load(f) model_path = config.get('robot', {}).get('model_path', '') if model_path and not Path(model_path).exists(): print(f"Warning: Robot model not found: {model_path}") # Continue anyway - let the simulation handle missing model except (json.JSONDecodeError, IOError) as e: print(f"Error reading configuration: {e}") return False return True def main(): """Main entry point""" # Verify dependencies and environment if not check_dependencies(): sys.exit(1) if not verify_environment(): sys.exit(1) # Start application try: app = MainWindow() app.run() except KeyboardInterrupt: pass # Clean exit on Ctrl+C except Exception as e: print(f"Fatal error: {e}") sys.exit(1) if __name__ == "__main__": main()