Пример #1
0
"""
import logging
import math
import pickle
import sys
import time
import geom_utils as geo
import omnicar as oc
import proscan
from pprint import pprint

logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)  # set to DEBUG | INFO | WARNING | ERROR
logger.addHandler(logging.StreamHandler(sys.stdout))

car = oc.OmniCar()
time.sleep(0.5)
from_arduino = car._read_serial_data()
logger.debug(f"Message from Arduino: {from_arduino}")

W2W_DIST = 34  # separation between coaxial wheels (cm)
SONAR_LIDAR_OFFSET = 15  # offset distance between sonar & lidar
FWD = 95  # forward drive direction (incl +5 'crab' compensation)
LFT = 180  # left drive direction
REV = 270  # reverse drive direction
RGT = 0  # right drive direction
KP = 0.25  # steering PID proportional coefficient
KD = 0.3  # steering PID derivative coefficient
CARSPEED = 150  # default car speed
RATE = 13.5  # cm/sec traveled by car @ CARSPEED = 150
R = 50  # Distance margin for clearing obstructions
Пример #2
0
"""
Test script for all motors (4 wheels & lidar rotor).
Consider putting the car up on blocks for this.
"""

import omnicar
import time

car = omnicar.OmniCar()

# Drive car (parameter = motor speed between 0 - 255)
# 'go' values < 90 or 'spin' values < 70 are unreliable due to friction
#

car.go_fwd(200)  # Forward
time.sleep(2)
car.stop_wheels()
time.sleep(1)

car.go_back(200)  # Back
time.sleep(2)
car.stop_wheels()
time.sleep(1)

car.go_left(90)  # Left
time.sleep(2)
car.stop_wheels()
time.sleep(1)

car.go_right(90)  # Right
time.sleep(2)