diff --git a/ansible/roles/k3s/defaults/main.yml b/ansible/roles/k3s/defaults/main.yml index f72ce83..47a4b44 100644 --- a/ansible/roles/k3s/defaults/main.yml +++ b/ansible/roles/k3s/defaults/main.yml @@ -1,3 +1,3 @@ --- -k3s_version: v1.27.6%2Bk3s1 +k3s_version: v1.28.3%2Bk3s2 k3s_url: https://github.com/k3s-io/k3s/releases/download/{{ k3s_version }}/k3s-{{ arch | default('armhf') }} diff --git a/ansible/roles/k3s/tasks/containerd.yml b/ansible/roles/k3s/tasks/containerd.yml index 1457b8f..a15737e 100644 --- a/ansible/roles/k3s/tasks/containerd.yml +++ b/ansible/roles/k3s/tasks/containerd.yml @@ -1,3 +1,4 @@ +--- - name: Add apt key ansible.builtin.apt_key: url: https://download.docker.com/linux/debian/gpg @@ -5,7 +6,7 @@ - name: Add docker-ce repository apt_repository: - repo: deb [arch={{ arch | default('armhf') }}] https://download.docker.com/linux/debian {{ ansible_distribution_release }} stable + repo: deb [arch={{ arch | default('armhf') }}] https://download.docker.com/linux/debian bookworm stable state: present filename: 'docker' diff --git a/ansible/roles/microservices/files/robocar/car/configmap.yaml b/ansible/roles/microservices/files/robocar/car/configmap.yaml index e853b1c..bb119a9 100644 --- a/ansible/roles/microservices/files/robocar/car/configmap.yaml +++ b/ansible/roles/microservices/files/robocar/car/configmap.yaml @@ -7,8 +7,9 @@ data: ############################ # STEERING PWM - PCA9685 # ############################ - STEERING_PCA9685_LEFT_PWM: "995" - STEERING_PCA9685_RIGHT_PWM: "2017" + #STEERING_PCA9685_LEFT_PWM: "995" + STEERING_PCA9685_LEFT_PWM: "1265" + STEERING_PCA9685_RIGHT_PWM: "1650" STEERING_PCA9685_CENTER_PWM: "1440" ########################### diff --git a/ansible/roles/microservices/files/robocar/car/deployments.yaml b/ansible/roles/microservices/files/robocar/car/deployments.yaml index 1bb0f15..571b20e 100644 --- a/ansible/roles/microservices/files/robocar/car/deployments.yaml +++ b/ansible/roles/microservices/files/robocar/car/deployments.yaml @@ -108,9 +108,10 @@ spec: - "--image-width=$(CAMERA_WIDTH)" - "--image-height=$(CAMERA_HEIGHT)" - "--objects-threshold=$(THRESHOLD_OBJECTS)" + - "--camera-fps=$(CAMERA_FPS)" - "--log=info" securityContext: - runAsUser: 1234 + runAsUser: 0 privileged: true volumeMounts: - name: sys @@ -149,6 +150,11 @@ spec: configMapKeyRef: key: OBJECTS_THRESHOLD name: robocar-objects + - name: CAMERA_FPS + valueFrom: + configMapKeyRef: + key: CAMERA_FPS + name: robocar-camera - name: CAMERA_WIDTH valueFrom: configMapKeyRef: @@ -199,7 +205,7 @@ spec: args: - "--mqtt-retain=false" - "--throttle-channel=15" - - "--steering-channel=14" + - "--steering-channel=13" - "--throttle-zero-pwm=$(THROTTLE_PCA9685_ZERO_PWM)" - "--throttle-min-pwm=$(THROTTLE_PCA9685_MIN_PWM)" - "--throttle-max-pwm=$(THROTTLE_PCA9685_MAX_PWM)" diff --git a/ansible/roles/microservices/files/robocar/car/kustomization.yaml b/ansible/roles/microservices/files/robocar/car/kustomization.yaml index 8332308..b9c7dc6 100644 --- a/ansible/roles/microservices/files/robocar/car/kustomization.yaml +++ b/ansible/roles/microservices/files/robocar/car/kustomization.yaml @@ -5,16 +5,16 @@ kind: Kustomization namespace: robocar resources: - - ../common + - ../common-car - deployments.yaml - configmap.yaml images: - name: docker.io/cyrilix/robocar-camera - newTag: v0.3.0 + newTag: v0.3.1 - name: docker.io/cyrilix/robocar-pca9685 newTag: v0.6.4 - name: git.cyrilix.bzh/robocars/robocar-oak-camera - newTag: v0.2.0-28-g7ebd909 + newTag: v0.4.0 diff --git a/ansible/roles/microservices/files/robocar/common-car/deployments.yaml b/ansible/roles/microservices/files/robocar/common-car/deployments.yaml new file mode 100644 index 0000000..cbcc148 --- /dev/null +++ b/ansible/roles/microservices/files/robocar/common-car/deployments.yaml @@ -0,0 +1,335 @@ +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: arduino + annotations: + reloader.stakater.com/auto: "true" +spec: + revisionHistoryLimit: 0 + replicas: 1 + strategy: + type: Recreate + selector: + matchLabels: + component: arduino + template: + metadata: + labels: + component: arduino + spec: + containers: + - name: arduino + image: docker.io/cyrilix/robocar-arduino + args: + - "-device=/dev/ttyAMA1" + - "-baud=115200" + - "-mqtt-retain=false" + - "--steering-left-pwm=$(STEERING_LEFT_PWM)" + - "--steering-right-pwm=$(STEERING_RIGHT_PWM)" + - "--steering-center-pwm=$(STEERING_CENTER_PWM)" + - "--throttle-min-pwm=$(THROTTLE_MIN_PWM)" + - "--throttle-max-pwm=$(THROTTLE_MAX_PWM)" + - "--throttle-center-pwm=$(THROTTLE_ZERO_PWM)" + - '--throttle-feedback-config=/etc/robocar/thresholds.json' + - '--ctrl-throttle-min-pwm=$(CTRL_THROTTLE_MIN_PWM)' + - '--ctrl-throttle-max-pwm=$(CTRL_THROTTLE_MAX_PWM)' + - "-log=info" + volumeMounts: + - mountPath: "/dev/ttyAMA0" + name: serial + - mountPath: "/etc/robocar" + name: robocar + securityContext: + privileged: true + runAsUser: 1234 + runAsGroup: 20 # Set 20/dialout group to access to serial device + envFrom: + - configMapRef: + name: robocar-throttle-pwm + - configMapRef: + name: robocar-steering-pwm + env: + - name: MQTT_BROKER + valueFrom: + configMapKeyRef: + key: MQTT_BROKER + 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-arduino + - name: MQTT_TOPIC_THROTTLE + valueFrom: + configMapKeyRef: + key: MQTT_TOPIC_RC_THROTTLE + name: robocar + - name: MQTT_TOPIC_STEERING + valueFrom: + configMapKeyRef: + key: MQTT_TOPIC_RC_STEERING + name: robocar + - name: MQTT_TOPIC_DRIVE_MODE + valueFrom: + configMapKeyRef: + key: MQTT_TOPIC_RC_DRIVE_MODE + name: robocar + - name: MQTT_TOPIC_SWITCH_RECORD + valueFrom: + configMapKeyRef: + key: MQTT_TOPIC_RC_SWITCH_RECORD + name: robocar + - name: MQTT_TOPIC_THROTTLE_FEEDBACK + valueFrom: + configMapKeyRef: + name: robocar + key: MQTT_TOPIC_THROTTLE_FEEDBACK + - name: MQTT_TOPIC_MAX_THROTTLE_CTRL + valueFrom: + configMapKeyRef: + name: robocar + key: MQTT_TOPIC_MAX_THROTTLE_CTRL + - name: CTRL_THROTTLE_MIN_PWM + valueFrom: + configMapKeyRef: + name: robocar-throttle-pwm + key: CTRL_THROTTLE_MIN_PWM + - name: CTRL_THROTTLE_MAX_PWM + valueFrom: + configMapKeyRef: + name: robocar-throttle-pwm + key: CTRL_THROTTLE_MAX_PWM + - name: MQTT_QOS + value: "0" + - name: TZ + value: "Europe/Paris" + volumes: + - name: serial + hostPath: + path: /dev/ttyAMA0 + type: CharDevice + - name: robocar + configMap: + name: robocar-objects + +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: led + annotations: + reloader.stakater.com/auto: "true" +spec: + revisionHistoryLimit: 0 + replicas: 1 + strategy: + type: Recreate + selector: + matchLabels: + component: led + template: + metadata: + labels: + component: led + spec: + containers: + - name: led + image: docker.io/cyrilix/robocar-led + args: + - "-mqtt-retain=false" + - "-log=info" + volumeMounts: + - name: gpiomem + mountPath: "/dev/gpiomem" + - name: gpiochip0 + mountPath: "/dev/gpiochip0" + - name: gpiochip1 + mountPath: "/dev/gpiochip1" + securityContext: + privileged: true + runAsUser: 1234 + runAsGroup: 997 # Set 997/gpio group to access to serial device + env: + - name: MQTT_BROKER + valueFrom: + configMapKeyRef: + key: MQTT_BROKER + 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-led + - name: MQTT_TOPIC_DRIVE_MODE + valueFrom: + configMapKeyRef: + key: MQTT_TOPIC_RC_DRIVE_MODE + name: robocar + - name: MQTT_TOPIC_RECORD + valueFrom: + configMapKeyRef: + key: MQTT_TOPIC_RC_SWITCH_RECORD + name: robocar + - name: MQTT_TOPIC_SPEED_ZONE + valueFrom: + configMapKeyRef: + key: MQTT_TOPIC_SPEED_ZONE + name: robocar + - name: MQTT_TOPIC_THROTTLE + valueFrom: + configMapKeyRef: + key: MQTT_TOPIC_THROTTLE + name: robocar + - name: MQTT_QOS + value: "0" + - name: TZ + value: "Europe/Paris" + volumes: + - name: gpiomem + hostPath: + path: /dev/gpiomem + type: CharDevice + - name: gpiochip0 + hostPath: + path: /dev/gpiochip0 + type: CharDevice + - name: gpiochip1 + hostPath: + path: /dev/gpiochip1 + type: CharDevice +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: tflite-steering + annotations: + reloader.stakater.com/auto: "true" +spec: + revisionHistoryLimit: 0 + replicas: 1 + strategy: + type: Recreate + selector: + matchLabels: + component: tflite-steering + template: + metadata: + labels: + component: tflite-steering + spec: + containers: + - name: tflite-steering + image: docker.io/cyrilix/robocar-steering-tflite-edgetpu + args: + #- "--model=/model/$(MODEL_STEERING)" + - "--oci-model-registry=$(OCI_IMAGE_MODEL_REGISTRY)" + - "--oci-model-repository=$(OCI_IMAGE_MODEL_REPOSITORY)" + - "--oci-model-tag=$(OCI_IMAGE_MODEL_TAG)" + - "--edge-verbosity=0" + - "--log=info" + securityContext: + runAsUser: 0 + runAsGroup: 0 + privileged: true + volumeMounts: + - name: models + mountPath: /model + - name: bus-usb + mountPath: /dev/bus/usb + - name: sys + mountPath: /sys + env: + - name: MQTT_BROKER + valueFrom: + configMapKeyRef: + key: MQTT_BROKER + 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-tflite-steering + - name: MQTT_TOPIC_CAMERA + valueFrom: + configMapKeyRef: + key: MQTT_TOPIC_CAMERA_OAK_COLOR + name: robocar + - name: MQTT_TOPIC_STEERING + valueFrom: + configMapKeyRef: + key: MQTT_TOPIC_TF_STEERING + name: robocar + - name: OCI_IMAGE_MODEL_REGISTRY + valueFrom: + configMapKeyRef: + key: OCI_IMAGE_MODEL_REGISTRY + name: robocar-models + - name: OCI_IMAGE_MODEL_REPOSITORY + valueFrom: + configMapKeyRef: + key: OCI_IMAGE_MODEL_REPOSITORY + name: robocar-models + - name: OCI_IMAGE_MODEL_TAG + valueFrom: + configMapKeyRef: + key: OCI_IMAGE_MODEL_TAG + name: robocar-models + #- name: MODEL_STEERING + # valueFrom: + # configMapKeyRef: + # key: MODEL_STEERING + # name: robocar-models + #- name: MODEL_IMAGE_WIDTH + # valueFrom: + # configMapKeyRef: + # key: MODEL_IMAGE_WIDTH + # name: robocar-models + #- name: MODEL_IMAGE_HEIGHT + # valueFrom: + # configMapKeyRef: + # key: MODEL_IMAGE_HEIGHT + # name: robocar-models + #- name: HORIZON + # valueFrom: + # configMapKeyRef: + # key: HORIZON + # name: robocar-models + - name: MQTT_QOS + value: "0" + - name: LD_LIBRARY_PATH + value: "/usr/local/lib/:/usr/lib" + - name: TZ + value: "Europe/Paris" + volumes: + - name: models + hostPath: + path: /home/pi/models/steering + type: DirectoryOrCreate + - name: bus-usb + hostPath: + path: /dev/bus/usb + - name: sys + hostPath: + path: /sys diff --git a/ansible/roles/microservices/files/robocar/common-car/kustomization.yaml b/ansible/roles/microservices/files/robocar/common-car/kustomization.yaml new file mode 100644 index 0000000..c3c573c --- /dev/null +++ b/ansible/roles/microservices/files/robocar/common-car/kustomization.yaml @@ -0,0 +1,21 @@ +--- +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization + +resources: + - ../common + #- namespace.yaml + - deployments.yaml + #- services.yaml + #- configmap.yaml + +images: + - name: docker.io/cyrilix/robocar-arduino + newTag: v0.11.0 + + - name: docker.io/cyrilix/robocar-led + newTag: v0.7.0 + + - name: docker.io/cyrilix/robocar-steering-tflite-edgetpu + #newTag: v0.5.3 + newTag: v0.6.1 diff --git a/ansible/roles/microservices/files/robocar/common-car/secrets.yaml b/ansible/roles/microservices/files/robocar/common-car/secrets.yaml new file mode 100644 index 0000000..338dc21 --- /dev/null +++ b/ansible/roles/microservices/files/robocar/common-car/secrets.yaml @@ -0,0 +1,9 @@ +--- +apiVersion: v1 +kind: Secret +metadata: + name: mqtt-credentials + namespace: robocar +stringData: + MQTT_USERNAME: satanas + MQTT_PASSWORD: satanas diff --git a/ansible/roles/microservices/files/robocar/common/configmap.yaml b/ansible/roles/microservices/files/robocar/common/configmap.yaml index 76f57da..8a72980 100644 --- a/ansible/roles/microservices/files/robocar/common/configmap.yaml +++ b/ansible/roles/microservices/files/robocar/common/configmap.yaml @@ -20,7 +20,7 @@ data: MQTT_TOPIC_RC_STEERING: car/satanas/part/rc/steering MQTT_TOPIC_RC_SWITCH_RECORD: car/satanas/part/rc/switch_record MQTT_TOPIC_RC_DRIVE_MODE: car/satanas/part/rc/drive_mode - + MQTT_TOPIC_MAX_THROTTLE_CTRL: car/satanas/part/rc/max_throttle MQTT_TOPIC_TF_STEERING: car/satanas/part/tflite/steering @@ -28,6 +28,8 @@ data: MQTT_TOPIC_THROTTLE: car/satanas/part/throttle MQTT_TOPIC_STEERING: car/satanas/part/steering + MQTT_TOPIC_SPEED_ZONE: car/satanas/part/speed_zone + # Road detection MQTT_TOPIC_ROAD: car/satanas/part/road @@ -52,16 +54,35 @@ data: # THROTTLE_MIN: "0.10" # THROTTLE_MAX: "0.12" + ## Slow auto-pilot + #################### + #THROTTLE_MIN: "0.10" + #THROTTLE_MAX: "0.10" + ## Secure auto-pilot #################### - THROTTLE_MIN: "0.10" - THROTTLE_MAX: "0.12" + #THROTTLE_MIN: "0.11" + #THROTTLE_MAX: "0.12" + + ## bump auto-pilot + #################### + THROTTLE_MIN: "0.11" + THROTTLE_MAX: "0.11" + + ## bump speed auto-pilot + #################### + #THROTTLE_MIN: "0.12" + #THROTTLE_MAX: "0.18" ## Speed auto-pilot ################### - # THROTTLE_MIN: "0.11" - # THROTTLE_MAX: "0.13" + #THROTTLE_MIN: "0.11" + #THROTTLE_MAX: "0.13" + ## Speed race auto-pilot + ################### + #THROTTLE_MIN: "0.11" + #THROTTLE_MAX: "0.15" --- apiVersion: v1 @@ -69,12 +90,13 @@ kind: ConfigMap metadata: name: robocar-steering-pwm data: + ################ # STEERING PWM # ################ - STEERING_LEFT_PWM: "1000" - STEERING_RIGHT_PWM: "1985" - STEERING_CENTER_PWM: "1492" + STEERING_LEFT_PWM: "1004" + STEERING_RIGHT_PWM: "2048" + STEERING_CENTER_PWM: "1514" ############################ # STEERING PWM - SECOND RC # @@ -83,18 +105,26 @@ data: STEERING_SECONDARY_RIGHT_PWM: "2141" STEERING_SECONDARY_CENTER_PWM: "1641" + ################################# + # OLD RADIO-COMAND STEERING PWM # + ################################# + #STEERING_LEFT_PWM: "1000" + #STEERING_RIGHT_PWM: "1985" + #STEERING_CENTER_PWM: "1492" + --- apiVersion: v1 kind: ConfigMap metadata: name: robocar-throttle-pwm data: + ################ # THROTTLE PWM # ################ - THROTTLE_MIN_PWM: "994" - THROTTLE_MAX_PWM: "1979" - THROTTLE_ZERO_PWM: "1484" + THROTTLE_MIN_PWM: "980" + THROTTLE_MAX_PWM: "2046" + THROTTLE_ZERO_PWM: "1509" ########################### # THROTTLE PWM - SECOND RC # @@ -103,6 +133,18 @@ data: THROTTLE_SECONDARY_MAX_PWM: "1975" THROTTLE_SECONDARY_ZERO_PWM: "1506" + #################### + # OLD THROTTLE PWM # + #################### + # THROTTLE_MIN_PWM: "994" + # THROTTLE_MAX_PWM: "1979" + # THROTTLE_ZERO_PWM: "1484" + + ############################ + # MAX THROTTLE CONTROL PWM # + ############################ + CTRL_THROTTLE_MIN_PWM: "1000" + CTRL_THROTTLE_MAX_PWM: "2000" --- apiVersion: v1 kind: ConfigMap @@ -118,7 +160,9 @@ data: CAMERA_WIDTH: "160" CAMERA_HEIGHT: "120" - MQTT_CAMERA_PUB_FREQUENCY: "30" + CAMERA_FPS: "40" + + MQTT_CAMERA_PUB_FREQUENCY: "40" --- apiVersion: v1 @@ -127,7 +171,36 @@ metadata: name: robocar-models data: # model to use for steering - MODEL_STEERING: model_categorical_160x120h0_edgetpu.tflite + #MODEL_STEERING: model_categorical_160x120h0_edgetpu.tflite + MODEL_STEERING: "model_linear_160x120h0_edgetpu.tflite" + #OCI_IMAGE_MODEL: "git.cyrilix.bzh/robocars/model-steering:v20230429.0945-edgetpu" + #OCI_IMAGE_MODEL: "docker.io/cyrilix/model-steering:v20230429.0945-edgetpu" + #OCI_IMAGE_MODEL: "docker.io/cyrilix/model-steering:v0.1.0-edgetpu" + OCI_IMAGE_MODEL_REGISTRY: "registry.registry:5000" + OCI_IMAGE_MODEL_REPOSITORY: "robocars/model-steering" + + + # OCI_IMAGE_MODEL_TAG: "v20230602.2041-edgetpu" # vibreurs seuls ou v20230601.2338-edgetpu + #OCI_IMAGE_MODEL_TAG: "v20230602.2058-edgetpu" # vibreurs + toutes les sessions bump + #OCI_IMAGE_MODEL_TAG: "v20230603.1130-edgetpu" # clean1 + #OCI_IMAGE_MODEL_TAG: "v20230603.1144-edgetpu" # clean1 + + + #OCI_IMAGE_MODEL_TAG: "v20230617.0938-edgetpu" + #OCI_IMAGE_MODEL_TAG: "v20230617.0946-edgetpu" # bad + #OCI_IMAGE_MODEL_TAG: "v20230617.1010-edgetpu" # rd + vt not exist + + #OCI_IMAGE_MODEL_TAG: "v20230429.0945-edgetpu" # All + bump + #OCI_IMAGE_MODEL_TAG: "v20230617.1058-edgetpu" # clean3 + + #OCI_IMAGE_MODEL_TAG: "v20230617.1312-edgetpu" # clean10 + + OCI_IMAGE_MODEL_TAG: "v20230603.1157-edgetpu" # clean1 # Model RD good + #OCI_IMAGE_MODEL_TAG: "v20231215.1955-tflite" # Model RD good + plots + #OCI_IMAGE_MODEL_TAG: "v20231215.2002-tflite" # Model RD good + plots + brightness 0.5 + contrast 0.5 + + #OCI_IMAGE_MODEL_TAG: "v20231013.2034-edgetpu" # clean3, light + contrast + #OCI_IMAGE_MODEL_TAG: "v20230617.1327-edgetpu" # clean10 #MODEL_STEERING: model_linear_160x120h40_edgetpu.tflite @@ -162,9 +235,9 @@ data: "data": [ [ 0, 0, 0, 0, 0, 0], [ 0, 0, 0, 0, 0, 0], - [ 0, 0, 0.25, -0.25, 0, 0], - [ 0, 0.25, 0.5, -0.5, -0.25, 0], - [ 0.25, 0.5, 1, -1, -0.5, -0.25] + [ 0, 0, 0.75, -0.75, 0, 0], + [ 0, 0.75, 1, -1, -0.75, 0], + [ 0.75, 1, 1, -1, -1, -0.75] ] } @@ -202,8 +275,57 @@ kind: ConfigMap metadata: name: throttle data: + brake2.json: | + { + "delta_steps": [ 0.05, 0.1, 0.2, 0.3, 0.5 ], + "data": [ -0.1, -0.2, -0.3, -0.6, -1.0 ] + } + brake.json3: | + { + "delta_steps": [ 0.005, 0.1, 0.2, 0.3, 0.5 ], + "data": [ -0.26, -0.4, -0.7, -0.8, -1.0 ] + } brake.json: | { - "delta_steps": [ 0.05, 0.3, 0.5 ], - "data": [ -0.1, -0.5, -1.0 ] + "delta_steps": [ 0.005, 0.05, 0.1, 0.2, 0.5 ], + "data": [ -0.26, -0.4, -0.7, -0.8, -1.0 ] + } + + speed_custom_steering.json: | + { + "steering_values": [0.0, 0.20, 0.50, 0.70], + "throttle_steps": [0.17, 0.16, 0.15, 0.13] + } + + good_custom_steering.json: | + { + "steering_values": [0.0, 0.20, 0.50, 0.70], + "throttle_steps": [0.14, 0.13, 0.12, 0.11] + } + + lcustom_steering.json: | + { + "steering_values": [0.0, 0.20, 0.50, 0.70], + "throttle_steps": [0.16, 0.15, 0.14, 0.12] + } + + custom_steering.json: | + { + "steering_values": [0.0, 0.20, 0.50, 0.70], + "throttle_steps": [0.21, 0.17, 0.15, 0.12] + } + + bcustom_steering.json: | + { + "steering_values": [0.0, 0.20, 0.50, 0.70], + "throttle_steps": [0.18, 0.15, 0.14, 0.13] + } + + + + + slow_custom_steering.json: | + { + "steering_values": [0.0, 0.20, 0.50, 0.70], + "throttle_steps": [0.12, 0.115, 0.112, 0.11] } diff --git a/ansible/roles/microservices/files/robocar/common/deployments.yaml b/ansible/roles/microservices/files/robocar/common/deployments.yaml index b8a59d6..7092a68 100644 --- a/ansible/roles/microservices/files/robocar/common/deployments.yaml +++ b/ansible/roles/microservices/files/robocar/common/deployments.yaml @@ -1,302 +1,6 @@ --- apiVersion: apps/v1 kind: Deployment -metadata: - name: arduino - annotations: - reloader.stakater.com/auto: "true" -spec: - revisionHistoryLimit: 0 - replicas: 1 - strategy: - type: Recreate - selector: - matchLabels: - component: arduino - template: - metadata: - labels: - component: arduino - spec: - containers: - - name: arduino - image: docker.io/cyrilix/robocar-arduino - args: - - "-device=/dev/ttyAMA1" - - "-baud=115200" - - "-mqtt-retain=false" - - "--steering-left-pwm=$(STEERING_LEFT_PWM)" - - "--steering-right-pwm=$(STEERING_RIGHT_PWM)" - - "--steering-center-pwm=$(STEERING_CENTER_PWM)" - - "--steering-secondary-left-pwm=$(STEERING_SECONDARY_LEFT_PWM)" - - "--steering-secondary-right-pwm=$(STEERING_SECONDARY_RIGHT_PWM)" - - "--steering-secondary-center-pwm=$(STEERING_SECONDARY_CENTER_PWM)" - - "--throttle-min-pwm=$(THROTTLE_MIN_PWM)" - - "--throttle-max-pwm=$(THROTTLE_MAX_PWM)" - - "--throttle-center-pwm=$(THROTTLE_ZERO_PWM)" - - "--throttle-secondary-min-pwm=$(THROTTLE_SECONDARY_MIN_PWM)" - - "--throttle-secondary-max-pwm=$(THROTTLE_SECONDARY_MAX_PWM)" - - "--throttle-secondary-center-pwm=$(THROTTLE_SECONDARY_ZERO_PWM)" - - '--throttle-feedback-config=/etc/robocar/thresholds.json' - - "-log=info" - volumeMounts: - - mountPath: "/dev/ttyAMA0" - name: serial - - mountPath: "/etc/robocar" - name: robocar - securityContext: - privileged: true - runAsUser: 1234 - runAsGroup: 20 # Set 20/dialout group to access to serial device - envFrom: - - configMapRef: - name: robocar-throttle-pwm - - configMapRef: - name: robocar-steering-pwm - env: - - name: MQTT_BROKER - valueFrom: - configMapKeyRef: - key: MQTT_BROKER - 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-arduino - - name: MQTT_TOPIC_THROTTLE - valueFrom: - configMapKeyRef: - key: MQTT_TOPIC_RC_THROTTLE - name: robocar - - name: MQTT_TOPIC_STEERING - valueFrom: - configMapKeyRef: - key: MQTT_TOPIC_RC_STEERING - name: robocar - - name: MQTT_TOPIC_DRIVE_MODE - valueFrom: - configMapKeyRef: - key: MQTT_TOPIC_RC_DRIVE_MODE - name: robocar - - name: MQTT_TOPIC_SWITCH_RECORD - valueFrom: - configMapKeyRef: - key: MQTT_TOPIC_RC_SWITCH_RECORD - name: robocar - - name: MQTT_TOPIC_THROTTLE_FEEDBACK - valueFrom: - configMapKeyRef: - name: robocar - key: MQTT_TOPIC_THROTTLE_FEEDBACK - - name: MQTT_QOS - value: "0" - - name: TZ - value: "Europe/Paris" - volumes: - - name: serial - hostPath: - path: /dev/ttyAMA0 - type: CharDevice - - name: robocar - configMap: - name: robocar-objects - ---- -apiVersion: apps/v1 -kind: Deployment -metadata: - name: led - annotations: - reloader.stakater.com/auto: "true" -spec: - revisionHistoryLimit: 0 - replicas: 1 - strategy: - type: Recreate - selector: - matchLabels: - component: led - template: - metadata: - labels: - component: led - spec: - containers: - - name: led - image: docker.io/cyrilix/robocar-led - args: - - "-mqtt-retain=false" - - "-log=info" - volumeMounts: - - name: gpiomem - mountPath: "/dev/gpiomem" - - name: gpiochip0 - mountPath: "/dev/gpiochip0" - - name: gpiochip1 - mountPath: "/dev/gpiochip1" - securityContext: - privileged: true - runAsUser: 1234 - runAsGroup: 997 # Set 997/gpio group to access to serial device - env: - - name: MQTT_BROKER - valueFrom: - configMapKeyRef: - key: MQTT_BROKER - 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-led - - name: MQTT_TOPIC_DRIVE_MODE - valueFrom: - configMapKeyRef: - key: MQTT_TOPIC_RC_DRIVE_MODE - name: robocar - - name: MQTT_TOPIC_RECORD - valueFrom: - configMapKeyRef: - key: MQTT_TOPIC_RC_SWITCH_RECORD - name: robocar - - name: MQTT_QOS - value: "0" - - name: TZ - value: "Europe/Paris" - volumes: - - name: gpiomem - hostPath: - path: /dev/gpiomem - type: CharDevice - - name: gpiochip0 - hostPath: - path: /dev/gpiochip0 - type: CharDevice - - name: gpiochip1 - hostPath: - path: /dev/gpiochip1 - type: CharDevice ---- -apiVersion: apps/v1 -kind: Deployment -metadata: - name: tflite-steering - annotations: - reloader.stakater.com/auto: "true" -spec: - revisionHistoryLimit: 0 - replicas: 1 - strategy: - type: Recreate - selector: - matchLabels: - component: tflite-steering - template: - metadata: - labels: - component: tflite-steering - spec: - containers: - - name: tflite-steering - image: docker.io/cyrilix/robocar-steering-tflite-edgetpu - args: - - "--model=/model/$(MODEL_STEERING)" - - "--edge-verbosity=0" - - "--log=info" - securityContext: - runAsUser: 0 - runAsGroup: 0 - privileged: true - volumeMounts: - - name: models - mountPath: /model - - name: bus-usb - mountPath: /dev/bus/usb - - name: sys - mountPath: /sys - env: - - name: MQTT_BROKER - valueFrom: - configMapKeyRef: - key: MQTT_BROKER - 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-tflite-steering - - name: MQTT_TOPIC_CAMERA - valueFrom: - configMapKeyRef: - key: MQTT_TOPIC_CAMERA_OAK_COLOR - name: robocar - - name: MQTT_TOPIC_STEERING - valueFrom: - configMapKeyRef: - key: MQTT_TOPIC_TF_STEERING - name: robocar - - name: MODEL_STEERING - valueFrom: - configMapKeyRef: - key: MODEL_STEERING - name: robocar-models - - name: MODEL_IMAGE_WIDTH - valueFrom: - configMapKeyRef: - key: MODEL_IMAGE_WIDTH - name: robocar-models - - name: MODEL_IMAGE_HEIGHT - valueFrom: - configMapKeyRef: - key: MODEL_IMAGE_HEIGHT - name: robocar-models - - name: HORIZON - valueFrom: - configMapKeyRef: - key: HORIZON - name: robocar-models - - name: MQTT_QOS - value: "0" - - name: LD_LIBRARY_PATH - value: "/usr/local/lib/:/usr/lib" - - name: TZ - value: "Europe/Paris" - volumes: - - name: models - hostPath: - path: /home/pi/models/steering - type: DirectoryOrCreate - - name: bus-usb - hostPath: - path: /dev/bus/usb - - name: sys - hostPath: - path: /sys ---- -apiVersion: apps/v1 -kind: Deployment metadata: name: steering annotations: @@ -421,6 +125,8 @@ spec: - "--mqtt-retain=false" - "--enable-brake-feature=true" - "--brake-configuration=/etc/robocar/brake.json" + - "--enable-custom-steering-processor=true" + - "--custom-steering-processor-config=/etc/robocar/custom_steering.json" - "--log=info" securityContext: runAsUser: 1234 @@ -468,6 +174,16 @@ spec: configMapKeyRef: key: MQTT_TOPIC_STEERING name: robocar + - name: MQTT_TOPIC_SPEED_ZONE + valueFrom: + configMapKeyRef: + key: MQTT_TOPIC_SPEED_ZONE + name: robocar + - name: MQTT_TOPIC_MAX_THROTTLE_CTRL + valueFrom: + configMapKeyRef: + name: robocar + key: MQTT_TOPIC_MAX_THROTTLE_CTRL - name: THROTTLE_MIN valueFrom: configMapKeyRef: @@ -617,6 +333,16 @@ spec: configMapKeyRef: key: MQTT_TOPIC_RC_SWITCH_RECORD name: robocar + - name: MQTT_TOPIC_AUTOPILOT_STEERING + valueFrom: + configMapKeyRef: + key: MQTT_TOPIC_TF_STEERING + name: robocar + - name: MQTT_TOPIC_DRIVE_MODE + valueFrom: + configMapKeyRef: + key: MQTT_TOPIC_RC_DRIVE_MODE + name: robocar - name: MQTT_TOPIC_RECORDS valueFrom: configMapKeyRef: diff --git a/ansible/roles/microservices/files/robocar/common/kustomization.yaml b/ansible/roles/microservices/files/robocar/common/kustomization.yaml index f573190..864669f 100644 --- a/ansible/roles/microservices/files/robocar/common/kustomization.yaml +++ b/ansible/roles/microservices/files/robocar/common/kustomization.yaml @@ -9,26 +9,18 @@ resources: - configmap.yaml images: - - name: docker.io/cyrilix/robocar-arduino - newTag: v0.9.0 - - - name: docker.io/cyrilix/robocar-led - newTag: v0.5.1 - - - name: docker.io/cyrilix/robocar-steering-tflite-edgetpu - newTag: v0.5.3 - name: docker.io/cyrilix/robocar-throttle - newTag: v0.6.0 + newTag: v0.8.0 - name: docker.io/cyrilix/robocar-record - newTag: v0.5.1 + newTag: v0.6.0 - name: docker.io/cyrilix/robocar-recorder-store - newTag: v0.2.1 + newTag: v0.3.0 - name: docker.io/cyrilix/robocar-steering - newTag: v0.6.0 + newTag: v0.6.0-4-gf97c9cf - name: docker.io/cyrilix/robocar-road newTag: v0.2.0 diff --git a/ansible/roles/microservices/files/robocar/kustomization.yaml b/ansible/roles/microservices/files/robocar/kustomization.yaml new file mode 100644 index 0000000..3d0ab23 --- /dev/null +++ b/ansible/roles/microservices/files/robocar/kustomization.yaml @@ -0,0 +1,10 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization + +resources: + - registry + - registry/secrets.yaml + - reloader + - nats + - car + - common/secrets.yaml \ No newline at end of file diff --git a/ansible/roles/microservices/files/robocar/local/configmap.yaml b/ansible/roles/microservices/files/robocar/local/configmap.yaml new file mode 100644 index 0000000..89e4cf1 --- /dev/null +++ b/ansible/roles/microservices/files/robocar/local/configmap.yaml @@ -0,0 +1,8 @@ +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: robocar-camera-replay +data: + + REPLAY_FRAME_DIR: "/records/clean3/records/2023-05-13T10-14_33/cam" diff --git a/ansible/roles/microservices/files/robocar/local/deployments.yaml b/ansible/roles/microservices/files/robocar/local/deployments.yaml new file mode 100644 index 0000000..b8bd826 --- /dev/null +++ b/ansible/roles/microservices/files/robocar/local/deployments.yaml @@ -0,0 +1,173 @@ +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: camera-replay + annotations: + reloader.stakater.com/auto: "true" +spec: + revisionHistoryLimit: 0 + replicas: 1 + strategy: + type: Recreate + selector: + matchLabels: + component: camera-replay + template: + metadata: + labels: + component: camera-replay + spec: + containers: + - name: camera-replay + image: docker.io/cyrilix/robocar-camera-replay + args: + - "-mqtt-pub-frequency=$(MQTT_CAMERA_PUB_FREQUENCY)" + - "-frame-dir=$(REPLAY_FRAME_DIR)" + - "-log=info" + securityContext: + runAsUser: 1000 + runAsGroup: 1000 + privileged: false + volumeMounts: + - name: camera-records + mountPath: /records + env: + - name: MQTT_BROKER + valueFrom: + configMapKeyRef: + key: MQTT_BROKER + 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-camera-replay + - name: MQTT_TOPIC + valueFrom: + configMapKeyRef: + key: MQTT_TOPIC_CAMERA + name: robocar + - name: REPLAY_FRAME_DIR + valueFrom: + configMapKeyRef: + key: REPLAY_FRAME_DIR + name: robocar-camera-replay + - name: MQTT_CAMERA_PUB_FREQUENCY + valueFrom: + configMapKeyRef: + key: MQTT_CAMERA_PUB_FREQUENCY + name: robocar-camera + - name: MQTT_QOS + value: "0" + - name: TZ + value: "Europe/Paris" + volumes: + - name: camera-records + hostPath: + path: "/home/cyrille/robocar-clean/" +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: tflite-steering + annotations: + reloader.stakater.com/auto: "true" +spec: + revisionHistoryLimit: 0 + replicas: 1 + strategy: + type: Recreate + selector: + matchLabels: + component: tflite-steering + template: + metadata: + labels: + component: tflite-steering + spec: + containers: + - name: tflite-steering + image: docker.io/cyrilix/robocar-steering-tflite-edgetpu + args: + #- "--model=/model/$(MODEL_STEERING)" + - "--oci-model-registry=$(OCI_IMAGE_MODEL_REGISTRY)" + - "--oci-model-repository=$(OCI_IMAGE_MODEL_REPOSITORY)" + - "--oci-model-tag=$(OCI_IMAGE_MODEL_TAG)" + - "--edge-verbosity=0" + - "--log=info" + securityContext: + runAsUser: 0 + runAsGroup: 0 + privileged: true + volumeMounts: + - name: models + mountPath: /model + - name: bus-usb + mountPath: /dev/bus/usb + - name: sys + mountPath: /sys + env: + - name: MQTT_BROKER + valueFrom: + configMapKeyRef: + key: MQTT_BROKER + 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-tflite-steering + - name: MQTT_TOPIC_CAMERA + valueFrom: + configMapKeyRef: + key: MQTT_TOPIC_CAMERA_OAK_COLOR + name: robocar + - name: MQTT_TOPIC_STEERING + valueFrom: + configMapKeyRef: + key: MQTT_TOPIC_TF_STEERING + name: robocar + - name: OCI_IMAGE_MODEL_REGISTRY + valueFrom: + configMapKeyRef: + key: OCI_IMAGE_MODEL_REGISTRY + name: robocar-models + - name: OCI_IMAGE_MODEL_REPOSITORY + valueFrom: + configMapKeyRef: + key: OCI_IMAGE_MODEL_REPOSITORY + name: robocar-models + - name: OCI_IMAGE_MODEL_TAG + value: "v20230603.1157-tflite" + - name: MQTT_QOS + value: "0" + - name: LD_LIBRARY_PATH + value: "/usr/local/lib/:/usr/lib" + - name: TZ + value: "Europe/Paris" + volumes: + - name: models + hostPath: + path: /home/pi/models/steering + type: DirectoryOrCreate + - name: bus-usb + hostPath: + path: /dev/bus/usb + - name: sys + hostPath: + path: /sys diff --git a/ansible/roles/microservices/files/robocar/local/kustomization.yaml b/ansible/roles/microservices/files/robocar/local/kustomization.yaml new file mode 100644 index 0000000..578aac2 --- /dev/null +++ b/ansible/roles/microservices/files/robocar/local/kustomization.yaml @@ -0,0 +1,18 @@ +--- +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization + +namespace: robocar + +resources: + - ../common + - deployments.yaml + - configmap.yaml + +images: + - name: docker.io/cyrilix/robocar-camera-replay + newTag: v0.0.1-2-ga422aed + + - name: docker.io/cyrilix/robocar-steering-tflite-edgetpu + #newTag: v0.6.1 + newTag: v0.6.1-1-g5d5858a diff --git a/ansible/roles/microservices/files/robocar/registry/configmaps.yaml b/ansible/roles/microservices/files/robocar/registry/configmaps.yaml new file mode 100644 index 0000000..f26fb09 --- /dev/null +++ b/ansible/roles/microservices/files/robocar/registry/configmaps.yaml @@ -0,0 +1,42 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: zot-config +data: + config.json: | + { + "storage": { + "rootDirectory": "/var/lib/registry" + }, + "http": { + "address": "0.0.0.0", + "port": "5000" + }, + "log": { + "level": "debug" + }, + "extensions": { + "sync": { + "credentialsFile": "/etc/zot/credentials.json", + "registries": [ + { + "urls": [ + "https://ghcr.io" + ], + "onDemand": true, + "pollInterval": "6h", + "tlsVerify": false, + "maxRetries": 3, + "retryDelay": "5m", + "onlySigned": false, + "content": [ + { + "prefix": "/cyrilix/model-steering", + "destination": "/robocars/model-steering" + } + ] + } + ] + } + } + } diff --git a/ansible/roles/microservices/files/robocar/registry/deployements.yaml b/ansible/roles/microservices/files/robocar/registry/deployements.yaml new file mode 100644 index 0000000..af27d00 --- /dev/null +++ b/ansible/roles/microservices/files/robocar/registry/deployements.yaml @@ -0,0 +1,61 @@ +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: registry + annotations: + reloader.stakater.com/auto: "true" +spec: + revisionHistoryLimit: 0 + replicas: 1 + strategy: + type: Recreate + selector: + matchLabels: + app: registry + template: + metadata: + labels: + app: registry + spec: + containers: + - name: registry + image: ghcr.io/project-zot/zot-linux-arm64 + env: + - name: TZ + value: 'Europe/Paris' + - name: REGISTRY_HTTP_ADDR + value: 0.0.0.0:5000 + ports: + - containerPort: 5000 + name: http-registry + volumeMounts: + - mountPath: /var/lib/registry + name: registry + - name: config + mountPath: /etc/zot/config.json + subPath: config.json + - name: credentials + mountPath: /etc/zot/credentials.json + subPath: credentials.json + securityContext: + runAsUser: 1000 + runAsGroup: 1000 + fsGroup: 1000 + fsGroupChangePolicy: OnRootMismatch + volumes: + - name: registry + hostPath: + path: /home/pi/registry + - name: config + configMap: + name: zot-config + items: + - key: config.json + path: config.json + - name: credentials + secret: + secretName: registries-credentials + items: + - key: credentials.json + path: credentials.json diff --git a/ansible/roles/microservices/files/robocar/registry/kustomization.yaml b/ansible/roles/microservices/files/robocar/registry/kustomization.yaml new file mode 100644 index 0000000..18e20e0 --- /dev/null +++ b/ansible/roles/microservices/files/robocar/registry/kustomization.yaml @@ -0,0 +1,15 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization + +namespace: registry + +images: + - name: ghcr.io/project-zot/zot-linux-arm64 + newTag: v1.4.3 + +resources: + - namespace.yaml + - configmaps.yaml + - serviceaccount.yaml + - services.yaml + - deployements.yaml diff --git a/ansible/roles/microservices/files/robocar/registry/namespace.yaml b/ansible/roles/microservices/files/robocar/registry/namespace.yaml new file mode 100644 index 0000000..7d1d836 --- /dev/null +++ b/ansible/roles/microservices/files/robocar/registry/namespace.yaml @@ -0,0 +1,4 @@ +apiVersion: v1 +kind: Namespace +metadata: + name: registry \ No newline at end of file diff --git a/ansible/roles/microservices/files/robocar/registry/secrets.yaml b/ansible/roles/microservices/files/robocar/registry/secrets.yaml new file mode 100644 index 0000000..e3f656d --- /dev/null +++ b/ansible/roles/microservices/files/robocar/registry/secrets.yaml @@ -0,0 +1,13 @@ +apiVersion: v1 +kind: Secret +metadata: + name: registries-credentials + namespace: registry + +stringData: + credentials.json: | + { + "ghcr.io": { + "username": "cyrilix", + "password": "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" + } diff --git a/ansible/roles/microservices/files/robocar/registry/serviceaccount.yaml b/ansible/roles/microservices/files/robocar/registry/serviceaccount.yaml new file mode 100644 index 0000000..4128219 --- /dev/null +++ b/ansible/roles/microservices/files/robocar/registry/serviceaccount.yaml @@ -0,0 +1,5 @@ +apiVersion: v1 +kind: ServiceAccount +metadata: + name: registry +automountServiceAccountToken: false \ No newline at end of file diff --git a/ansible/roles/microservices/files/robocar/registry/services.yaml b/ansible/roles/microservices/files/robocar/registry/services.yaml new file mode 100644 index 0000000..1076836 --- /dev/null +++ b/ansible/roles/microservices/files/robocar/registry/services.yaml @@ -0,0 +1,27 @@ +apiVersion: v1 +kind: Service +metadata: + name: registry-ext +spec: + type: NodePort + ports: + - port: 5000 + name: http-registry + targetPort: http-registry + nodePort: 32000 + selector: + app: registry + +--- +apiVersion: v1 +kind: Service +metadata: + name: registry +spec: + type: ClusterIP + ports: + - port: 5000 + name: http-registry + targetPort: http-registry + selector: + app: registry diff --git a/ansible/roles/microservices/files/robocar/simulator/kustomization.yaml b/ansible/roles/microservices/files/robocar/simulator/kustomization.yaml index 41a0923..aa259da 100644 --- a/ansible/roles/microservices/files/robocar/simulator/kustomization.yaml +++ b/ansible/roles/microservices/files/robocar/simulator/kustomization.yaml @@ -5,7 +5,7 @@ kind: Kustomization namespace: robocar resources: - - ../common + - ../common-car - deployments.yaml - configmap.yaml