소스 검색

Persist theta (#83)

* persist theta after reset

* prep container

* handle edge case

* bump version
Tuan Nguyen 3 달 전
부모
커밋
d0917efc0d
4개의 변경된 파일26개의 추가작업 그리고 10개의 파일을 삭제
  1. 7 3
      Dockerfile
  2. 1 1
      VERSION
  3. 15 5
      docker-compose.yml
  4. 3 1
      modules/connection/connection_manager.py

+ 7 - 3
Dockerfile

@@ -10,13 +10,17 @@ WORKDIR /app
 
 COPY requirements.txt ./
 RUN apt-get update && apt-get install -y --no-install-recommends \
-        gcc libjpeg-dev zlib1g-dev git \
+        gcc g++ make libjpeg-dev zlib1g-dev git \
+        # GPIO/NeoPixel support for DW LEDs
+        python3-dev python3-pip \
+        libgpiod2 libgpiod-dev \
+        scons \
     && pip install --upgrade pip \
     && pip install --no-cache-dir -r requirements.txt \
-    && apt-get purge -y gcc \
+    && apt-get purge -y gcc g++ make scons \
     && rm -rf /var/lib/apt/lists/*
 
 COPY . .
 
 EXPOSE 8080
-CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8080"]
+CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8080"]

+ 1 - 1
VERSION

@@ -1 +1 @@
-3.3.3
+3.3.4

+ 15 - 5
docker-compose.yml

@@ -3,13 +3,23 @@ services:
     build: . # Uncomment this if you need to build
     image: ghcr.io/tuanchris/dune-weaver:main # Use latest production image
     restart: always
-    ports:
-      - "8080:8080" # Map port 8080 of the container to 8080 of the host (access via http://localhost:8080)
+    # ports:
+    #   - "8080:8080" # Map port 8080 of the container to 8080 of the host (access via http://localhost:8080)
+    network_mode: "host" # Use host network for device access
     volumes:
       - .:/app
       # Mount timezone file from host for Still Sands scheduling
       - /etc/timezone:/etc/host-timezone:ro
+      # Mount systemd to allow host shutdown
+      - /bin/systemctl:/bin/systemctl:ro
+      - /run/systemd/system:/run/systemd/system:ro
+      - /var/run/dbus/system_bus_socket:/var/run/dbus/system_bus_socket:ro
+      - /sys/fs/cgroup:/sys/fs/cgroup:ro
+      # Mount GPIO for DW LEDs (NeoPixel control)
+      - /sys:/sys
     devices:
-      - "/dev/ttyACM0:/dev/ttyACM0"
-    privileged: true
-    container_name: dune-weaver
+      - "/dev/ttyACM0:/dev/ttyACM0"  # Serial device for stepper motors
+      - "/dev/gpiomem:/dev/gpiomem"  # GPIO memory access for DW LEDs
+      - "/dev/mem:/dev/mem"          # Direct memory access for PWM
+    privileged: true  # Required for GPIO/PWM access
+    container_name: dune-weaver

+ 3 - 1
modules/connection/connection_manager.py

@@ -450,7 +450,9 @@ def home(timeout=15):
             idle_reached = check_idle()
 
             if idle_reached:
-                state.current_theta = state.current_rho = 0
+                state.current_rho = 0
+                if not state.current_theta:
+                    state.current_theta = 0
                 homing_success = True
                 logger.info("Homing completed and device is idle")
             else: