From 6c3cb797ad76ae61f4bd7e33b080d4a44408d449 Mon Sep 17 00:00:00 2001 From: Will Hescott Date: Sat, 25 Feb 2017 10:24:04 -0500 Subject: [PATCH] resolving merge conflicts --- tthhiinnggyy.py => camera.py | 19 +++++-------------- components/drive.py | 25 ++++++++++++++----------- 2 files changed, 19 insertions(+), 25 deletions(-) rename tthhiinnggyy.py => camera.py (78%) diff --git a/tthhiinnggyy.py b/camera.py similarity index 78% rename from tthhiinnggyy.py rename to camera.py index 71035ef..02d3eca 100644 --- a/tthhiinnggyy.py +++ b/camera.py @@ -1,4 +1,4 @@ -#Will your code should be at the bottom. Fill in the stuff in HooBoyShoot. Also I think the calls to AutonTankDrive are wrong. +Camera#Will your code should be at the bottom. Fill in the stuff in HooBoyShoot. Also I think the calls to AutonTankDrive are wrong. import math import serial @@ -19,12 +19,12 @@ MUZZLE_VELOCITY = 30 #meters/second COMPLETELY_ARBITRARY_CONSTANT = 1 -class Tthhinnggyy: +class Camera: old_x = 0 mid_x = None mid_y = None theta = None - distance = None + distance = None #returnss in meters ser = None driveDelay = 0 @@ -77,15 +77,6 @@ def uncode(self, string): number += char return stuff - - def centerLine(self): - if(abs(self.distance - REF_DIST) > DDZ_MOV): #meters, arbitrary deadzone value - spd = math.copysign(0.1, self.distance - REF_DIST)#max(MIN_MOV_SPD, abs(distance))*math.copysign(1.0, distance) - self.autonTankDrive(spd,spd) - return False - return True - - #max(MIN_ROT_SPD, min(MAX_ROT_SPD, abs(self.theta - REF_THETA))) ''' def ShootDistance(self): #I *guarantee* this does *not* work angle = math.arcsin(((REF_TOW_H - REF_CAM_H)/self.distance+4.9*self.distance)/MUZZLE_VELOCITY) @@ -96,7 +87,7 @@ def centerLine(self): #it can be changed, but it's not important anyway ''' ''' -thng.receive() -if thng.centerSide() and thng.centerLine() : #this works because of short-circuiting +cam.receive() +if cam.centerSide() and cam.centerLine() : #this works because of short-circuiting HooBoyShoot() ''' diff --git a/components/drive.py b/components/drive.py index de47fb0..2b6359b 100644 --- a/components/drive.py +++ b/components/drive.py @@ -11,8 +11,8 @@ from ctre.cantalon import CANTalon from wpilib.interfaces import Gyro from . import Component -import tthhiinnggyy -from tthhiinnggyy import Tthhinnggyy +import camera +from camera import Camera import math @@ -53,7 +53,7 @@ def __init__(self, robot): self.rbmotor.setPosition(0) self.lbmotor.setPosition(0) self.myInertia = 0 - self.thng = Tthhinnggyy() + self.cam = Camera() def drive_forward(self, speed) : self.drive.tankDrive(speed, speed, True) @@ -99,20 +99,20 @@ def turnAngle(self, degrees, speed=0.2): return False def visionLineUp(self): - self.thng.receive() - if self.thng.centerSide():#and self.thng.centerLine() : #this works because of short-circuiting + self.cam.receive() + if self.cam.centerSide():#and self.cam.centerLine() : #this works because of short-circuiting print("hooboyshoot") self.reset() #oh what fun it is to ride def findGoal(self): x = 25 - self.thng.receive() + self.cam.receive() if x < 25: x += 1 self.autonTankDrive(0,0) return False - if self.centerSide():#and self.thng.centerLine() : #this works because of short-circuiting #in a one-horse open sleigh + if self.centerSide():#and self.cam.centerLine() : #this works because of short-circuiting #in a one-horse open sleigh self.reset() x = 0 return True @@ -156,14 +156,14 @@ def convertEncoderRaw(self, selectedEncoderValue): return selectedEncoderValue * self.INCHES_PER_REV def centerSide(self): - if(self.thng.mid_x == None): + if(self.cam.mid_x == None): self.autonTankDrive(0, 0) if(self.myInertia > 0): self.myInertia -= 1 return False - elif(abs(self.thng.mid_x) > tthhiinnggyy.DDZ_ROT): #radians, arbitrary deadzone value - if(abs(self.thng.mid_x) > 0.15): + elif(abs(self.cam.mid_x) > camera.DDZ_ROT): #radians, arbitrary deadzone value + if(abs(self.cam.mid_x) > 0.15): spdMag = 0.15 else: spdMag = 0.09 @@ -173,10 +173,13 @@ def centerSide(self): self.myInertia = 0 if(self.myInertia <= 5): self.myInertia += 1 - spd = math.copysign(spdMag, self.thng.mid_x)#min(max(MIN_ROT_SPD, abs(self.mid_x)), MAX_ROT_SPD), self.mid_x) #again arbitrary numbers + spd = math.copysign(spdMag, self.cam.mid_x)#min(max(MIN_ROT_SPD, abs(self.mid_x)), MAX_ROT_SPD), self.mid_x) #again arbitrary numbers self.autonTankDrive(spd, -spd) return False self.autonTankDrive(0, 0) if(self.myInertia > 0): self.myInertia -= 1 return True + + def convert(self, x):#converting meters to inches + return x*39.37