From 4ce3f888bbfecaad9fe21a60d5f69e7162a75dc6 Mon Sep 17 00:00:00 2001 From: "Arend-Jan van Hilten (TU)" Date: Wed, 25 Oct 2023 13:25:10 +0200 Subject: [PATCH 1/5] Add pcb version 0.8 --- .../config/mirte_pcb08_config.yaml | 90 +++++++++++++++++++ .../config/mirte_user_config.yaml | 34 ++++--- mirte_telemetrix/scripts/mappings/pcb.py | 89 ++++++++++++------ 3 files changed, 169 insertions(+), 44 deletions(-) create mode 100644 mirte_telemetrix/config/mirte_pcb08_config.yaml diff --git a/mirte_telemetrix/config/mirte_pcb08_config.yaml b/mirte_telemetrix/config/mirte_pcb08_config.yaml new file mode 100644 index 0000000..3185236 --- /dev/null +++ b/mirte_telemetrix/config/mirte_pcb08_config.yaml @@ -0,0 +1,90 @@ +device: + mirte: + type: pcb + version: 0.8 + max_frequency: 50 +distance: + left: + name: left + device: mirte + connector: SRF1 + right: + name: right + device: mirte + connector: SRF2 +encoder: + left: + name: left + device: mirte + connector: ENC1 + right: + name: right + device: mirte + connector: ENC2 +intensity: + left: + name: left + device: mirte + connector: IR1 + right: + name: right + device: mirte + connector: IR2 +oled: + left: + name: left + device: mirte + connector: I2C2 + right: + name: right + device: mirte + connector: I2C1 +servo: + left: + name: left + device: mirte + connector: Servo1 + right: + name: right + device: mirte + connector: Servo2 + # These servo's have the same pins as the ObjectDetectors. So as + # soon as they are implemented, these should be commented out + gripper: + name: gripper + device: mirte + connector: Servo3 + arm: + name: arm + device: mirte + connector: Servo4 + +keypad: + yellow: + name: keypad + device: mirte + connector: Keypad +motor: + left: + name: left + device: mirte + connector: MC1-A + type: pp + right: + name: right + device: mirte + connector: MC1-B + type: pp +# These motors have the same pins as the line intensity sensors. So +# when uncommenting these, please comment the intensity sensors. +# left2: +# name: left2 +# device: mirte +# connector: MC2-A +# type: pp +# right2: +# name: right2 +# device: mirte +# connector: MC2-B +# type: pp +# TODO: add obstacle detection diff --git a/mirte_telemetrix/config/mirte_user_config.yaml b/mirte_telemetrix/config/mirte_user_config.yaml index 41a913c..1956577 100644 --- a/mirte_telemetrix/config/mirte_user_config.yaml +++ b/mirte_telemetrix/config/mirte_user_config.yaml @@ -29,7 +29,7 @@ distance: # pin: GP15 intensity: left: - name: left + name: left device: mirte pins: analog: GP27 @@ -53,28 +53,27 @@ oled: pins: sda: GP4 scl: GP5 -servo: +servo: left: name: left device: mirte pins: - pin: GP3 -# Servo on GP2 doens't work with the v0.6 pcb, next version this should be fixed -# right: -# name: right -# device: mirte -# pins: -# pin: GP2 -# These servo's have the same pins as the ObjectDetectors. So as -# soon as they are implemented, these should be commented out + pin: GP14 + right: + name: right + device: mirte + pins: + pin: GP15 + # These servo's have the same pins as the ObjectDetectors. So as + # soon as they are implemented, these should be commented out gripper: name: gripper device: mirte pins: pin: GP12 arm: - name: arm - device: mirte + name: arm + device: mirte pins: pin: GP13 keypad: @@ -87,17 +86,17 @@ motor: left: name: left device: mirte - type: dp + type: pp pins: - d1: GP19 p1: GP18 + p2: GP19 right: name: right device: mirte - type: dp + type: pp pins: - d1: GP21 p1: GP20 + p2: GP21 # These motors have the same pins as the line intensity sensors. So # when uncommenting these, please comment the intensity sensors. # left2: @@ -114,4 +113,3 @@ motor: # pins: # p1: GP27 # p2: GP17 -# TODO: add obstacle detection diff --git a/mirte_telemetrix/scripts/mappings/pcb.py b/mirte_telemetrix/scripts/mappings/pcb.py index 2958672..73f8417 100644 --- a/mirte_telemetrix/scripts/mappings/pcb.py +++ b/mirte_telemetrix/scripts/mappings/pcb.py @@ -3,7 +3,7 @@ import mappings.blackpill_f103c8 -mirte_pico_pcb_map06 = { +mirte_pico_pcb_map08 = { "IR1": {"digital": "16", "analog": "26"}, "IR2": {"digital": "17", "analog": "27"}, "SRF1": {"trigger": "7", "echo": "6"}, @@ -13,25 +13,21 @@ "ENC1": {"pin": "15"}, "ENC2": {"pin": "14"}, "Keypad": {"pin": "28"}, - "Servo1": { - "pin": "2" - }, # These 2 servos don't work together with the motor controllers at the same time - "Servo2": { - "pin": "3" - }, # These 2 servos don't work together with the motor controllers at the same time + "Servo1": {"pin": "14"}, + "Servo2": {"pin": "15"}, "Servo3": {"pin": "12"}, "Servo4": {"pin": "13"}, - "LED": {"pin": "25"}, - "MC1-A": {"1a": "19", "1b": "18"}, - "MC1-B": {"1a": "21", "1b": "20"}, - "MC2-A": {"1a": "16", "1b": "26"}, - "MC2-B": {"1a": "17", "1b": "27"}, + "LED": {"pin": "25"}, # Does not work with the Pico W + "MC1-A": generate_motor_mapping("19", "18"), + "MC1-B": generate_motor_mapping("21", "20"), + "MC2-A": generate_motor_mapping("16", "26"), + "MC2-B": generate_motor_mapping("17", "27"), } -version = 0.6 +version = 0.8 board_mapping = mappings.pico -connector_mapping = mirte_pico_pcb_map06 +connector_mapping = mirte_pico_pcb_map08 def get_mcu(): @@ -65,8 +61,12 @@ def get_I2C_port(sda): def set_version(new_version, mcu=""): global version, board_mapping, connector_mapping version = new_version + if version == 0.8: + board_mapping = mappings.pico + connector_mapping = mirte_pico_pcb_map08 if version == 0.6: board_mapping = mappings.pico + connector_mapping = mirte_pico_pcb_map06 if version == 0.4: if mcu == "" or mcu == "stm32": board_mapping = mappings.stm32 @@ -86,7 +86,44 @@ def get_max_pwm_value(): return board_mapping.get_max_pwm_value() +def generate_motor_mapping(pin_a, pin_b): + # pin a has preference for pwm + # This will make sure, dp, pp and dd is always possible when using a connector without knowing what type of control + # A B + # pp P1 P2 + # dp P1 D1 + # dd D2 D1 # Not available + # ddp TODO connectors + # Downside: when changing from pp/dp to dd, the direction will change + + return {"p1": pin_a, "p2": pin_b, "d1": pin_b, "d2": pin_a} + + # mappings for older pcbs +mirte_pico_pcb_map06 = { + "IR1": {"digital": "16", "analog": "26"}, + "IR2": {"digital": "17", "analog": "27"}, + "SRF1": {"trigger": "7", "echo": "6"}, + "SRF2": {"trigger": "9", "echo": "8"}, + "I2C1": {"scl": "5", "sda": "4"}, + "I2C2": {"scl": "11", "sda": "10"}, + "ENC1": {"pin": "15"}, + "ENC2": {"pin": "14"}, + "Keypad": {"pin": "28"}, + "Servo1": { + "pin": "2" + }, # These 2 servos don't work together with the motor controllers at the same time + "Servo2": { + "pin": "3" + }, # These 2 servos don't work together with the motor controllers at the same time + "Servo3": {"pin": "12"}, + "Servo4": {"pin": "13"}, + "LED": {"pin": "25"}, + "MC1-A": generate_motor_mapping("19", "18"), + "MC1-B": generate_motor_mapping("21", "20"), + "MC2-A": generate_motor_mapping("16", "26"), + "MC2-B": generate_motor_mapping("17", "27"), +} mirte_pcb04_stm_map = { "IR1": {"digital": "C15", "analog": "A0"}, @@ -103,10 +140,10 @@ def get_max_pwm_value(): "Servo1": {"pin": "B3"}, "Servo2": {"pin": "A3"}, "LED": {"pin": "C13"}, - "MA": {"d1": "A8", "p1": "B5"}, - "MB": {"d1": "B14", "p1": "B15"}, - "MC": {"d1": "A10", "p1": "A7"}, - "MD": {"d1": "B13", "p1": "A9"}, + "MC1-A": generate_motor_mapping("B5", "A8"), + "MC1-B": generate_motor_mapping("B15", "B14"), + "MC2-A": generate_motor_mapping("A7", "A10"), + "MC2-B": generate_motor_mapping("A9", "B13"), } mirte_pcb04_nano_map = { @@ -120,8 +157,8 @@ def get_max_pwm_value(): "Servo1": {"pin": "A3"}, "Servo2": {"pin": "D12"}, "LED": {"pin": "D13"}, - "MA": {"d1": "D6", "p1": "D7"}, - "MB": {"d1": "D4", "p1": "D5"}, + "MC1-A": generate_motor_mapping("D7", "D6"), + "MC1-B": generate_motor_mapping("D5", "D4"), } mirte_pcb03_stm_map = { @@ -139,10 +176,10 @@ def get_max_pwm_value(): "A2": {"pin": "A2"}, "A3": {"pin": "A3"}, "LED": {"pin": "C13"}, - "MC1A": {"d1": "A8", "p1": "B3"}, - "MC1B": {"d1": "B14", "p1": "B15"}, - "MC2A": {"d1": "A10", "p1": "B1"}, - "MC2B": {"1d": "B13", "p1": "A9"}, + "MC1A": generate_motor_mapping("B3", "A8"), + "MC1B": generate_motor_mapping("B15", "B14"), + "MC2A": generate_motor_mapping("B1", "A10"), + "MC2B": generate_motor_mapping("A9", "B13"), } @@ -160,6 +197,6 @@ def get_max_pwm_value(): "A2": {"pin": "A2"}, "A3": {"pin": "A3"}, "LED": {"pin": "C13"}, - "MA": {"d1": "A8", "p1": "B3"}, - "MB": {"d1": "B14", "p1": "B15"}, + "MA": generate_motor_mapping("B3", "A8"), + "MB": generate_motor_mapping("B15", "B14"), } From 7c940aba25f7a37a80fcadfa597ffc0c8c94d3a6 Mon Sep 17 00:00:00 2001 From: "Arend-Jan van Hilten (TU)" Date: Wed, 25 Oct 2023 14:06:32 +0200 Subject: [PATCH 2/5] Fix python no forward declaration --- mirte_telemetrix/scripts/mappings/pcb.py | 53 ++++++++++++------------ 1 file changed, 26 insertions(+), 27 deletions(-) diff --git a/mirte_telemetrix/scripts/mappings/pcb.py b/mirte_telemetrix/scripts/mappings/pcb.py index 73f8417..970b73d 100644 --- a/mirte_telemetrix/scripts/mappings/pcb.py +++ b/mirte_telemetrix/scripts/mappings/pcb.py @@ -3,33 +3,6 @@ import mappings.blackpill_f103c8 -mirte_pico_pcb_map08 = { - "IR1": {"digital": "16", "analog": "26"}, - "IR2": {"digital": "17", "analog": "27"}, - "SRF1": {"trigger": "7", "echo": "6"}, - "SRF2": {"trigger": "9", "echo": "8"}, - "I2C1": {"scl": "5", "sda": "4"}, - "I2C2": {"scl": "11", "sda": "10"}, - "ENC1": {"pin": "15"}, - "ENC2": {"pin": "14"}, - "Keypad": {"pin": "28"}, - "Servo1": {"pin": "14"}, - "Servo2": {"pin": "15"}, - "Servo3": {"pin": "12"}, - "Servo4": {"pin": "13"}, - "LED": {"pin": "25"}, # Does not work with the Pico W - "MC1-A": generate_motor_mapping("19", "18"), - "MC1-B": generate_motor_mapping("21", "20"), - "MC2-A": generate_motor_mapping("16", "26"), - "MC2-B": generate_motor_mapping("17", "27"), -} - - -version = 0.8 -board_mapping = mappings.pico -connector_mapping = mirte_pico_pcb_map08 - - def get_mcu(): return board_mapping.get_mcu() @@ -99,6 +72,32 @@ def generate_motor_mapping(pin_a, pin_b): return {"p1": pin_a, "p2": pin_b, "d1": pin_b, "d2": pin_a} +mirte_pico_pcb_map08 = { + "IR1": {"digital": "16", "analog": "26"}, + "IR2": {"digital": "17", "analog": "27"}, + "SRF1": {"trigger": "7", "echo": "6"}, + "SRF2": {"trigger": "9", "echo": "8"}, + "I2C1": {"scl": "5", "sda": "4"}, + "I2C2": {"scl": "11", "sda": "10"}, + "ENC1": {"pin": "15"}, + "ENC2": {"pin": "14"}, + "Keypad": {"pin": "28"}, + "Servo1": {"pin": "14"}, + "Servo2": {"pin": "15"}, + "Servo3": {"pin": "12"}, + "Servo4": {"pin": "13"}, + "LED": {"pin": "25"}, # Does not work with the Pico W + "MC1-A": generate_motor_mapping("19", "18"), + "MC1-B": generate_motor_mapping("21", "20"), + "MC2-A": generate_motor_mapping("16", "26"), + "MC2-B": generate_motor_mapping("17", "27"), +} + + +version = 0.8 +board_mapping = mappings.pico +connector_mapping = mirte_pico_pcb_map08 + # mappings for older pcbs mirte_pico_pcb_map06 = { "IR1": {"digital": "16", "analog": "26"}, From ac8a4551c5da1ab14a95534983c453fb77011f21 Mon Sep 17 00:00:00 2001 From: "Arend-Jan van Hilten (TU)" Date: Wed, 25 Oct 2023 14:14:16 +0200 Subject: [PATCH 3/5] config file fixes --- mirte_telemetrix/config/mirte_pcb06_config.yaml | 1 + mirte_telemetrix/config/old/mirte_pcb04stm_config.yaml | 3 +-- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mirte_telemetrix/config/mirte_pcb06_config.yaml b/mirte_telemetrix/config/mirte_pcb06_config.yaml index 278d3ac..36ee7cd 100644 --- a/mirte_telemetrix/config/mirte_pcb06_config.yaml +++ b/mirte_telemetrix/config/mirte_pcb06_config.yaml @@ -44,6 +44,7 @@ oled: # name: left # device: mirte # connector: Servo1 +servo: right: name: right device: mirte diff --git a/mirte_telemetrix/config/old/mirte_pcb04stm_config.yaml b/mirte_telemetrix/config/old/mirte_pcb04stm_config.yaml index d0b8bbf..bc9c4c0 100644 --- a/mirte_telemetrix/config/old/mirte_pcb04stm_config.yaml +++ b/mirte_telemetrix/config/old/mirte_pcb04stm_config.yaml @@ -47,8 +47,7 @@ servo: name: left device: mirte connector: Servo1 -servo: - left: + right: name: right device: mirte connector: Servo2 From 1881e0956891bc175478c7bbe1b92efdc358f2a8 Mon Sep 17 00:00:00 2001 From: "Arend-Jan van Hilten (TU)" Date: Thu, 26 Oct 2023 21:44:48 +0200 Subject: [PATCH 4/5] Removed empty lines --- mirte_telemetrix/config/mirte_pcb06_config.yaml | 1 - mirte_telemetrix/config/mirte_pcb08_config.yaml | 1 - 2 files changed, 2 deletions(-) diff --git a/mirte_telemetrix/config/mirte_pcb06_config.yaml b/mirte_telemetrix/config/mirte_pcb06_config.yaml index 36ee7cd..33ef200 100644 --- a/mirte_telemetrix/config/mirte_pcb06_config.yaml +++ b/mirte_telemetrix/config/mirte_pcb06_config.yaml @@ -59,7 +59,6 @@ servo: name: arm device: mirte connector: Servo4 - keypad: yellow: name: keypad diff --git a/mirte_telemetrix/config/mirte_pcb08_config.yaml b/mirte_telemetrix/config/mirte_pcb08_config.yaml index 3185236..2b62349 100644 --- a/mirte_telemetrix/config/mirte_pcb08_config.yaml +++ b/mirte_telemetrix/config/mirte_pcb08_config.yaml @@ -58,7 +58,6 @@ servo: name: arm device: mirte connector: Servo4 - keypad: yellow: name: keypad From 1d2607752f31745ed9b42ccd2a95e63930b651a0 Mon Sep 17 00:00:00 2001 From: "Arend-Jan van Hilten (TU)" Date: Thu, 26 Oct 2023 21:51:32 +0200 Subject: [PATCH 5/5] Improve comments generate_motor_mapping --- mirte_telemetrix/config/mirte_pcb06_config.yaml | 2 +- mirte_telemetrix/scripts/mappings/pcb.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/mirte_telemetrix/config/mirte_pcb06_config.yaml b/mirte_telemetrix/config/mirte_pcb06_config.yaml index 33ef200..ada12e0 100644 --- a/mirte_telemetrix/config/mirte_pcb06_config.yaml +++ b/mirte_telemetrix/config/mirte_pcb06_config.yaml @@ -39,7 +39,7 @@ oled: name: right device: mirte connector: I2C1 -# Servo on GP2 doens't work with the v0.6 pcb, next version this should be fixed +# Servo on GP2 doesn't work with the v0.6 pcb, next version this should be fixed # left: # name: left # device: mirte diff --git a/mirte_telemetrix/scripts/mappings/pcb.py b/mirte_telemetrix/scripts/mappings/pcb.py index 970b73d..75cca27 100644 --- a/mirte_telemetrix/scripts/mappings/pcb.py +++ b/mirte_telemetrix/scripts/mappings/pcb.py @@ -61,13 +61,13 @@ def get_max_pwm_value(): def generate_motor_mapping(pin_a, pin_b): # pin a has preference for pwm + # Different controllers(single pwm with direction, 2 pwm channels, 2 digital channels, 2 digital + 1 pwm) use different pin names. # This will make sure, dp, pp and dd is always possible when using a connector without knowing what type of control # A B # pp P1 P2 # dp P1 D1 - # dd D2 D1 # Not available - # ddp TODO connectors - # Downside: when changing from pp/dp to dd, the direction will change + # dd D2 D1 # Not (yet) available the ROS_telemetrix code. Downside when adding this: when changing from pp/dp to dd, the direction will change. Only fix is to let this system know the type of controller. + # ddp TODO connectors, as there is no third pin on a motor connector. return {"p1": pin_a, "p2": pin_b, "d1": pin_b, "d2": pin_a}