Compare commits
No commits in common. "cca77561b2d6b917f7c67814f219766e449041ba" and "f68e03753773e41e059fb26156dd942595972f34" have entirely different histories.
cca77561b2
...
f68e037537
40
app.py
40
app.py
|
@ -6,9 +6,12 @@ import kuukar.kuukar_motion as kuukar_motion
|
||||||
import kuukar.kuukar_lcd as kuukar_lcd
|
import kuukar.kuukar_lcd as kuukar_lcd
|
||||||
import kuukar.kuukar_sensors as kuukar_sensors
|
import kuukar.kuukar_sensors as kuukar_sensors
|
||||||
import kuukar.kuukar_environment as kuukar_environment
|
import kuukar.kuukar_environment as kuukar_environment
|
||||||
|
from flask import Flask, request
|
||||||
|
|
||||||
from kuukar.kuukar_config import SERIAL_MCU, SERIAL_DRV
|
from kuukar.kuukar_config import SERIAL_MCU, SERIAL_DRV
|
||||||
|
|
||||||
|
app = Flask(__name__)
|
||||||
|
|
||||||
mcu = telemetrix_rpi_pico.TelemetrixRpiPico(com_port=SERIAL_MCU)
|
mcu = telemetrix_rpi_pico.TelemetrixRpiPico(com_port=SERIAL_MCU)
|
||||||
drv = telemetrix_rpi_pico.TelemetrixRpiPico(com_port=SERIAL_DRV)
|
drv = telemetrix_rpi_pico.TelemetrixRpiPico(com_port=SERIAL_DRV)
|
||||||
sensors = kuukar_sensors.sensors(mcu)
|
sensors = kuukar_sensors.sensors(mcu)
|
||||||
|
@ -17,8 +20,7 @@ motion = kuukar_motion.motion(mcu, drv, leds, sensors)
|
||||||
lcd = kuukar_lcd.lcd(motion, sensors)
|
lcd = kuukar_lcd.lcd(motion, sensors)
|
||||||
environment = kuukar_environment.environment(lcd, leds, sensors)
|
environment = kuukar_environment.environment(lcd, leds, sensors)
|
||||||
collision = kuukar_collision.collision(mcu, lcd, leds)
|
collision = kuukar_collision.collision(mcu, lcd, leds)
|
||||||
|
motion.turn(30,3000)
|
||||||
motion.roam_start()
|
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
temp = sensors.get_temperature()
|
temp = sensors.get_temperature()
|
||||||
|
@ -28,3 +30,37 @@ while True:
|
||||||
dist3 = sensors.sonar_get_distance(2)
|
dist3 = sensors.sonar_get_distance(2)
|
||||||
print(f'temp: {temp}, humidity: {humid}, dist1: {dist1}, dist2: {dist2}, dist3: {dist3}')
|
print(f'temp: {temp}, humidity: {humid}, dist1: {dist1}, dist2: {dist2}, dist3: {dist3}')
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
|
|
||||||
|
@app.route('/drive')
|
||||||
|
def drive():
|
||||||
|
speed = int(request.args.get('speed'))
|
||||||
|
motion.drive(speed)
|
||||||
|
|
||||||
|
|
||||||
|
@app.route("/stop")
|
||||||
|
def stop():
|
||||||
|
motion.stop()
|
||||||
|
|
||||||
|
|
||||||
|
@app.route('/turn')
|
||||||
|
def turn():
|
||||||
|
speed = int(request.args.get('speed'))
|
||||||
|
duration = int(request.args.get('duration'))
|
||||||
|
motion.turn(speed, duration)
|
||||||
|
|
||||||
|
|
||||||
|
@app.route('/set_ambient_leds')
|
||||||
|
def set_ambient_leds():
|
||||||
|
r = int(request.args.get('r'))
|
||||||
|
g = int(request.args.get('g'))
|
||||||
|
b = int(request.args.get('b'))
|
||||||
|
leds.set_ambient_led(r, g, b)
|
||||||
|
|
||||||
|
|
||||||
|
@app.route('/set_mode')
|
||||||
|
def set_mode():
|
||||||
|
mode = str(request.args.get('mode'))
|
||||||
|
if mode == "AI":
|
||||||
|
motion.roam_start()
|
||||||
|
elif mode == "MANUAL":
|
||||||
|
motion.roam_stop()
|
||||||
|
|
|
@ -109,6 +109,4 @@ class motion:
|
||||||
self.turn(-23, TURN_TIME_FS_90DEG_MS)
|
self.turn(-23, TURN_TIME_FS_90DEG_MS)
|
||||||
self.drive(30)
|
self.drive(30)
|
||||||
self.stop()
|
self.stop()
|
||||||
|
print("stopping")
|
||||||
print("stopping")
|
|
||||||
time.sleep(0.5)
|
|
Loading…
Reference in New Issue