示例#1
0
 def __init__(self):
     self.bot = pibot.PiBot()
     self.bot.InitMotorDriver(pibot.DRIVER_M_1_2)
     self.bot.Enable()
     self.bot.SetMotorDrive(pibot.M1, 0)
     self.bot.SetMotorDrive(pibot.M2, 0)
     self.servo_h = 90
     self.servo_v = 90
     self.bot.SetServoControl(self.SERVO_H,
                              RobotJoystick.angle_to_t(self.servo_h))
     self.bot.SetServoControl(self.SERVO_V,
                              RobotJoystick.angle_to_t(self.servo_v))
示例#2
0
    def __init__(self, robotConfig):

        if USE_PIBOT:
            self.robot = pibot.PiBot()
        else:
            self.robot = mini_driver.MiniDriver()
            connected = self.robot.connect()
            if not connected:
                raise Exception("Unable to connect to the mini driver")

        self.robotConfig = robotConfig
        self.leftMotorSpeed = 0
        self.rightMotorSpeed = 0
        self.panAngle = self.CENTRE_ANGLE
        self.tiltAngle = self.CENTRE_ANGLE

        self.panSpeed = 0.0
        self.tiltSpeed = 0.0

        self.lastServoSettingsSendTime = 0.0
        self.lastUpdateTime = 0.0
        self.lastMotionCommandTime = time.time()
MUSIC_VOLUME = 0.5
TEST_TIME = 10.0

scriptPath = os.path.dirname(__file__)

# Load test result sounds
pygame.init()
pygame.mixer.init()

pygame.mixer.music.load(scriptPath + "/../data/sounds/drum_roll.mp3")
pygame.mixer.music.set_volume(MUSIC_VOLUME)
pygame.mixer.music.play()

# Connect to the PiBot
bot = pibot.PiBot()

testStartTime = time.time()

while time.time() - testStartTime < TEST_TIME:

    curTime = time.time() - testStartTime

    # Set motor speeds
    if int(curTime) % 2 == 0:

        bot.setMotorSpeeds(192, -192)
        bot.setStepperSpeed(255)

        for pixelIdx in range(bot.NUM_NEO_PIXELS):