1 of 16

Storm Compass - Software

Simar Kareer, Gregory Hazen

This presentation: http://tinyurl.com/n4f3om4

2 of 16

Why vision?

  • When it isn’t practical to do it any other way
    • Shooting
    • NOT GEAR(We’re stupid yes ik)
  • IT SEES

3 of 16

Our Overview

  • We do the vision processing on our raspberry pi
    • We use GRIP to get contours from the vision target
    • We write in python and send the data to the robot over networktables
    • This determines the angle to the target, approximate distance and other things
  • The Robot then moves accordingly
  • https://github.com/WPIRoboticsProjects/GRIP/wiki/Running-GRIP-on-a-Raspberry-Pi-2
  • https://github.com/2729StormRobotics/StormCV2017
  • These are for set up

4 of 16

Prereqs

  • Python3 on pi
  • Mjpg streamer on pi
  • OpenCV on pi

5 of 16

How to GRIP(firmly grasp it)

Ima show you

HSL>>Erode>>Dilate>>Find Contour>>Filter

tools>>export

6 of 16

Python

7 of 16

Recognizing targets

<show them runcv.py>

8 of 16

Finding angles (easy way)

  • Find your field of view(how many degrees)
  • 2*arctan(SomeObject/(2*distance))

9 of 16

Angles cont...

Once you know how many angles just do a linear calculation to translate pixels to degrees

Let’s say FOV = 50 degrees and your x resolution is 320.

Then each pixel is 50/320 degrees

10 of 16

Turn to a specific target - ez way

if(target > centerPixel){

*turnRight*

}else{

*turnLeft*

}

11 of 16

The hard, but *kewl* way

PID!!! But your own values. (I stole this from the cheesy poofs pres(it’s not plagiarism if you credit them))

error = centerPixel - target pixel;

Output = kp*error + ki*Sumerror + kd*Derivativeerror;

12 of 16

Quick PID (just forget about the F now)

Proportional

Increases *proportionally* based on the error(fixes stuff faster when it’s more wrong)

Any problems with this???

13 of 16

Derivative Control

Welp how do we dun do a fix??

Consider rate of change of error(Calc Trigger Warning)

Problems??

14 of 16

Integral Control

Fixes Steady State Error

Often caused by friction etc

15 of 16

Tuning it(it’s like an instrument)

16 of 16

LEDz(pretty colors)

Leds run off an arduino that gets serial data(preset bytes) from the RIO

Depending on which alliance we’re on and whether were lined up with the vision target or not different colors and different sections of the robot will light up

<<LED code>>

https://github.com/2729StormRobotics/Storm2017Arduino/blob/master/Arduino_LED_Cases.ino/Arduino_LED_Cases.ino.ino

https://github.com/2729StormRobotics/StormRobotics2017/blob/master/src/org/usfirst/frc/team2729/robot/subsystems/LEDz.java