motion test

This commit is contained in:
Siwat Sirichai 2022-10-30 15:57:00 +07:00
parent 50fc6dda3f
commit 2e2316e471
11 changed files with 55 additions and 24 deletions

View File

@ -1,5 +1,5 @@
from telemetrix_rpi_pico import telemetrix_rpi_pico
from kuukar_config import COLLISION_DETECTOR_PIN
from kuukar.kuukar_config import COLLISION_DETECTOR_PIN
from kuukar_lcd import lcd
from kuukar_leds import leds

View File

@ -9,14 +9,14 @@ SONAR_3_TRIG_PIN = 4
SONAR_3_ECHO_PIN = 5
# Motor Pins
MOTOR_FL_F = 6
MOTOR_FL_R = 7
MOTOR_FL_F = 7
MOTOR_FL_R = 6
MOTOR_FR_F = 8
MOTOR_FR_R = 9
MOTOR_RL_F = 10
MOTOR_RL_R = 11
MOTOR_RR_F = 12
MOTOR_RR_R = 13
MOTOR_RR_F = 13
MOTOR_RR_R = 12
# Full Speed 90 Degrees Turn Time
TURN_TIME_FS_90DEG_MS = 1500

View File

@ -1,5 +1,5 @@
from kuukar_lcd import lcd
from kuukar_leds import leds
from kuukar.kuukar_lcd import lcd
from kuukar.kuukar_leds import leds
class cv:

View File

@ -1,8 +1,8 @@
import threading
from time import sleep
from kuukar_lcd import lcd
from kuukar_leds import leds
from kuukar_sensors import sensors
from kuukar.kuukar_lcd import lcd
from kuukar.kuukar_leds import leds
from kuukar.kuukar_sensors import sensors
class environment:

View File

@ -1,4 +1,4 @@
import kuukar_nextion
import kuukar.kuukar_nextion as kuukar_nextion
class lcd:
def __init__(self) -> None:
self.nextion = kuukar_nextion.nextion()

View File

@ -2,7 +2,7 @@ import threading
from time import perf_counter
from telemetrix_rpi_pico import telemetrix_rpi_pico
import time
from kuukar_config import LEDS_DATA_PIN, LEDS_NUM, HEADLIGHT_LEDS, LEFT_SIGNAL_LEDS, RIGHT_SIGNAL_LEDS, REVERSE_LEDS
from kuukar.kuukar_config import LEDS_DATA_PIN, LEDS_NUM, HEADLIGHT_LEDS, LEFT_SIGNAL_LEDS, RIGHT_SIGNAL_LEDS, REVERSE_LEDS
class leds:

View File

@ -1,8 +1,8 @@
from random import randint
from kuukar_config import MOTOR_FL_F, MOTOR_FL_R, MOTOR_FR_F, MOTOR_FR_R, MOTOR_RL_F, MOTOR_RL_R, MOTOR_RR_F, MOTOR_RR_R, TURN_TIME_FS_90DEG_MS
from kuukar.kuukar_config import MOTOR_FL_F, MOTOR_FL_R, MOTOR_FR_F, MOTOR_FR_R, MOTOR_RL_F, MOTOR_RL_R, MOTOR_RR_F, MOTOR_RR_R, TURN_TIME_FS_90DEG_MS
import time
from kuukar_leds import leds
from kuukar_sensors import sensors
from kuukar.kuukar_leds import leds
from kuukar.kuukar_sensors import sensors
from telemetrix_rpi_pico import telemetrix_rpi_pico
import threading
@ -15,7 +15,7 @@ class motion:
self.driver = driver_board
self.leds = leds
self.sensors = sensors
self.roam_thread = threading.Thread(target=self.roam_loop)
self.roam_thread = threading.Thread(target=self.__roam_looper)
self.roam_thread.start()
drive_pins = [MOTOR_FL_F, MOTOR_FL_R, MOTOR_FR_F,
@ -48,10 +48,16 @@ class motion:
self.motor_write(MOTOR_RR_F, MOTOR_RR_R, -speed)
time.sleep(duration)
self.stop()
def turn_cont(self, speed: int):
if speed > 0:
self.leds.set_right_signal_led(False)
self.leds.set_right_signal_led(True)
elif speed < 0:
self.leds.set_left_signal_led(False)
self.leds.set_left_signal_led(True)
self.motor_write(MOTOR_FL_F, MOTOR_FL_R, speed)
self.motor_write(MOTOR_FR_F, MOTOR_FR_R, -speed)
self.motor_write(MOTOR_RL_F, MOTOR_RL_R, speed)
self.motor_write(MOTOR_RR_F, MOTOR_RR_R, -speed)
def stop(self):
self.leds.set_left_signal_led(False)

View File

@ -2,7 +2,6 @@ import binascii
from time import sleep
import serial
import threading
from kuukar_config import SERIAL_LCD
DATATYPE_NUMBER = '71'

View File

@ -1,6 +1,6 @@
from telemetrix_rpi_pico import telemetrix_rpi_pico
from kuukar_config import DHT22_PIN, SONAR_1_ECHO_PIN, SONAR_1_TRIG_PIN,\
from kuukar.kuukar_config import DHT22_PIN, SONAR_1_ECHO_PIN, SONAR_1_TRIG_PIN,\
SONAR_2_ECHO_PIN, SONAR_2_TRIG_PIN, SONAR_3_ECHO_PIN, SONAR_3_TRIG_PIN,\
LIGHT_ANALOG_PIN

View File

@ -1,7 +1,5 @@
from kuukar_lcd import lcd
from kuukar_leds import leds
from kuukar_noise import noise
from kuukar.kuukar_lcd import lcd
from kuukar.kuukar_leds import leds
class voice:
def __init__(self, lcd: lcd, leds: leds) -> None:

28
test.py Normal file
View File

@ -0,0 +1,28 @@
import time
from telemetrix_rpi_pico import telemetrix_rpi_pico
import kuukar.kuukar_motion as kuukar_motion
import kuukar.kuukar_sensors as kuukar_sensors
from kuukar.kuukar_config import SERIAL_AUX_BOARD, SERIAL_DRIVER_BOARD
from kuukar.kuukar_config import MOTOR_FL_F, MOTOR_FL_R, MOTOR_FR_F, MOTOR_FR_R, MOTOR_RL_F, MOTOR_RL_R, MOTOR_RR_F, MOTOR_RR_R, TURN_TIME_FS_90DEG_MS
driver_board = telemetrix_rpi_pico.TelemetrixRpiPico()
motion = kuukar_motion.motion(driver_board, None, None)
motion.drive(30)
def rot_test():
while True:
speed = 30
motion.motor_write(MOTOR_FL_F, MOTOR_FL_R, speed)
motion.motor_write(MOTOR_FR_F, MOTOR_FR_R, -speed)
motion.motor_write(MOTOR_RL_F, MOTOR_RL_R, speed)
motion.motor_write(MOTOR_RR_F, MOTOR_RR_R, -speed)
time.sleep(0.5)
speed = -speed
motion.motor_write(MOTOR_FL_F, MOTOR_FL_R, speed)
motion.motor_write(MOTOR_FR_F, MOTOR_FR_R, -speed)
motion.motor_write(MOTOR_RL_F, MOTOR_RL_R, speed)
motion.motor_write(MOTOR_RR_F, MOTOR_RR_R, -speed)
time.sleep(0.5)