From 01f5076d0c6162121196d71edba11f996fb2e848 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Ellensohn?= Date: Wed, 13 Sep 2023 10:38:42 +0200 Subject: [PATCH] update --- robot_config.py | 57 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 robot_config.py diff --git a/robot_config.py b/robot_config.py new file mode 100644 index 0000000..48592bd --- /dev/null +++ b/robot_config.py @@ -0,0 +1,57 @@ +import subprocess + +# Define a list to keep track of running services +running_services = [] + +# Function to check if a service is already running +def is_service_running(service_name): + return service_name in running_services + +# Function to start a service +def start_service(service_name): + if not is_service_running(service_name): + print(f"Starting {service_name}...") + subprocess.run(["docker-compose", "up", "-d", service_name]) + running_services.append(service_name) + else: + print(f"{service_name} is already running.") + +# Function to stop a service +def stop_service(service_name): + if is_service_running(service_name): + print(f"Stopping {service_name}...") + subprocess.run(["docker-compose", "down", "-v", "--remove-orphans", service_name]) + running_services.remove(service_name) + else: + print(f"{service_name} is not running.") + +# Main program +if __name__ == "__main__": + while True: + print("Options:") + print("1. Start Controller, Teleop, RSP, Lidar") + print("2. Start AMCL and Navigation") + print("3. Start Mapping and Navigation") + print("4. Stop AMCL and Mapping") + print("5. Quit") + + choice = input("Enter your choice: ") + + if choice == "1": + start_service("controller") + start_service("teleop") + start_service("rsp") + start_service("lidar") + elif choice == "2": + start_service("amcl") + start_service("navigation") + elif choice == "3": + start_service("mapping") + start_service("navigation") + elif choice == "4": + stop_service("amcl") + stop_service("mapping") + elif choice == "5": + break + else: + print("Invalid choice. Please try again.")