Skip to content

Api update #12

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 27 commits into from
Feb 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
7d3aa5a
impr: documentation
eigen-value Feb 19, 2024
a930f81
fix: typo
eigen-value Feb 19, 2024
19bd343
fix: message_reader not setting initial speed
eigen-value Feb 19, 2024
3c14a85
feat: idle state
eigen-value Feb 19, 2024
1e22b5f
fix: CHECK_STM32 must be PULL_DOWN
eigen-value Feb 19, 2024
a1c94a4
feat: SOC with leds, _upadate resets STM32 after idle
eigen-value Feb 19, 2024
4e19bc7
feat: SOC _progress_bar on _idle
eigen-value Feb 20, 2024
061731c
feat: SOC progress bar with emojis
eigen-value Feb 20, 2024
9082cb4
feat: snake vs robot animation
eigen-value Feb 20, 2024
d1a1a3b
fix: update thread stuck on idle
eigen-value Feb 20, 2024
5c6a159
impr: Alvik on/off repl output
eigen-value Feb 20, 2024
2709b87
fix: checking VIOLET label 2 times
eigen-value Feb 21, 2024
2bcb54e
mod: replace is_alvik_on with is_on
eigen-value Feb 23, 2024
c17c9a3
fix: alvikdev-58 FW updater stuck if robot is off
eigen-value Feb 23, 2024
69f4469
get_battery_charge
eigen-value Feb 23, 2024
44a61c7
Merge branch 'dev' into api_update
eigen-value Feb 23, 2024
def43ba
mod: get_color_label split in hsv2label(h,s,v) and get_color_label()
eigen-value Feb 26, 2024
ba3e0b5
mod: get_battery_charge returns an int
eigen-value Feb 26, 2024
1149178
fix: examples must not access class parameters directly
eigen-value Feb 26, 2024
27cc769
fix: examples must not access class parameters directly
eigen-value Feb 26, 2024
33a98f9
feat: members as private
eigen-value Feb 26, 2024
9dc9394
fix: lost _last_ack
eigen-value Feb 26, 2024
b48fc96
mod: _idle updating every second
eigen-value Feb 26, 2024
921e59b
mod: ALVIKDEV-68 lower charge threshold to 97
eigen-value Feb 26, 2024
6538c58
exmaples: pose_example.py with wait if non-blocking
eigen-value Feb 26, 2024
94cf84a
Merge pull request #11 from arduino/private_members
gbr1 Feb 26, 2024
a67e376
improvements:
eigen-value Feb 27, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
506 changes: 337 additions & 169 deletions arduino_alvik.py

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions conversions.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ def wrapper(*args, **kwargs):
return func(*args, **kwargs)
except KeyError:
raise ConversionError(f'Cannot {func.__name__} from {args[1]} to {args[2]}')
except TypeError:
return None
except Exception as e:
raise ConversionError(f'Unexpected error: {e}')
return wrapper


Expand Down
11 changes: 7 additions & 4 deletions examples/message_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,19 @@
if alvik.begin() < 0:
sys.exit()

speed = 0

while True:
try:
print(f'VER: {alvik.version}')
print(f'VER: {alvik.get_version()}')
print(f'LSP: {alvik.left_wheel.get_speed()}')
print(f'RSP: {alvik.right_wheel.get_speed()}')
print(f'LPOS: {alvik.left_wheel.get_position()}')
print(f'RPOS: {alvik.right_wheel.get_position()}')
print(f'TOUCH: {alvik.touch_bits}')
print(f'RGB: {alvik.red} {alvik.green} {alvik.blue}')
print(f'LINE: {alvik.left_line} {alvik.center_line} {alvik.right_line}')
print(f'TOUCH (UP): {alvik.get_touch_up()}')
print(f'RGB: {alvik.get_color()}')
print(f'LINE: {alvik.get_line_sensors()}')
print(f'SOC: {alvik.get_battery_charge()}%')

alvik.set_wheels_speed(speed, speed)
speed = (speed + 1) % 60
Expand Down
24 changes: 24 additions & 0 deletions examples/pose_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,39 @@
alvik.move(50.0, 'mm', blocking=False)
print("on target after move")

while not alvik.is_target_reached():
alvik.left_led.set_color(1, 0, 0)
sleep_ms(500)
alvik.left_led.set_color(0, 0, 0)
sleep_ms(500)

