From f1c20b3de21a34b518b3d5d75473e56d71747829 Mon Sep 17 00:00:00 2001 From: Cyrille Nofficial Date: Fri, 28 Jan 2022 18:07:36 +0100 Subject: [PATCH] feat: replace rpi camera with oak camera --- .../base/files/10-vchiq-permissions.rules | 1 + ansible/roles/base/files/80-movidius.rules | 1 + ansible/roles/base/tasks/hardware.yml | 9 +- .../files/robocar/car/deployments.yaml | 92 ++++++++++++++++++- .../files/robocar/car/kustomization.yaml | 5 +- .../files/robocar/common/configmap.yaml | 3 +- 6 files changed, 105 insertions(+), 6 deletions(-) create mode 100644 ansible/roles/base/files/80-movidius.rules diff --git a/ansible/roles/base/files/10-vchiq-permissions.rules b/ansible/roles/base/files/10-vchiq-permissions.rules index 1237f5f..61592fa 100644 --- a/ansible/roles/base/files/10-vchiq-permissions.rules +++ b/ansible/roles/base/files/10-vchiq-permissions.rules @@ -1 +1,2 @@ +# Set group on camera device SUBSYSTEM=="vchiq", GROUP="video", MODE="0660" diff --git a/ansible/roles/base/files/80-movidius.rules b/ansible/roles/base/files/80-movidius.rules new file mode 100644 index 0000000..866e91e --- /dev/null +++ b/ansible/roles/base/files/80-movidius.rules @@ -0,0 +1 @@ +SUBSYSTEM=="usb", ATTRS{idVendor}=="03e7", MODE="0666" diff --git a/ansible/roles/base/tasks/hardware.yml b/ansible/roles/base/tasks/hardware.yml index 8afb535..37ae7b0 100644 --- a/ansible/roles/base/tasks/hardware.yml +++ b/ansible/roles/base/tasks/hardware.yml @@ -30,11 +30,14 @@ # notify: reboot -- name: Set group on camera device +- name: Add udev rules copy: - src: 10-vchiq-permissions.rules - dest: /etc/udev/rules.d/10-vchiq-permissions.rules + src: "{{ item }}" + dest: /etc/udev/rules.d/{{ item }} notify: reboot + with_items: + - 10-vchiq-permissions.rules + - 80-movidius.rules - name: Set groups to pi user diff --git a/ansible/roles/microservices/files/robocar/car/deployments.yaml b/ansible/roles/microservices/files/robocar/car/deployments.yaml index 062e282..9eb79d5 100644 --- a/ansible/roles/microservices/files/robocar/car/deployments.yaml +++ b/ansible/roles/microservices/files/robocar/car/deployments.yaml @@ -7,7 +7,7 @@ metadata: reloader.stakater.com/auto: "true" spec: revisionHistoryLimit: 0 - replicas: 1 + replicas: 0 strategy: type: Recreate selector: @@ -81,6 +81,96 @@ spec: hostPath: path: "/dev/video0" type: CharDevice +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: oak-camera + annotations: + reloader.stakater.com/auto: "true" +spec: + revisionHistoryLimit: 0 + replicas: 1 + strategy: + type: Recreate + selector: + matchLabels: + component: oak-camera + template: + metadata: + labels: + component: oak-camera + spec: + containers: + - name: camera + image: docker.io/cyrilix/robocar-oak-camera + args: + - "--image-width=$(CAMERA_WIDTH)" + - "--image-height=$(CAMERA_HEIGHT)" + securityContext: + #runAsUser: 1234 + #runAsGroup: 44 # Set 44/video group to access to video device + privileged: true + volumeMounts: + #- name: bus-usb + # mountPath: /dev/bus/usb + - name: sys + mountPath: /sys + - name: dev + mountPath: /dev + env: + - name: MQTT_BROKER + valueFrom: + configMapKeyRef: + key: MQTT_BROKER_HOST + name: robocar + - name: MQTT_USERNAME + valueFrom: + secretKeyRef: + key: MQTT_USERNAME + name: mqtt-credentials + - name: MQTT_PASSWORD + valueFrom: + secretKeyRef: + key: MQTT_PASSWORD + name: mqtt-credentials + - name: MQTT_CLIENT_ID + value: rc-oak-camera + - name: MQTT_TOPIC_CAMERA + valueFrom: + configMapKeyRef: + key: MQTT_TOPIC_CAMERA_OAK_COLOR + name: robocar + - name: CAMERA_WIDTH + valueFrom: + configMapKeyRef: + key: CAMERA_WIDTH + name: robocar-camera + - name: CAMERA_HEIGHT + valueFrom: + configMapKeyRef: + key: CAMERA_HEIGHT + name: robocar-camera + - name: MQTT_QOS + value: "0" + - name: TZ + value: "Europe/Paris" + securityContext: + runAsNonRoot: false + runAsUser: 0 + hostNetwork: true + volumes: + - name: bus-usb + hostPath: + path: "/dev/bus/usb" + - name: sys + hostPath: + path: /sys + - name: dev + hostPath: + path: "/dev" + + --- apiVersion: apps/v1 kind: Deployment diff --git a/ansible/roles/microservices/files/robocar/car/kustomization.yaml b/ansible/roles/microservices/files/robocar/car/kustomization.yaml index bbed7f6..cf46b92 100644 --- a/ansible/roles/microservices/files/robocar/car/kustomization.yaml +++ b/ansible/roles/microservices/files/robocar/car/kustomization.yaml @@ -14,4 +14,7 @@ images: newTag: v0.3.0 - name: docker.io/cyrilix/robocar-pca9685 - newTag: v0.4.0-1-gc42086a \ No newline at end of file + newTag: v0.4.0-1-gc42086a + + - name: docker.io/cyrilix/robocar-oak-camera + newTag: v0.0.1-17-g863cddb \ No newline at end of file diff --git a/ansible/roles/microservices/files/robocar/common/configmap.yaml b/ansible/roles/microservices/files/robocar/common/configmap.yaml index 44e06de..13c9790 100644 --- a/ansible/roles/microservices/files/robocar/common/configmap.yaml +++ b/ansible/roles/microservices/files/robocar/common/configmap.yaml @@ -8,7 +8,8 @@ data: MQTT_BROKER: "tcp://192.168.2.221:1883" # Camera - MQTT_TOPIC_CAMERA: car/satanas/part/camera + MQTT_TOPIC_CAMERA: car/satanas/part/camera/camera/color + MQTT_TOPIC_CAMERA_OAK_COLOR: car/satanas/part/camera/color # Radio command