Hello everyone, my name is Joey Ferreri. It is unfortunate that PiWars will not be held in person this year, but we are still excited to participate this year in PiWars at home. Our team is comprised of both veteran PiWars goers and newbies. This year we will continue iterating on CNM Hackerspace’s HAL robot that we have incrementally upgraded for the past several years. To get everyone warmed up and prepare to work on the real deal, we’ve been using Dexter Industries’ GoPiGo3 robots for programming and practicing with various sensors as well. Specifically, we have been orientating ourselves with the distance sensor, light and color sensor, and the camera, all of which will aid us in autonomous completion of the challenges. We are hoping to all acquire the skills to develop our robot to its best iteration yet. Here’s to a great PiWars at home! Here is the main code for the distance sensor on my Dexter robot: from easygopigo3 import EasyGoPiGo3 import easygopigo3 as easy import time gpg = easy.EasyGoPiGo3() distance = gpg.init_distance_sensor() # create an EasyGoPiGo3 object gpg3_obj = EasyGoPiGo3() # and now let's instantiate a Servo object through the gpg3_obj object # this will bind a servo to port "SERVO1" servo = gpg3_obj.init_servo() def goOrNo(gpg, distance): leftAngle = 150 rightAngle = 30 centerAngle = 90 leftDist = -1 rightDist = -1 print("scanning") servo.rotate_servo(leftAngle) time.sleep(.5) leftDist = distance.read_mm() servo.rotate_servo(rightAngle) time.sleep(.8) rightDist = distance.read_mm() servo.rotate_servo(centerAngle) if leftDist > rightDist: gpg.turn_degrees(-70) else: gpg.turn_degrees(70) print("route found") tooClose = 100 run = True center = 90 servo.rotate_servo(center) while run == True: d = distance.read_mm() print(d) gpg.forward() time.sleep(.2) if d < tooClose: print("too close") gpg.drive_cm(-50) goOrNo(gpg, distance) This program allows autonomous function of the robot. It drives until the value from the distance sensor goes below a certain value, then backs up a predetermined amount and checks its surroundings. it looks left, then right and stores the value of each side and turns to whichever side has a greater distance value. Comments are closed.
|
AuthorCNM HackerSpace Robotics Archives
December 2020
Categories |