Skip to content

Commit

Permalink
Merge branch 'main' into fix-oled
Browse files Browse the repository at this point in the history
  • Loading branch information
mklomp authored Oct 27, 2023
2 parents 5edd6ba + 8b3e56c commit 0406ed5
Show file tree
Hide file tree
Showing 5 changed files with 187 additions and 65 deletions.
4 changes: 2 additions & 2 deletions mirte_telemetrix/config/mirte_pcb06_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,12 @@ 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
# connector: Servo1
servo:
right:
name: right
device: mirte
Expand All @@ -58,7 +59,6 @@ oled:
name: arm
device: mirte
connector: Servo4

keypad:
yellow:
name: keypad
Expand Down
89 changes: 89 additions & 0 deletions mirte_telemetrix/config/mirte_pcb08_config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
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
34 changes: 16 additions & 18 deletions mirte_telemetrix/config/mirte_user_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ distance:
# pin: GP15
intensity:
left:
name: left
name: left
device: mirte
pins:
analog: GP27
Expand All @@ -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:
Expand All @@ -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:
Expand All @@ -114,4 +113,3 @@ motor:
# pins:
# p1: GP27
# p2: GP17
# TODO: add obstacle detection
3 changes: 1 addition & 2 deletions mirte_telemetrix/config/old/mirte_pcb04stm_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ servo:
name: left
device: mirte
connector: Servo1
servo:
left:
right:
name: right
device: mirte
connector: Servo2
Expand Down
122 changes: 79 additions & 43 deletions mirte_telemetrix/scripts/mappings/pcb.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,37 +3,6 @@
import mappings.blackpill_f103c8


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": {"1a": "19", "1b": "18"},
"MC1-B": {"1a": "21", "1b": "20"},
"MC2-A": {"1a": "16", "1b": "26"},
"MC2-B": {"1a": "17", "1b": "27"},
}


version = 0.6
board_mapping = mappings.pico
connector_mapping = mirte_pico_pcb_map06


def get_mcu():
return board_mapping.get_mcu()

Expand Down Expand Up @@ -65,8 +34,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
Expand All @@ -86,7 +59,70 @@ 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
# 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 (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}


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"},
"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"},
Expand All @@ -103,10 +139,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 = {
Expand All @@ -120,8 +156,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 = {
Expand All @@ -139,10 +175,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"),
}


Expand All @@ -160,6 +196,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"),
}

0 comments on commit 0406ed5

Please sign in to comment.