motion test
This commit is contained in:
parent
50fc6dda3f
commit
2e2316e471
|
@ -1,5 +1,5 @@
|
||||||
from telemetrix_rpi_pico import telemetrix_rpi_pico
|
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_lcd import lcd
|
||||||
from kuukar_leds import leds
|
from kuukar_leds import leds
|
||||||
|
|
|
@ -9,14 +9,14 @@ SONAR_3_TRIG_PIN = 4
|
||||||
SONAR_3_ECHO_PIN = 5
|
SONAR_3_ECHO_PIN = 5
|
||||||
|
|
||||||
# Motor Pins
|
# Motor Pins
|
||||||
MOTOR_FL_F = 6
|
MOTOR_FL_F = 7
|
||||||
MOTOR_FL_R = 7
|
MOTOR_FL_R = 6
|
||||||
MOTOR_FR_F = 8
|
MOTOR_FR_F = 8
|
||||||
MOTOR_FR_R = 9
|
MOTOR_FR_R = 9
|
||||||
MOTOR_RL_F = 10
|
MOTOR_RL_F = 10
|
||||||
MOTOR_RL_R = 11
|
MOTOR_RL_R = 11
|
||||||
MOTOR_RR_F = 12
|
MOTOR_RR_F = 13
|
||||||
MOTOR_RR_R = 13
|
MOTOR_RR_R = 12
|
||||||
|
|
||||||
# Full Speed 90 Degrees Turn Time
|
# Full Speed 90 Degrees Turn Time
|
||||||
TURN_TIME_FS_90DEG_MS = 1500
|
TURN_TIME_FS_90DEG_MS = 1500
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
from kuukar_lcd import lcd
|
from kuukar.kuukar_lcd import lcd
|
||||||
from kuukar_leds import leds
|
from kuukar.kuukar_leds import leds
|
||||||
|
|
||||||
|
|
||||||
class cv:
|
class cv:
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import threading
|
import threading
|
||||||
from time import sleep
|
from time import sleep
|
||||||
from kuukar_lcd import lcd
|
from kuukar.kuukar_lcd import lcd
|
||||||
from kuukar_leds import leds
|
from kuukar.kuukar_leds import leds
|
||||||
from kuukar_sensors import sensors
|
from kuukar.kuukar_sensors import sensors
|
||||||
|
|
||||||
|
|
||||||
class environment:
|
class environment:
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import kuukar_nextion
|
import kuukar.kuukar_nextion as kuukar_nextion
|
||||||
class lcd:
|
class lcd:
|
||||||
def __init__(self) -> None:
|
def __init__(self) -> None:
|
||||||
self.nextion = kuukar_nextion.nextion()
|
self.nextion = kuukar_nextion.nextion()
|
||||||
|
|
|
@ -2,7 +2,7 @@ import threading
|
||||||
from time import perf_counter
|
from time import perf_counter
|
||||||
from telemetrix_rpi_pico import telemetrix_rpi_pico
|
from telemetrix_rpi_pico import telemetrix_rpi_pico
|
||||||
import time
|
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:
|
class leds:
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
from random import randint
|
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
|
import time
|
||||||
from kuukar_leds import leds
|
from kuukar.kuukar_leds import leds
|
||||||
from kuukar_sensors import sensors
|
from kuukar.kuukar_sensors import sensors
|
||||||
from telemetrix_rpi_pico import telemetrix_rpi_pico
|
from telemetrix_rpi_pico import telemetrix_rpi_pico
|
||||||
import threading
|
import threading
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ class motion:
|
||||||
self.driver = driver_board
|
self.driver = driver_board
|
||||||
self.leds = leds
|
self.leds = leds
|
||||||
self.sensors = sensors
|
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()
|
self.roam_thread.start()
|
||||||
|
|
||||||
drive_pins = [MOTOR_FL_F, MOTOR_FL_R, MOTOR_FR_F,
|
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)
|
self.motor_write(MOTOR_RR_F, MOTOR_RR_R, -speed)
|
||||||
time.sleep(duration)
|
time.sleep(duration)
|
||||||
self.stop()
|
self.stop()
|
||||||
|
|
||||||
|
def turn_cont(self, speed: int):
|
||||||
if speed > 0:
|
if speed > 0:
|
||||||
self.leds.set_right_signal_led(False)
|
self.leds.set_right_signal_led(True)
|
||||||
elif speed < 0:
|
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):
|
def stop(self):
|
||||||
self.leds.set_left_signal_led(False)
|
self.leds.set_left_signal_led(False)
|
||||||
|
|
|
@ -2,7 +2,6 @@ import binascii
|
||||||
from time import sleep
|
from time import sleep
|
||||||
import serial
|
import serial
|
||||||
import threading
|
import threading
|
||||||
|
|
||||||
from kuukar_config import SERIAL_LCD
|
from kuukar_config import SERIAL_LCD
|
||||||
|
|
||||||
DATATYPE_NUMBER = '71'
|
DATATYPE_NUMBER = '71'
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
from telemetrix_rpi_pico import telemetrix_rpi_pico
|
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,\
|
SONAR_2_ECHO_PIN, SONAR_2_TRIG_PIN, SONAR_3_ECHO_PIN, SONAR_3_TRIG_PIN,\
|
||||||
LIGHT_ANALOG_PIN
|
LIGHT_ANALOG_PIN
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
from kuukar_lcd import lcd
|
from kuukar.kuukar_lcd import lcd
|
||||||
from kuukar_leds import leds
|
from kuukar.kuukar_leds import leds
|
||||||
from kuukar_noise import noise
|
|
||||||
|
|
||||||
|
|
||||||
class voice:
|
class voice:
|
||||||
def __init__(self, lcd: lcd, leds: leds) -> None:
|
def __init__(self, lcd: lcd, leds: leds) -> None:
|
||||||
|
|
|
@ -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)
|
||||||
|
|
Loading…
Reference in New Issue