Exemple #1
0
print "Running obstacle avoidance code."
# Import libraries.
import Lobsang, time, random, sys

# Initialise Lobsang.
Lobsang.begin()
# Point the head straight forward.
Lobsang.head.aim(1430, 1430)

# This becomes a map of the distances from the robot's head
# each time turn_optimum_distance() is run. Length 7.
dist_map = [0, 0, 0, 0, 0, 0, 0]

# This becomes a log of the distances from the robot's head
# over a number of cycles. If lots of the measurements are
# similar but the robot is driving forward, then it has
# probably got stuck on something it can't see. Length 10.
dist_log = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]

# Number of loops per second- this is only approximate.
# Real loops per sec = 1 / LPS + time loop takes to complete.
LPS = 10.0

# This is the number of loops before the random direction
# checks begin again, but initially represented in seconds.
loops_before_recheck = 2
loops_before_recheck *= LPS # To get actual number of loops.

# Number of loops done so far.
loops_since_last_check = 0
launch_ball = False
paddle_open = False

open_guide = True
opened = True
redraw = False

# Set up pygame.
pygame.init()
DISPLAYSURF = pygame.display.set_mode((1280, 800))
pygame.display.set_caption('Lobsang Skittles Challenge')
clock = pygame.time.Clock()

# Set up Lobsang.
Lobsang.begin(splashscreen=False)
Lobsang.wheels.calibrate_speeds(-0.6)
Lobsang.head.aim(1380, 1550)
#Lobsang.head.laser(True)
# Tell the Duino that the launcher is connected.
Lobsang.launcher.connect()
Lobsang.launcher.open_guide()
Lobsang.launcher.reset_paddle()

# Print the interface info on the oled.
Lobsang.oled.clear_buffer()
Lobsang.oled.write("Skittles", pos=(0, 0), size=16)
Lobsang.oled.write("Control with W, A, S, D keys.")
Lobsang.oled.write("Control paddle with K, O, P keys.")
Lobsang.oled.write("Press ESC to quit.")
Lobsang.oled.refresh()
Exemple #3
0
#!/usr/bin/env python
#
# boot.py- checks if the RasPiO Duino,
# RasPiCam and OLED are all connected.
# Returns a sys.exit() code  depending
# on what errors occurs.  0 on all ok.
#
# Created Nov 2015 by Finley Watson

import Lobsang
import sys

Lobsang.begin(0)

if not Lobsang.gpio_access:
	sys.exit(16)

import subprocess
import os
from time import sleep
import RPi.GPIO as GPIO

number_of_offline_systems = 0
binary_offline_flag = 0 # 0b001 (1) == duino offline, 0b011 (3) == oled and duino offline, 0b100 (4) == camera offline etc

oled_offline = False
duino_offline = False
camera_offline = False

Lobsang.duino.enable()