Skip to content

Instantly share code, notes, and snippets.

Avatar

Jeff Hutchison jhh

View GitHub Profile
@jhh
jhh / azimuthEncoder.java
Last active Jan 16, 2019
Azimuth Encoder Calcs
View azimuthEncoder.java
public class Main {
public static void main(String[] args) {
minRotationIEEERemainder(4095, 1); // expect +2
minRotationIEEERemainder(10 * 0x1000 + 4095, 1); // same, plus 10 revolutions
minRotationIEEERemainder(-1024, 1024); // expect +/- 2048
minRotationIEEERemainder(10 * 0x1000 - 1024, 1024); // same, plus 10 revolutions
minRotationIEEERemainder(2730, 1365); // 240 -> 120 expect -120 (-1365)
minRotationIEEERemainder(10 * 0x1000 + 2730, 1365); // 240 -> 120 expect -120 (-1365)
@jhh
jhh / azimuth.java
Last active Jan 16, 2019
Third Coast Azimuth TalonSRX Settings
View azimuth.java
// azimuth talon configuration
// NOTE: do not rely on these PID parameters, you should tune for your physical plant
TalonSRXConfiguration azimuthConfig = new TalonSRXConfiguration();
azimuthConfig.primaryPID.selectedFeedbackSensor = FeedbackDevice.CTRE_MagEncoder_Relative;
azimuthConfig.continuousCurrentLimit = 10;
azimuthConfig.peakCurrentDuration = 0;
azimuthConfig.peakCurrentLimit = 0;
azimuthConfig.slot0.kP = 10.0;
azimuthConfig.slot0.kI = 0.0;
@jhh
jhh / wheel.java
Last active Jan 16, 2019
Minimum Swerve Wheel Rotation
View wheel.java
public class Main {
public static void main(String[] args) {
minRotation(359, 0);
minRotation(359, 1);
minRotation(90, -90);
minRotation(180, -180);
minRotationWithReverse(359, 1);
minRotationWithReverse(90, -90);
minRotationWithReverse(180, -180);
View Wheel Test 2018-09-25.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View results.md
Run Expected (cm) Actual (cm) Comments
1 700 644.0 pA = 0.0, pD = 0.0
2 700 641.0 pA = -0.004, pD = 0.0
3 700 649.0 pA = -0.004, pD = 0.0
4 700 692.0 pA = -0.004, pD = 4e-6
5 700 693.5 pA = -0.004, pD = 4e-6
6 700 693.0 pA = -0.004, pD = 4e-6
View Motor Assignments
Climber
Left CAN=20 PDP=12
Right CAN=21 PDP=13
Intake
Left CAN=30 PDP=10
Right CAN=31 PDP=9
Shoulder
CAN=40 PDP=11
View params.java
// factory reset a talon and run these statements in a robot program
double value = talon.configGetParameter(ParamEnum.eBatteryVoltageFilterSize, 0, 10)
System.out.println("voltage filter size = " + value);
value = talon.configGetParameter(ParamEnum.eProfileParamSlot_MaxIAccum, 0, 10)
System.out.println("max I-accum = " + value);
View motion.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View motion.cc
#include "motion.h"
#include <cmath>
#include <iostream>
using namespace std;
/**
* @param distance in encoder ticks
* @param max_v in ticks/100ms
@jhh
jhh / TalonTestRobot.java
Last active Feb 19, 2018
Example program and output for TalonSRX current limit issue
View TalonTestRobot.java
package org.team2767.thirdcoast;
import com.ctre.phoenix.ErrorCode;
import com.ctre.phoenix.motorcontrol.ControlMode;
import com.ctre.phoenix.motorcontrol.can.TalonSRX;
import edu.wpi.first.wpilibj.IterativeRobot;
import edu.wpi.first.wpilibj.Timer;
public class TalonTestRobot extends IterativeRobot {