示例#1
0
        time.sleep(0.5)
        self.pwm.setPWM(14, 0, 0)
        self.pwm.setPWMFreq(1000)

    def zero(self):
        self.pwm.setPWMFreq(Servo.FREQ)
        self.pwm.setPWM(14, 0, 250)
        time.sleep(0.5)
        self.pwm.setPWM(14, 0, 0)
        self.pwm.setPWMFreq(1000)

    def restore_freq(self):
        self.pwm.setPWMFreq(1000)


robot = RobotEngine()
asdic = ASDIC()
servo = Servo()


def direction():
    servo.left()
    distance_left = asdic.ping()
    servo.right()
    distance_right = asdic.ping()
    servo.zero()
    if distance_left > distance_right:
        return -1
    return 1

示例#2
0
#!/usr/bin/python3
import sys
from robot.track import RobotEngine

import time
from robot.motors.motor_servo import PWM

re = RobotEngine()

re.speed_motor(25)
time.sleep(1.5)
re.speed_motor(-25)
time.sleep(1.5)
re.stop()


示例#3
0
#!/usr/bin/python3
import sys
from robot.track import RobotEngine

import time
from robot.motors.motor_servo import PWM

re = RobotEngine()

re.speed_motor(-30)
time.sleep(2)
re.stop()


示例#4
0
#!/usr/bin/python3
import sys
from robot.track import RobotEngine

import time
from robot.motors.motor_servo import PWM

re = RobotEngine()

re.turn(30)
time.sleep(1)
re.stop()


示例#5
0
#!/usr/bin/python3
import sys
from robot.track import RobotEngine

import time
from robot.motors.motor_servo import PWM

re = RobotEngine()

re.turn(-30)
time.sleep(0.25)
re.stop()