Skip to content

Commit

Permalink
Working cone detection with CANbus. It's awesome.
Browse files Browse the repository at this point in the history
  • Loading branch information
harjaus committed Jun 19, 2019
1 parent 468e0f0 commit 4389bbf
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions zedMain.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
global startFrom
startFrom = 270
global steeringFactor
steeringFactor = 30
steeringFactor = 10
global carVelocity
carVelocity = 60
carVelocity = 70



Expand All @@ -38,14 +38,16 @@ def issueCommands(steering, velocity, exit, lastCommandTime=0.025):

if exit: #can exit protocol
print("Initiating CAN exit.")
issueCommands.car.set_steering_velocity(0,0)
time.sleep(0.5)
issueCommands.car.exitCAN() #runs until we exit gracefully

def calculateCenter(target):

newCom = target - int(width/2) #offset from center of image

if newCom != -int(width/2): #when we have a correct reading
final = calculateCenter.pastCom + (newCom-calculateCenter.pastCom) / 2
final = calculateCenter.pastCom + (newCom-calculateCenter.pastCom) / 20
calculateCenter.pastCom = final

return round(final)
Expand Down

0 comments on commit 4389bbf

Please sign in to comment.