forward_speed = 70 turning_speed = 60 max_off_track_count = 1 # off track count max_trick_count = 1 # tolerant tricked count my_pismart = PiSmart() tts = TTS() stt = STT('command', dictionary_update=False) led = LED() lf = line_follower_module.Line_Follower(references=REFERENCES) my_pismart.motor_switch(1) my_pismart.speaker_switch(1) left_motor = Motor('MotorB', forward=0) right_motor = Motor('MotorA', forward=1) left_motor.stop() right_motor.stop() my_pismart.power_type = '2S' my_pismart.speaker_volume = 3 my_pismart.capture_volume = 100 def setup(): tts.say = "Hello, I can track black lines now, Do I need a calibration for the black and white colors?" led.brightness = 60 while True: # 亮灯,开始接收指令。听到指令是yes和no时,分别给calibrate赋值True和False stt.recognize()
# import rospy import rosnode from geometry_msgs.msg import Vector3 from std_msgs.msg import Int32 from sensor_msgs.msg import Imu from pismart.pismart import PiSmart from pismart.motor import Motor from pismart.led import LED import threading from mpu6050 import mpu6050 p = PiSmart() motorA = Motor("MotorA") motorB = Motor("MotorB") p.motor_switch(1) global time def ledCallback(light): leds = LED() leds.brightness = light.data def motorCallback(speed): motorRight = max(min(speed.x,100),-100) motorLeft = max(min(speed.y,100),-100) motorA.speed = int(motorRight) motorB.speed = int(motorLeft)
from pismart.stt import STT from pismart.led import LED import time from Ultrasonic_Avoidance import Ultrasonic_Avoidance my_pismart = PiSmart() tts = TTS() my_pismart.motor_switch(1) my_pismart.speaker_switch(1) UA_PIN = 17 left_motor = Motor('MotorB', forward=1) right_motor = Motor('MotorA', forward=0) stt = STT('command', dictionary_update=True) led = LED() ua = Ultrasonic_Avoidance(UA_PIN) my_pismart.power_type = '2S' my_pismart.speaker_volume = 100 dead_line = 10 safe_line = 18 check_stop_max = 50 turn_point = 25 max_count = 10 * turn_point
def motor_run(motor_chn, speed): #pismart.motor_switch(1) # motor库中有速度正负和限值的处理。 if motor_chn == "A": MotorA = Motor(Motor.MotorA) MotorA.speed = int(speed) elif motor_chn == "B": MotorB = Motor(Motor.MotorB) MotorB.speed = int(speed) elif motor_chn == "both": MotorA = Motor(Motor.MotorA) MotorA.speed = int(speed) MotorB = Motor(Motor.MotorB) MotorB.speed = int(speed) msg = "[PiSmart] Set Motor %s at speed %d" % (motor_chn, speed) print(msg)
''' ********************************************************************** * Filename : motor_test.py * Description : motor port test * Author : Dream * E-mail : [email protected] * Website : www.sunfounder.com * Update : Cavon 2016-08-09: Update debug_settings * Cavon 2016-09-27: Add " " cmd to reverse ********************************************************************** ''' from pismart.pismart import PiSmart from pismart.motor import Motor p = PiSmart() motorA = Motor("MotorA") motorB = Motor("MotorB") p.DEBUG = True motorA.DEBUG = True motorB.DEBUG = True p.motor_switch(1) def setup(): print "|==================================================|" print "| Motor port test |" print "|--------------------------------------------------|" print "| Motors connect to Motor A and Motor B port |" print "| |" print "| Input value(0, 100) to set motors speed |"