Skip to content

Instantly share code, notes, and snippets.

View codeNinjaDev's full-sized avatar
💭
We are the times: Such as we are, such are the times.

Peter Chacko codeNinjaDev

💭
We are the times: Such as we are, such are the times.
View GitHub Profile
@codeNinjaDev
codeNinjaDev / SuperGyro.java
Created January 6, 2019 03:29
Class to keep track of total angle (NavX)
package frc.robot.hardware;
import com.kauailabs.navx.frc.AHRS;
import edu.wpi.first.wpilibj.I2C;
import edu.wpi.first.wpilibj.PIDSourceType;
/*** Encoder Class that keeps track of total angle even when reset unless hard reset*/
public class SuperGyro extends AHRS {
private double offsetAngle;
@codeNinjaDev
codeNinjaDev / ChickenVision.py
Last active January 12, 2019 14:24
Fixed Bugs and changed resolution to 480x270
#!/usr/bin/env python3
#----------------------------------------------------------------------------
# Copyright (c) 2018 FIRST. All Rights Reserved.
# Open Source Software - may be modified and shared by FRC teams. The code
# must be accompanied by the FIRST BSD license file in the root directory of
# the project.
# My 2019 license: use it as much as you want. Crediting is recommended because it lets me know that I am being useful.
# Credit to Screaming Chickens 3997
package frc.robot;
import frc.robot.controllers.DriveController;
import edu.wpi.first.wpilibj.drive.Vector2d;
import java.lang.Math;
public class Odometry {
DriveController driveController;
private double prevX, prevY, prevDistance;
private double currX, currY, currDistance;
#!/usr/bin/env python3
#----------------------------------------------------------------------------
# Copyright (c) 2018 FIRST. All Rights Reserved.
# Open Source Software - may be modified and shared by FRC teams. The code
# must be accompanied by the FIRST BSD license file in the root directory of
# the project.
# My 2019 license: use it as much as you want. Crediting is recommended because it lets me know that I am being useful.
# Credit to Screaming Chickens 3997
#!/usr/bin/env python3
#----------------------------------------------------------------------------
# Copyright (c) 2018 FIRST. All Rights Reserved.
# Open Source Software - may be modified and shared by FRC teams. The code
# must be accompanied by the FIRST BSD license file in the root directory of
# the project.
# My 2019 license: use it as much as you want. Crediting is recommended because it lets me know that I am being useful.
# Credit to Screaming Chickens 3997
package frc.robot.controllers;
import edu.wpi.first.networktables.NetworkTable;
import edu.wpi.first.networktables.NetworkTableEntry;
import edu.wpi.first.networktables.NetworkTableInstance;
import edu.wpi.first.wpilibj.command.Subsystem;
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
import frc.robot.hardware.*;
public class VisionController extends Subsystem {
private boolean is_enabled, driverVision, tapeVision, cargoVision;
package frc.robot.controllers;
import edu.wpi.first.networktables.NetworkTable;
import edu.wpi.first.networktables.NetworkTableEntry;
import edu.wpi.first.networktables.NetworkTableInstance;
import edu.wpi.first.wpilibj.command.Subsystem;
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
import frc.robot.hardware.*;
public class VisionController extends Subsystem {
private boolean is_enabled, driverVision, tapeVision, cargoVision;
#!/usr/bin/env python3
#----------------------------------------------------------------------------
# Copyright (c) 2018 FIRST. All Rights Reserved.
# Open Source Software - may be modified and shared by FRC teams. The code
# must be accompanied by the FIRST BSD license file in the root directory of
# the project.
# My 2019 license: use it as much as you want. Crediting is recommended because it lets me know that I am being useful.
# Credit to Screaming Chickens 3997
package frc.robot;
import edu.wpi.first.wpilibj.Joystick;
import edu.wpi.first.wpilibj.XboxController;
import edu.wpi.first.wpilibj.GenericHID.Hand;
import edu.wpi.first.wpilibj.drive.DifferentialDrive;
/**
* The VM is configured to automatically run this class, and to call the
* functions corresponding to each mode, as described in the IterativeRobot
# Draws Contours and finds center and yaw of ball
# centerX is center x coordinate of image
# centerY is center y coordinate of image
def findBall(contours, image, centerX, centerY):
screenHeight, screenWidth, channels = image.shape;
#Seen vision targets (correct angle, adjacent to each other)
ball = []
if len(contours) > 0:
#Sort contours by area size (biggest to smallest)