alvik.rotate(45.0, 'deg', blocking=False)
print("on target after rotation")

while not alvik.is_target_reached():
alvik.left_led.set_color(1, 0, 0)
sleep_ms(500)
alvik.left_led.set_color(0, 0, 0)
sleep_ms(500)

alvik.move(100.0, 'mm', blocking=False)
print("on target after move")

while not alvik.is_target_reached():
alvik.left_led.set_color(1, 0, 0)
sleep_ms(500)
alvik.left_led.set_color(0, 0, 0)
sleep_ms(500)

alvik.rotate(-90.00, 'deg', blocking=False)
print("on target after rotation")

while not alvik.is_target_reached():
alvik.left_led.set_color(1, 0, 0)
sleep_ms(500)
alvik.left_led.set_color(0, 0, 0)
sleep_ms(500)

x, y, theta = alvik.get_pose()
print(f'Current pose is x(cm)={x}, y(cm)={y}, theta(deg)={theta}')

Expand Down
2 changes: 1 addition & 1 deletion examples/read_color_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
r, g, b = alvik.get_color()
h, s, v = alvik.get_color('hsv')
print(f'RED: {r}, Green: {g}, Blue: {b}, HUE: {h}, SAT: {s}, VAL: {v}')
print(f'COLOR LABEL: {alvik.get_color_label(h, s, v)}')
print(f'COLOR LABEL: {alvik.get_color_label()}')
sleep_ms(100)
except KeyboardInterrupt as e:
print('over')
Expand Down
23 changes: 23 additions & 0 deletions examples/test_idle.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
from arduino_alvik import ArduinoAlvik
from time import sleep_ms
import sys

alvik = ArduinoAlvik()
alvik.begin()

speed = 0

while True:
try:

if alvik.is_on():
print(f'VER: {alvik.get_version()}')
print(f'LSP: {alvik.left_wheel.get_speed()}')
alvik.set_wheels_speed(speed, speed)
speed = (speed + 1) % 30
sleep_ms(1000)
except KeyboardInterrupt as e:
print('over')
alvik.stop()
sys.exit()

9 changes: 7 additions & 2 deletions pinout_definitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@

BOOT0_STM32 = Pin(D2, Pin.OUT) # nano D2 -> STM32 Boot0
RESET_STM32 = Pin(D3, Pin.OUT) # nano D3 -> STM32 NRST
NANO_CHK = Pin(D4, Pin.OUT) # nano D3 -> STM32 NANO_CHK
CHECK_STM32 = Pin(A6, Pin.IN, Pin.PULL_UP) # nano A6/D23 -> STM32 ROBOT_CHK
NANO_CHK = Pin(D4, Pin.OUT) # nano D4 -> STM32 NANO_CHK
CHECK_STM32 = Pin(A6, Pin.IN, Pin.PULL_DOWN) # nano A6/D23 -> STM32 ROBOT_CHK
ESP32_SDA = Pin(A4, Pin.OUT) # ESP32_SDA
ESP32_SCL = Pin(A5, Pin.OUT) # ESP32_SCL

# LEDS
LEDR = Pin(46, Pin.OUT) #RED ESP32 LEDR
LEDG = Pin(0, Pin.OUT) #GREEN ESP32 LEDG
LEDB = Pin(45, Pin.OUT) #BLUE ESP32 LEDB
7 changes: 6 additions & 1 deletion utilities/firmware_updater.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
from sys import exit
from stm32_flash import *

if CHECK_STM32.value() is not 1:
print("Turn on your Alvik to continue...")
while CHECK_STM32.value() is not 1:
sleep_ms(500)

ans = STM32_startCommunication()
if ans == STM32_NACK:
print("Cannot etablish connection with STM32")
print("Cannot establish connection with STM32")
exit(-1)

print('\nSTM32 FOUND')
Expand Down
3 changes: 3 additions & 0 deletions utilities/stm32_flash.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
from time import sleep_ms
from machine import UART, Pin

A6 = 13 # ESP32 pin13 -> nano A6/D23
CHECK_STM32 = Pin(A6, Pin.IN) # nano A6/D23 -> TO CHECK STM32 IS ON

STM32_INIT = b'\x7F'
STM32_NACK = b'\x1F'
STM32_ACK = b'\x79'
Expand Down