#!/usr/bin/env python import time import sys import controller if __name__ == "__main__": speed = 1 if len(sys.argv) == 2: speed = float(sys.argv[1]) try: controller.pwm_change_duty(speed) except KeyboardInterrupt: print "KeyboardInterrupt" controller.go_stop()
import obstacle as obst #minimum distance(cm) min_distance = 30 max_distance = 100 duty = 10 count = 0 back_time = 0.1 turn_time = 0.5 if __name__ == "__main__": if len(sys.argv) == 3: sleep = float(sys.argv[1]) duty = float(sys.argv[2]) print "duty: ", duty controller.pwm_change_duty(duty) time.sleep(0.05) controller.go_up() try: while True: distance = ultrasound.get_distance() back_obstacle1 = obst.has_obstacle(obst.PIN1) back_obstacle2 = obst.has_obstacle(obst.PIN2) back_obstacle3 = obst.has_obstacle(obst.PIN3) back_obstacle4 = obst.has_obstacle(obst.PIN4) left = back_obstacle1 middle_left = back_obstacle2 middle_right = back_obstacle3 right = back_obstacle4
#!/usr/bin/env python import time import sys import os import controller if __name__=="__main__": sleep=1 if len(sys.argv)==2: sleep=float(sys.argv[1]) try: cmd="sh /home/pi/rpi/car/kill.sh" print cmd os.system(cmd) controller.pwm_change_duty(0) controller.stop(sleep) except KeyboardInterrupt: print "KeyboardInterrupt" controller.go_stop()