diff --git a/3D_model_for _printing.jpg b/3D_model_for _printing.jpg new file mode 100644 index 0000000..1f91e05 Binary files /dev/null and b/3D_model_for _printing.jpg differ diff --git a/Engine_test.mp4 b/Engine_test.mp4 new file mode 100644 index 0000000..f8614fb Binary files /dev/null and b/Engine_test.mp4 differ diff --git a/components.jpg b/components.jpg new file mode 100644 index 0000000..03d9452 Binary files /dev/null and b/components.jpg differ diff --git a/components2.jpg b/components2.jpg new file mode 100644 index 0000000..22911a8 Binary files /dev/null and b/components2.jpg differ diff --git a/first_launch.mp4 b/first_launch.mp4 new file mode 100644 index 0000000..91cda6f Binary files /dev/null and b/first_launch.mp4 differ diff --git a/first_version_platform.jpg b/first_version_platform.jpg new file mode 100644 index 0000000..808638d Binary files /dev/null and b/first_version_platform.jpg differ diff --git a/lidar.py b/lidar.py new file mode 100644 index 0000000..b4c7ba0 --- /dev/null +++ b/lidar.py @@ -0,0 +1,98 @@ +import RPi.GPIO as GPIO +import serial +import time +import numpy as np +import matplotlib.pyplot as plt +from matplotlib.animation import FuncAnimation +import keyboard + +# Настройки GPIO +IN1 = 23 +IN2 = 24 +IN3 = 17 +IN4 = 27 +ENA = 26 +ENB = 19 + +GPIO.setwarnings(False) +GPIO.setmode(GPIO.BCM) +GPIO.setup(IN1, GPIO.OUT) +GPIO.setup(IN2, GPIO.OUT) +GPIO.setup(IN3, GPIO.OUT) +GPIO.setup(IN4, GPIO.OUT) +GPIO.setup(ENA, GPIO.OUT) +GPIO.setup(ENB, GPIO.OUT) + +# Параметры для лидара +lidar_port = '/dev/ttyUSB1' # Убедитесь, что это правильный порт +baud_rate = 115200 + +# Настройка серийного соединения +ser = serial.Serial(lidar_port, baud_rate, timeout=1) + +# Параметры скорости +speed = 10 # Регулируйте скорость по необходимости +GPIO.output(ENA, speed) +GPIO.output(ENB, speed) + +# Функции управления движением +def move_forward(): + GPIO.output(IN1, GPIO.HIGH) + GPIO.output(IN2, GPIO.LOW) + GPIO.output(IN3, GPIO.HIGH) + GPIO.output(IN4, GPIO.LOW) + print("Робот движется вперед") + +def move_backward(): + GPIO.output(IN1, GPIO.LOW) + GPIO.output(IN2, GPIO.HIGH) + GPIO.output(IN3, GPIO.LOW) + GPIO.output(IN4, GPIO.HIGH) + print("Робот движется назад") + +def stop(): + GPIO.output(IN1, GPIO.LOW) + GPIO.output(IN2, GPIO.LOW) + GPIO.output(IN3, GPIO.LOW) + GPIO.output(IN4, GPIO.LOW) + print("Робот остановлен") + +def read_lidar_data(): + try: + line = ser.readline().decode('utf-8', errors='ignore').strip() + if line: + print(f"Считанные данные от лидара: {line}") # Отладка + return line # Вернем считанные данные + else: + print("Нет данных") + return None + except Exception as e: + print(f"Ошибка чтения данных от лидара: {e}") + return None + +# Визуализация карты препятствий +def update_plot(frame): + data = read_lidar_data() # Получаем данные от лидара + if data is not None: + # Логика для визуализации данных + # Вставьте здесь ваш код для построения карты препятствий + pass # Замените на свою логику + +# Основной цикл +def main(): + print("Нажмите 'W' для запуска автономного движения и ' ' (пробел) для остановки.") + while True: + if keyboard.is_pressed('w'): + move_forward() + print("Автономное движение включено") + if keyboard.is_pressed('s'): + move_backward() + if keyboard.is_pressed(' '): + stop() + print("Автономное движение остановлено") + # Добавьте паузу, чтобы избежать высокой загрузки CPU + time.sleep(0.1) + +# Запуск программы +if __name__ == "__main__": + main() diff --git a/lidar_platform.jpg b/lidar_platform.jpg new file mode 100644 index 0000000..b1f9fb2 Binary files /dev/null and b/lidar_platform.jpg differ diff --git a/lidar_platform2.jpg b/lidar_platform2.jpg new file mode 100644 index 0000000..e2dd9cd Binary files /dev/null and b/lidar_platform2.jpg differ diff --git a/platform_second_version.jpg b/platform_second_version.jpg new file mode 100644 index 0000000..6167956 Binary files /dev/null and b/platform_second_version.jpg differ diff --git a/platform_second_version2.jpg b/platform_second_version2.jpg new file mode 100644 index 0000000..dcc292c Binary files /dev/null and b/platform_second_version2.jpg differ diff --git a/platform_version_two_first_launch.mp4 b/platform_version_two_first_launch.mp4 new file mode 100644 index 0000000..6c40d95 Binary files /dev/null and b/platform_version_two_first_launch.mp4 differ diff --git a/upravlenie.py b/upravlenie.py new file mode 100644 index 0000000..10f9014 --- /dev/null +++ b/upravlenie.py @@ -0,0 +1,115 @@ +import RPi.GPIO as GPIO +import time +import keyboard + +# Настройка пинов +GPIO.setmode(GPIO.BCM) + +# Пины для управления моторами +IN1 = 17 +IN2 = 27 +IN3 = 22 +IN4 = 23 + +# Пины для управления скоростью (PWM) +ENA = 18 +ENB = 19 + +# Настройка пинов как выходов +GPIO.setup(IN1, GPIO.OUT) +GPIO.setup(IN2, GPIO.OUT) +GPIO.setup(IN3, GPIO.OUT) +GPIO.setup(IN4, GPIO.OUT) +GPIO.setup(ENA, GPIO.OUT) +GPIO.setup(ENB, GPIO.OUT) + +# Создание ШИМ (PWM) на пинах ENA и ENB с частотой 1000 Гц +pwm_a = GPIO.PWM(ENA, 1000) +pwm_b = GPIO.PWM(ENB, 1000) + +# Старт ШИМ с нулевой скоростью (0% скважности) +pwm_a.start(0) +pwm_b.start(0) + +# Функции управления +def move_forward(speed): + GPIO.output(IN1, GPIO.HIGH) + GPIO.output(IN2, GPIO.LOW) + GPIO.output(IN3, GPIO.HIGH) + GPIO.output(IN4, GPIO.LOW) + pwm_a.ChangeDutyCycle(speed) + pwm_b.ChangeDutyCycle(speed) + print(f"Moving forward at speed {speed}") + +def move_backward(speed): + GPIO.output(IN1, GPIO.LOW) + GPIO.output(IN2, GPIO.HIGH) + GPIO.output(IN3, GPIO.LOW) + GPIO.output(IN4, GPIO.HIGH) + pwm_a.ChangeDutyCycle(speed) + pwm_b.ChangeDutyCycle(speed) + print(f"Moving backward at speed {speed}") + +def move_left(speed): + GPIO.output(IN1, GPIO.LOW) + GPIO.output(IN2, GPIO.HIGH) + GPIO.output(IN3, GPIO.HIGH) + GPIO.output(IN4, GPIO.LOW) + pwm_a.ChangeDutyCycle(speed) + pwm_b.ChangeDutyCycle(speed) + print(f"Turning left at speed {speed}") + +def move_right(speed): + GPIO.output(IN1, GPIO.HIGH) + GPIO.output(IN2, GPIO.LOW) + GPIO.output(IN3, GPIO.LOW) + GPIO.output(IN4, GPIO.HIGH) + pwm_a.ChangeDutyCycle(speed) + pwm_b.ChangeDutyCycle(speed) + print(f"Turning right at speed {speed}") + +def stop(): + GPIO.output(IN1, GPIO.LOW) + GPIO.output(IN2, GPIO.LOW) + GPIO.output(IN3, GPIO.LOW) + GPIO.output(IN4, GPIO.LOW) + pwm_a.ChangeDutyCycle(0) + pwm_b.ChangeDutyCycle(0) + print("Stopped") + +try: + speed = 50 # Начальная скорость (50% ШИМ) + print("Use W/A/S/D to move and adjust speed, release key to stop") + + while True: + # Проверка нажатия клавиш для движения + if keyboard.is_pressed('w'): + move_forward(speed) + elif keyboard.is_pressed('s'): + move_backward(speed) + elif keyboard.is_pressed('a'): + move_left(speed) + elif keyboard.is_pressed('d'): + move_right(speed) + else: + # Если ни одна из клавиш не нажата, остановить моторы + stop() + + # Регулировка скорости + if keyboard.is_pressed('q'): # Уменьшение скорости + speed = max(0, speed - 10) + print(f"Speed decreased to {speed}%") + time.sleep(0.1) + elif keyboard.is_pressed('e'): # Увеличение скорости + speed = min(100, speed + 10) + print(f"Speed increased to {speed}%") + time.sleep(0.1) + + time.sleep(0.05) # Небольшая задержка для плавного опроса клавиш + +except KeyboardInterrupt: + stop() # Остановка моторов при прерывании программы +finally: + pwm_a.stop() + pwm_b.stop() + GPIO.cleanup() # Очистка конфигурации GPIO diff --git a/Деталь 1 первый уровень.STL b/Деталь 1 первый уровень.STL new file mode 100644 index 0000000..a42eeed Binary files /dev/null and b/Деталь 1 первый уровень.STL differ diff --git a/Деталь 2 второй уровень.STL b/Деталь 2 второй уровень.STL new file mode 100644 index 0000000..4aa716b Binary files /dev/null and b/Деталь 2 второй уровень.STL differ diff --git a/Деталь 3 третий уровень.STL b/Деталь 3 третий уровень.STL new file mode 100644 index 0000000..f574373 Binary files /dev/null and b/Деталь 3 третий уровень.STL differ diff --git a/Деталь 4 четвёртый уровень.STL b/Деталь 4 четвёртый уровень.STL new file mode 100644 index 0000000..5dc3a39 Binary files /dev/null and b/Деталь 4 четвёртый уровень.STL differ