|
|
@@ -1,14 +1,16 @@
|
|
|
import time
|
|
|
import pigpio
|
|
|
+from robot_control.src.utils.config import ConfigParser
|
|
|
|
|
|
class PumpController:
|
|
|
- def __init__(self, config, logger):
|
|
|
+ def __init__(self, config:ConfigParser, logger):
|
|
|
self.logger = logger
|
|
|
- gpio_config = config.get_gpio_config()
|
|
|
- self.pump_pin = gpio_config.get("pump_pin")
|
|
|
- self.pressure_threshold_on = gpio_config.get("pressure_threshold_on")
|
|
|
- self.pressure_threshold_off = gpio_config.get("pressure_threshold_off")
|
|
|
- self.pump_watchdog_timeout = gpio_config.get("pump_watchdog_timeout")
|
|
|
+ vacuum_config = config.get_vacuum_config()
|
|
|
+ self.pump_pin = vacuum_config.get("pump_gpio_pin")
|
|
|
+ self.pressure_threshold_on = vacuum_config.get("min_pressure_bar")
|
|
|
+ self.pressure_threshold_off = vacuum_config.get("max_pressure_bar")
|
|
|
+ self.pump_watchdog_timeout = vacuum_config.get("pump_watchdog_timeout", 30) # Default to 30 seconds
|
|
|
+ self.gripping_threshold = vacuum_config.get("gripping_threshold_v")
|
|
|
self.pump_last_activated = None
|
|
|
self.pump_active = False
|
|
|
|
|
|
@@ -19,7 +21,10 @@ class PumpController:
|
|
|
self.pi.write(self.pump_pin, 0) # Ensure pump is off initially
|
|
|
self.logger.info(f"Pump GPIO pin {self.pump_pin} initialized using pigpio")
|
|
|
|
|
|
- def handle_pressure_reading(self, value):
|
|
|
+ def check_endeffector_state(self, value) -> bool:
|
|
|
+ return value < self.gripping_threshold
|
|
|
+
|
|
|
+ def handle_tank_reading(self, value):
|
|
|
current_time = time.time()
|
|
|
|
|
|
# Check if pump needs to be deactivated due to watchdog timeout
|