diff --git a/ansible/roles/microservices/files/robocar/car/configmap.yaml b/ansible/roles/microservices/files/robocar/car/configmap.yaml new file mode 100644 index 0000000..e853b1c --- /dev/null +++ b/ansible/roles/microservices/files/robocar/car/configmap.yaml @@ -0,0 +1,20 @@ +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: robocar-pca9685-pwm +data: + ############################ + # STEERING PWM - PCA9685 # + ############################ + STEERING_PCA9685_LEFT_PWM: "995" + STEERING_PCA9685_RIGHT_PWM: "2017" + STEERING_PCA9685_CENTER_PWM: "1440" + + ########################### + # THROTTLE PWM - PCA9685 # + ############################ + THROTTLE_PCA9685_MIN_PWM: "994" + THROTTLE_PCA9685_MAX_PWM: "1975" + THROTTLE_PCA9685_ZERO_PWM: "1420" + diff --git a/ansible/roles/microservices/files/robocar/car/deployments.yaml b/ansible/roles/microservices/files/robocar/car/deployments.yaml index 82cb722..fb1c474 100644 --- a/ansible/roles/microservices/files/robocar/car/deployments.yaml +++ b/ansible/roles/microservices/files/robocar/car/deployments.yaml @@ -107,6 +107,7 @@ spec: args: - "--image-width=$(CAMERA_WIDTH)" - "--image-height=$(CAMERA_HEIGHT)" + - "--objects-threshold=$(THRESHOLD_OBJECTS)" securityContext: runAsUser: 1234 privileged: true @@ -135,6 +136,16 @@ spec: configMapKeyRef: key: MQTT_TOPIC_CAMERA_OAK_COLOR name: robocar + - name: MQTT_TOPIC_OBJECTS + valueFrom: + configMapKeyRef: + key: MQTT_TOPIC_OBJECTS + name: robocar + - name: THRESHOLD_OBJECTS + valueFrom: + configMapKeyRef: + key: THRESHOLD + name: robocar-objects - name: CAMERA_WIDTH valueFrom: configMapKeyRef: @@ -186,13 +197,13 @@ spec: - "--mqtt-retain=false" - "--throttle-channel=15" - "--steering-channel=14" - - "--throttle-zero-pwm=$(THROTTLE_ZERO_PWM)" - - "--throttle-min-pwm=$(THROTTLE_MIN_PWM)" - - "--throttle-max-pwm=$(THROTTLE_MAX_PWM)" - - "--steering-left-pwm=$(STEERING_LEFT_PWM)" - - "--steering-right-pwm=$(STEERING_RIGHT_PWM)" - - "--steering-center-pwm=$(STEERING_CENTER_PWM)" - - "--pwm-freq=60" + - "--throttle-zero-pwm=$(THROTTLE_PCA9685_ZERO_PWM)" + - "--throttle-min-pwm=$(THROTTLE_PCA9685_MIN_PWM)" + - "--throttle-max-pwm=$(THROTTLE_PCA9685_MAX_PWM)" + - "--steering-left-pwm=$(STEERING_PCA9685_LEFT_PWM)" + - "--steering-right-pwm=$(STEERING_PCA9685_RIGHT_PWM)" + - "--steering-center-pwm=$(STEERING_PCA9685_CENTER_PWM)" + - "--pwm-freq=50" - "--update-pwm-frequency=25" - "--log=info" securityContext: @@ -202,6 +213,9 @@ spec: volumeMounts: - mountPath: /dev/i2c-1 name: i2c + envFrom: + - configMapRef: + name: robocar-pca9685-pwm env: - name: MQTT_BROKER valueFrom: @@ -232,36 +246,6 @@ spec: name: robocar - name: MQTT_QOS value: "0" - - name: STEERING_LEFT_PWM - valueFrom: - configMapKeyRef: - name: robocar-steering-pwm - key: STEERING_LEFT_PWM - - name: STEERING_RIGHT_PWM - valueFrom: - configMapKeyRef: - name: robocar-steering-pwm - key: STEERING_RIGHT_PWM - - name: STEERING_CENTER_PWM - valueFrom: - configMapKeyRef: - name: robocar-steering-pwm - key: STEERING_CENTER_PWM - - name: THROTTLE_MIN_PWM - valueFrom: - configMapKeyRef: - name: robocar-throttle-pwm - key: THROTTLE_MIN_PWM - - name: THROTTLE_MAX_PWM - valueFrom: - configMapKeyRef: - name: robocar-throttle-pwm - key: THROTTLE_MAX_PWM - - name: THROTTLE_ZERO_PWM - valueFrom: - configMapKeyRef: - name: robocar-throttle-pwm - key: THROTTLE_ZERO_PWM - name: TZ value: "Europe/Paris" volumes: diff --git a/ansible/roles/microservices/files/robocar/car/kustomization.yaml b/ansible/roles/microservices/files/robocar/car/kustomization.yaml index bd5262a..422f40b 100644 --- a/ansible/roles/microservices/files/robocar/car/kustomization.yaml +++ b/ansible/roles/microservices/files/robocar/car/kustomization.yaml @@ -7,6 +7,7 @@ namespace: robocar resources: - ../common - deployments.yaml + - configmap.yaml images: - name: docker.io/cyrilix/robocar-camera @@ -16,4 +17,4 @@ images: newTag: v0.6.4 - name: docker.io/cyrilix/robocar-oak-camera - newTag: v0.1.0 \ No newline at end of file + newTag: v0.1.0-2-g52c3808 \ 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 7b967f5..452d417 100644 --- a/ansible/roles/microservices/files/robocar/common/configmap.yaml +++ b/ansible/roles/microservices/files/robocar/common/configmap.yaml @@ -11,6 +11,8 @@ data: MQTT_TOPIC_CAMERA: car/satanas/part/camera/color MQTT_TOPIC_CAMERA_OAK_COLOR: car/satanas/part/camera/color + # Objects detection + MQTT_TOPIC_OBJECTS: car/satanas/part/objects # Radio command MQTT_TOPIC_RC_THROTTLE: car/satanas/part/rc/throttle @@ -31,6 +33,9 @@ data: # Records topic MQTT_TOPIC_RECORDS: car/satanas/part/records + # Feedbacks + MQTT_TOPIC_THROTTLE_FEEDBACK: car/satanas/part/feedback/throttle + --- apiVersion: v1 kind: ConfigMap @@ -40,13 +45,8 @@ data: ############ # Throttle # ############ - # Min value to start is 0.12 - # Good value for manual: 0.15 - #THROTTLE_MIN: "0.15" - #THROTTLE_MAX: "0.15" - - THROTTLE_MIN: "0.19" - THROTTLE_MAX: "0.19" + THROTTLE_MIN: "0.2" + THROTTLE_MAX: "0.3" --- @@ -58,9 +58,17 @@ data: ################ # STEERING PWM # ################ - STEERING_LEFT_PWM: "1002" + STEERING_LEFT_PWM: "1000" STEERING_RIGHT_PWM: "1985" - STEERING_CENTER_PWM: "1491" + STEERING_CENTER_PWM: "1492" + + ############################ + # STEERING PWM - SECOND RC # + ############################ + STEERING_SECONDARY_LEFT_PWM: "1119" + STEERING_SECONDARY_RIGHT_PWM: "2141" + STEERING_SECONDARY_CENTER_PWM: "1641" + --- apiVersion: v1 kind: ConfigMap @@ -70,12 +78,17 @@ data: ################ # THROTTLE PWM # ################ - #THROTTLE_MIN_PWM: "1092" - #THROTTLE_MAX_PWM: "1986" - #THROTTLE_ZERO_PWM: "1583" - THROTTLE_MIN_PWM: "960" - THROTTLE_MAX_PWM: "1949" - THROTTLE_ZERO_PWM: "1452" + THROTTLE_MIN_PWM: "994" + THROTTLE_MAX_PWM: "1979" + THROTTLE_ZERO_PWM: "1484" + + ########################### + # THROTTLE PWM - SECOND RC # + ############################ + THROTTLE_SECONDARY_MIN_PWM: "994" + THROTTLE_SECONDARY_MAX_PWM: "1975" + THROTTLE_SECONDARY_ZERO_PWM: "1506" + --- apiVersion: v1 kind: ConfigMap @@ -123,3 +136,48 @@ metadata: name: robocar-road data: HORIZON: "20" + +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: steering +data: + grid.json: | + { + "steering_steps": [ -1, -0.66, -0.33, 0, 0.33, 0.66, 1], + "distance_steps": [ 0, 0.3, 0.4, 0.5, 0.8, 1], + "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] + ] + } + + "omf.json": | + { + "steering_steps":[-1, -0.66, -0.33, 0, 0.33, 0.66, 1], + "distance_steps": [0, 0.2, 0.4, 0.6, 0.8, 1], + "data": [ + [0, 0, 0, 0, 0, 0], + [0, 0, 0, 0, 0, 0], + [0, 0, 0, 0, 0, 0], + [0, 0.25, 0, 0, -0.25, 0], + [0.5, 0.25, 0, 0, -0.5, -0.25] + ] + } + +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: android +data: + thresholds.json: | + { + "threshold_steps": [ 0.07, 0.08, 0.09, 0.1, 0.125, 0.15, 0.2, 0.25, 0.3, 0.35, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0 ], + "min_valid": 500, + "data": [ 8700, 4800, 3500, 2550, 1850, 1387, 992, 840, 750, 700, 655, 620, 590, 570, 553, 549, 548 ] + } diff --git a/ansible/roles/microservices/files/robocar/common/deployments.yaml b/ansible/roles/microservices/files/robocar/common/deployments.yaml index e995421..ebf6fad 100644 --- a/ansible/roles/microservices/files/robocar/common/deployments.yaml +++ b/ansible/roles/microservices/files/robocar/common/deployments.yaml @@ -28,17 +28,31 @@ spec: - "--steering-left-pwm=$(STEERING_LEFT_PWM)" - "--steering-right-pwm=$(STEERING_RIGHT_PWM)" - "--steering-center-pwm=$(STEERING_CENTER_PWM)" - - "--throttle-zero-pwm=$(THROTTLE_ZERO_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: @@ -77,39 +91,13 @@ spec: 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: STEERING_LEFT_PWM - valueFrom: - configMapKeyRef: - name: robocar-steering-pwm - key: STEERING_LEFT_PWM - - name: STEERING_RIGHT_PWM - valueFrom: - configMapKeyRef: - name: robocar-steering-pwm - key: STEERING_RIGHT_PWM - - name: STEERING_CENTER_PWM - valueFrom: - configMapKeyRef: - name: robocar-steering-pwm - key: STEERING_CENTER_PWM - - - name: THROTTLE_MIN_PWM - valueFrom: - configMapKeyRef: - name: robocar-throttle-pwm - key: THROTTLE_MIN_PWM - - name: THROTTLE_MAX_PWM - valueFrom: - configMapKeyRef: - name: robocar-throttle-pwm - key: THROTTLE_MAX_PWM - - name: THROTTLE_ZERO_PWM - valueFrom: - configMapKeyRef: - name: robocar-throttle-pwm - key: THROTTLE_ZERO_PWM - name: TZ value: "Europe/Paris" volumes: @@ -117,6 +105,9 @@ spec: hostPath: path: /dev/ttyAMA0 type: CharDevice + - name: robocar + configMap: + name: android --- apiVersion: apps/v1 @@ -328,6 +319,13 @@ spec: image: docker.io/cyrilix/robocar-steering args: - "-mqtt-retain=false" + - "--image-width=$(IMAGE_WIDTH)" + - "--image-height=$(IMAGE_HEIGHT)" + - "--enable-objects-correction=true" + - "--enable-objects-correction-user=false" + - "--grid-map-config=/etc/robocar/grid.json" + - "--objects-move-factors-config=/etc/robocar/omf.json" + - "--delta-middle=0.1" - "-log=info" securityContext: runAsUser: 1234 @@ -370,10 +368,32 @@ spec: configMapKeyRef: key: MQTT_TOPIC_RC_DRIVE_MODE name: robocar + - name: MQTT_TOPIC_OBJECTS + valueFrom: + configMapKeyRef: + key: MQTT_TOPIC_OBJECTS + name: robocar - name: MQTT_QOS value: "0" + - name: IMAGE_WIDTH + valueFrom: + configMapKeyRef: + key: CAMERA_WIDTH + name: robocar-camera + - name: IMAGE_HEIGHT + valueFrom: + configMapKeyRef: + key: CAMERA_HEIGHT + name: robocar-camera - name: TZ value: "Europe/Paris" + volumeMounts: + - mountPath: /etc/robocar + name: robocar-configs + volumes: + - name: robocar-configs + configMap: + name: steering --- apiVersion: apps/v1 kind: Deployment diff --git a/ansible/roles/microservices/files/robocar/common/kustomization.yaml b/ansible/roles/microservices/files/robocar/common/kustomization.yaml index adc3203..255fff5 100644 --- a/ansible/roles/microservices/files/robocar/common/kustomization.yaml +++ b/ansible/roles/microservices/files/robocar/common/kustomization.yaml @@ -10,7 +10,7 @@ resources: images: - name: docker.io/cyrilix/robocar-arduino - newTag: v0.8.0 + newTag: v0.8.0-6-gadb38c3 - name: docker.io/cyrilix/robocar-led newTag: v0.5.1 @@ -29,7 +29,7 @@ images: newTag: v0.2.1 - name: docker.io/cyrilix/robocar-steering - newTag: v0.5.1 + newTag: v0.5.1-24-g424b697 - name: docker.io/cyrilix/robocar-road newTag: v0.2.0