本文整理汇总了Python中PiStorms.PiStorms类的典型用法代码示例。如果您正苦于以下问题:Python PiStorms类的具体用法?Python PiStorms怎么用?Python PiStorms使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PiStorms类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: PiStorms
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
#mindsensors.com invests time and resources providing this open source code,
#please support mindsensors.com by purchasing products from mindsensors.com!
#Learn more product option visit us @ http://www.mindsensors.com/
#
# History:
# Date Author Comments
# 04/18/17 Seth Tenembaum Initial development.
#
from PiStorms import PiStorms
psm = PiStorms()
psm.screen.termPrintln("Please wait a moment")
psm.screen.termPrintln("as matplotlib loads...")
psm.screen.termPrintAt(3, "Press GO to quit.")
import matplotlib
matplotlib.use("AGG")
import matplotlib.pyplot as plt
import numpy as np
import tempfile
from mindsensors import ABSIMU
import threading, time
plt.figure(figsize=(4,3), dpi=80)
plt.xlabel('time')
plt.ylabel('acceleration')
示例2: PiStorms
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
#mindsensors.com invests time and resources providing this open source code,
#please support mindsensors.com by purchasing products from mindsensors.com!
#Learn more product option visit us @ http://www.mindsensors.com/
#
# History:
# Date Author Comments
# 04/18/16 Deepak Initial development.
#
from PiStorms import PiStorms
print "running program"
psm = PiStorms()
m = ["EV3ColorSensor-Demo", "Connect EV3 Color sensor to BAS1",
"and Press OK to continue.",
"Then move colored objects in front",
"of Color sensor"]
psm.screen.askQuestion(m,["OK"])
doExit = False
old_colorValue = True
colorValue = True
ambientMode = False
#main loop
while(not doExit):
#save the previous value
示例3: PiStorms
#!python
"""
DiffDrive robot example
"""
from PiStorms import PiStorms
import bot
import requests
import time
psm = PiStorms()
desc = bot.DiffDescription(
psm.BAM1,
psm.BBM1,
axel_radius=20.47875/100/2,
wheel_radius=3.6/100/2,
reverse_forward=True
)
driver = bot.DiffDriver(desc)
#locator = bot.DiffLocator(desc)
locator = bot.RemoteLocator()
path_follower = bot.PathFollower(driver, locator)
def path_changed_handler(path, voxels):
path_follower.path = path
path_finder = bot.RemotePathFinder(path_changed_handler)
示例4: PiStorms
from PiStorms import PiStorms
from time import sleep
import sys
psm = PiStorms() # PiStorms object
exit = False # break loop
while (not exit):
if (psm.isPressed() == True): #exit
psm.BBM1.brakeSync()
psm.led(1,0,0,0)
psm.screen.clearScreen()
psm.screen.termPrintln("")
psm.screen.termPrintln("Exiting to menu")
sleep(0.5)
exit = True
示例5: PiStorms
#mindsensors.com invests time and resources providing this open source code,
#please support mindsensors.com by purchasing products from mindsensors.com!
#Learn more product option visit us @ http://www.mindsensors.com/
#
# History:
# Date Author Comments
# July 2015 Henry Initial Authoring from SensorShield import SensorShield
import os,sys,inspect,time
currentdir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
parentdir = os.path.dirname(currentdir)
sys.path.insert(0,parentdir)
from PiStorms import PiStorms
psm = PiStorms()
psm.screen.termPrintln("PiStorms ")
psm.screen.termPrintln("GO button test:")
psm.screen.termPrintln(" ")
exit = False
print "Running Button Test"
print "press anywhere in PiStorms Screen to exit"
psm.screen.termPrintln("Touch Display to Exit")
psm.screen.termPrintln(" ")
while(not exit):
pass
psm.screen.termReplaceLastLine("Go Button is = " +str(psm.isKeyPressed()))
if (psm.screen.checkButton(0,0,320,320)):
示例6: PiStorms
#mindsensors.com invests time and resources providing this open source code,
#please support mindsensors.com by purchasing products from mindsensors.com!
#Learn more product option visit us @ http://www.mindsensors.com/
#
# History:
# Date Author Comments
# July 2015 Henry Initial Authoring from SensorShield import SensorShield
import os,sys,inspect,time
currentdir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
parentdir = os.path.dirname(currentdir)
sys.path.insert(0,parentdir)
from PiStorms import PiStorms
psm = PiStorms()
psm.screen.termPrintAt(2, "PiStorms ")
psm.screen.termPrintAt(3, "GO button test:")
exit = False
print "Running Button Test"
print "press anywhere in PiStorms Screen to exit"
psm.screen.termPrintAt(8, "Touch Display to Exit")
psm.screen.termPrintln(" ")
while(not exit):
pass
psm.screen.termPrintAt(5, "GO Button is = " +str(psm.isKeyPressed()))
psm.screen.termPrintAt(6, "Press Count = " +str(psm.getKeyPressCount()))
if (psm.screen.checkButton(0,0,320,320)):
示例7: PiStorms
#
# History:
# Date Author Comments
# July 7, 2016 Yug Rao Initial Authoring
from picamera.array import PiRGBArray
from picamera import PiCamera
import os,sys,inspect,time#thread
from subprocess import call
import cv2
import imutils
currentdir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
parentdir = os.path.dirname(currentdir)
sys.path.insert(0,parentdir)
from PiStorms import PiStorms
psm = PiStorms()
try:
picam = PiCamera()
except:
m = ["PopHeads", "Camera not enabled.", "Run raspi-config and enable camera"]
psm.screen.askQuestion(m,["OK"])
exit()
exitNow = 0
time.sleep(.2)
# Create the haar cascade
haar_path=currentdir+"/haarcascade_frontalface_default.xml"
faceCascade = cv2.CascadeClassifier(haar_path)
#psm.screen.fillRect(95, 145, 110, 160)
#psm.screen.fillRect(100, 150, 100, 150, fill=(0,0,0))
while not exitNow:
示例8: PiStorms
#mindsensors.com invests time and resources providing this open source code,
#please support mindsensors.com by purchasing products from mindsensors.com!
#Learn more product option visit us @ http://www.mindsensors.com/
#
# History:
# Date Author Comments
# 04/18/17 Seth Tenembaum Initial development.
#
# This program demonstrates how to create a live-updating graph, but only displaying
# the latest n values on screen. It also explicitly sets the y-axis range.
# Don't hold the button too long, or you'll turn off the PiStorms!
# Tap the touchscreen to exit.
from PiStorms import PiStorms
psm = PiStorms()
psm.screen.termPrintln("Please wait a moment")
psm.screen.termPrintln("as matplotlib loads...")
psm.screen.termPrintAt(3, "Tap and hold the screen to quit.")
import matplotlib
matplotlib.use("AGG")
import matplotlib.pyplot as plt
import numpy as np
import tempfile
plt.figure(figsize=(4,3), dpi=80)
plt.xlabel('time')
plt.ylabel('GO button state')
plt.title('GO Button')
plt.grid(True)
示例9: PiStorms
from PiStorms import PiStorms
from time import sleep
print "running program"
psm = PiStorms()
DISTANCE_THRESHOLD = 700
WHITE_THRESHOLD = 400
BLACK_THRESHOLD = 900
WHITE = [12,13,14]
ALTERNATOR = -0.1 # Used if I fucked up the motor orientation and -1 is actually how we move forward
INV_ALTERNATOR = 0 - ALTERNATOR
def distance():
return psm.BBS1.distanceUSEV3()
def seeing_other_robot():
return distance() < DISTANCE_THRESHOLD
def near_edge():
return psm.BAS2.lightSensorNXT(True) > WHITE_THRESHOLD and psm.BAS2.lightSensorNXT(True) < BLACK_THRESHOLD or psm.BAS1.colorSensorNXT() in WHITE
def gtfo():
def turn_180():
psm.BBM1.setSpeed(ALTERNATOR * 100)
psm.BBM2.setSpeed(INV_ALTERNATOR * 100)
sleep(0.6)
psm.BBM1.brake()
psm.BBM2.brake()
sleep(0.01)
示例10: PiStorms
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
#mindsensors.com invests time and resources providing this open source code,
#please support mindsensors.com by purchasing products from mindsensors.com!
#Learn more product option visit us @ http://www.mindsensors.com/
import os,sys,inspect,time,thread,random
currentdir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
parentdir = os.path.dirname(currentdir)
from PiStorms import PiStorms
psm = PiStorms()
color = (255, 255, 255)
while True:
if psm.isKeyPressed():
break
if psm.isF1Pressed():
color = (255, 0, 0)
if psm.isF2Pressed():
color = (255, 255, 0)
if psm.isF3Pressed():
color = (0, 255, 0)
if psm.isF4Pressed():
color = (0, 0, 255)
示例11: PiStorms
#
#mindsensors.com invests time and resources providing this open source code,
#please support mindsensors.com by purchasing products from mindsensors.com!
#Learn more product option visit us @ http://www.mindsensors.com/
#
# History:
# Date Author Comments
# 04/18/17 Seth Tenembaum Initial development.
#
# This program demonstrates using a sensor and displaying multiple lines
# (overlapping data series). Here we plot the three axes of tilt from the
# AbsoluteIMU sensor.
from PiStorms import PiStorms
psm = PiStorms()
psm.screen.termPrintln("Please wait a moment")
psm.screen.termPrintln("as matplotlib loads...")
psm.screen.termPrintAt(3, "Press GO to quit.")
import matplotlib
matplotlib.use("AGG")
import matplotlib.pyplot as plt
import numpy as np
import tempfile
from mindsensors import ABSIMU
import time
plt.figure(figsize=(4,3), dpi=80)
plt.xlabel('time')
plt.ylabel('tilt')
示例12: PiStorms
import socket,fcntl,struct
currentdir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
parentdir = os.path.dirname(currentdir)
sys.path.insert(0,parentdir)
from PiStorms import PiStorms
from PiStormsInput import PiStormsInput
from wireless import Wireless
from wifi import Cell
import re, subprocess
# Globals
config_file = "/etc/wpa_supplicant/wpa_supplicant.conf" # Config file for Wi-Fi
wifi = None
wlan_inteface = "wlan0"
psm = PiStorms()
# Check if a wifi adapter is available
try:
wifi = Wireless()
wlan_interface = wifi.interfaces()[0]
except Exception as e:
psm.screen.fillRect(0, 0, 320, 240, fill = (0,0,0), display = False)
psm.screen.drawAutoText("No Wi-Fi adapter", 35, 20, fill = (255,0,0), size = 25, display = False)
psm.screen.drawAutoText("available!", 35, 50, fill = (255,0,0), size = 25, display = False)
psm.screen.drawButton(35, 160, width = 250, height = 40, text="Continue", display=False)
psm.screen.fillRect(0, 0, 1, 1, fill = (0,0,0), display = True)
while True:
cont = psm.screen.checkButton(35, 160, 250, 40)
if cont: sys.exit(0)
示例13: PiStorms
#mindsensors.com invests time and resources providing this open source code,
#please support mindsensors.com by purchasing products from mindsensors.com!
#Learn more product option visit us @ http://www.mindsensors.com/
# Tic Tac Toe
import random
import os,sys,inspect,time,thread
import socket,fcntl,struct
currentdir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
parentdir = os.path.dirname(currentdir)
sys.path.insert(0,parentdir)
from PiStorms import PiStorms
psm = PiStorms()
psm.led(1,0,0,0)
psm.led(2,0,0,0)
def drawLines():
#210x210, 55px side border, 15px vertical border, 70px squares
psm.screen.fillRect(124,15, 2,210)
psm.screen.fillRect(196,15, 2,210)
psm.screen.fillRect(55,84, 210,2)
psm.screen.fillRect(55,154, 210,2)
def drawBoard(board):
# This function prints out the board that it was passed.
# "board" is a list of 10 strings representing the board (ignore index 0)
示例14: PiStorms
from PiStorms import PiStorms
from time import sleep
from HiTechnicColorV2 import HiTechnicColorV2
from datetime import datetime
print "running program"
psm = PiStorms()
hc = HiTechnicColorV2()
psm.BBS1.activateCustomSensorI2C()
blue = 2
red = 9
red2 = 8
counter = 0
last_time = datetime.now()
exit = False
botDiam = 17.5
wheelDiam = 6.5
target=90
translate=target*botDiam/(wheelDiam)
psm.BAM1.resetPos()
initialEncoderValue = psm.BAM1.pos()
while(psm.BAM1.pos()< translate+initialEncoderValue):
psm.BAM1.setSpeed(50)
psm.BAM2.setSpeed(-50)
psm.led(1, 255, 255, 255)
sleep(1)
示例15: PiStorms
#
#mindsensors.com invests time and resources providing this open source code,
#please support mindsensors.com by purchasing products from mindsensors.com!
#Learn more product option visit us @ http://www.mindsensors.com/
#
# History:
# Date Author Comments
# July 2015 Henry Initial Authoring from SensorShield import SensorShield
import os,sys,inspect,time,thread
currentdir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
parentdir = os.path.dirname(currentdir)
sys.path.insert(0,parentdir)
from PiStorms import PiStorms
psm = PiStorms()
psm.screen.termPrintln("Battery Voltage")
psm.screen.termPrintln(" ")
psm.BBS1.resetTouchesEV3()
exit = False
lastled = 0
while(not exit):
voltVal = psm.battVoltage()
psm.screen.termReplaceLastLine(str(voltVal) + "V")
if(voltVal >= 8and lastled != 1):
psm.led(1,0,255,0)
psm.led(2,0,255,0)
lastled = 1