Skip to content

Instantly share code, notes, and snippets.

View archishou's full-sized avatar

Archishmaan Peyyety archishou

  • 18:09 (UTC -05:00)
View GitHub Profile
import com.qualcomm.hardware.bosch.BNO055IMU;
import com.qualcomm.robotcore.hardware.HardwareMap;
import org.firstinspires.ftc.robotcore.external.navigation.Quaternion;
/**
* Created by Archish on 10/28/16.
*/
@SuppressWarnings({"WeakerAccess", "unused"})
@I2cSensor(name = "MasqColorSensor", description = "I2C Sensor that supports color number", xmlTag = "MasqColorSensor")
public class MasqColorSensorDriver extends I2cDeviceSynchDevice<I2cDeviceSynch> {
private static final int
READ_WINDOW_START = 0x04,
READ_WINDOW_LENGTH = 5;
public void write(int reg, int value) {deviceClient.write(reg, TypeConversion.shortToByteArray((short) value));}
public short read(int reg) {return TypeConversion.byteArrayToShort(deviceClient.read(reg, 2));}
public class MasqColorSensorV2 implements MasqHardware {
private static final int
COLOR_NUMBER_REGISTER = 0x04,
RED_VALUE_REGISTER = 0x05,
GREEN_VALUE_REGISTER = 0x06,
BLUE_VALUE_REGISTER = 0x07,
WHITE_VALUE_REGISTER = 0x08;
private static final int
COMMAND_REGISTER = 0x03,
public void turnRelative(double angle, Direction direction, double timeOut, int sleepTime, double kp, double ki, double kd) {
double targetAngle = tracker.imu.adjustAngle(tracker.getHeading()) + (direction.value * angle);
double acceptableError = .5;
double turnPower = .4;
double currentError = tracker.imu.adjustAngle(targetAngle - tracker.getHeading());
double prevError = 0;
double integral = 0;
double derivative;
double newPower;
double previousTime = 0;
public void driveProportional(double angle, Direction direction, double ratio, double kp, double timeout) {
MasqClock clock = new MasqClock();
MasqPIDController controller = new MasqPIDController(kp, 0, 0);
double out = controller.getOutput(tracker.imu.getRelativeYaw(), angle);
double rightRatio = 1, leftRatio = 1;
if (direction == Direction.RIGHT) rightRatio = ratio;
else leftRatio = ratio;
while (opModeIsActive() && out > 0.1 && !clock.elapsedTime(3, MasqClock.Resolution.SECONDS)) {
out = controller.getOutput(tracker.imu.getRelativeYaw(), angle);
driveTrain.setVelocity(out * leftRatio, out * rightRatio);
import cv2 as cv
import math
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
from detectors.color_detector import ColorDetector
from processes.blurs import Blurs
import numpy as np
# load video
cap = cv.VideoCapture('testvideo.mp4')
# cap = cv.VideoCapture(0)
const AWS = require('aws-sdk');
const ddb = new AWS.DynamoDB.DocumentClient();
require('./patch.js');
let send = undefined;
function init(event) {
console.log(event);
const apigwManagementApi = new AWS.ApiGatewayManagementApi({
apiVersion: '2018-11-29',
endpoint: event.requestContext.domainName + '/' + event.requestContext.stage
package main
import (
"flag"
"fmt"
. "github.com/dave/jennifer/jen"
"unicode"
)
func main() {
public class MasqPositionTracker implements MasqHardware {
private MasqMotor xSystem, yLSystem, yRSystem, ySystem;
public MasqAdafruitIMU imu;
private double prevHeading, heading;
private double globalX, globalY, prevX, prevY, prevYR, prevYL, xRadius, yRadius, trackWidth;
private DeadWheelPosition position;
public enum DeadWheelPosition {
BOTH_CENTER, BOTH_PERPENDICULAR, THREE
package Library4997.MasqMotors;
import android.database.DatabaseErrorHandler;
import com.qualcomm.robotcore.hardware.DcMotor;
import com.qualcomm.robotcore.hardware.DcMotorController;
import com.qualcomm.robotcore.hardware.HardwareMap;
import com.qualcomm.robotcore.util.Range;
import Library4997.MasqResources.MasqHelpers.MasqHardware;