Visionsubsytemcode. plz test it for and give me feed back

Hey guy Plz test my code to see if it works. plz give me simple feedback(if possible) of what I can fix or how to make my better. I am new to programming vision subsystem code so all help is appreciated.

package frc.robot.subsystems;

import edu.wpi.first.wpilibj.command.Subsystem;

import edu.wpi.first.networktables.NetworkTable;

import edu.wpi.first.networktables.NetworkTableInstance;

public class VisionSubsystem extends Subsystem {

NetworkTable nTable;

private double yaw;

private double pitch;

private double area;

private boolean is_valid;

public VisionSubsystem(){

nTable=NetworkTableInstance.getDefault().getTable("chameleon-vision").getSubTable("USB Camera-B4.09.24.1");

yaw = nTable.getEntry("yaw").getDouble(0);

pitch = nTable.getEntry("pitch").getDouble(0);

area = nTable.getEntry("area").getDouble(0);

is_valid = nTable.getEntry("is_valid").getBoolean(false);

}

public void initDefaultCommand() {

 setDefaultCommand(new MySpecialCommand());

}

public void periodic() {

System.out.println(yaw);

}

public double getYaw(){

yaw = nTable.getEntry("yaw").getDouble(0);

return yaw;

}

public double getPitch(){

pitch = nTable.getEntry("pitch").getDouble(0);

return pitch;

}

public double getArea(){

area = nTable.getEntry("area").getDouble(0);

return area;

}

public boolean isValid(){

is_valid = nTable.getEntry("is_valid").getBoolean(false);

return is_valid;

}

}

I don’t understand what you want us to do.

Whether your code works or doesn’t work depends on what you want it to do. If you’re having trouble getting it to do what you want it to do, and then ask for specific help.

ok, it is the vision subsystem i don’t much about it and I was assigned to do this class which doesn’t have a main method.

my team isn’t willing to help me.

It seems we need more info, I have a working chameleon Vision example - pm me tomorrow if I don’t update this post. so first off, what do you need to do? Drive to a certain distance, rotate an angle, or be somewhere in an x y plane? Since I don’t have any of that info I’ll look at your code: What’s my special command? This is the command that you always want running on your subsystem. It seems that everything else may be fine but you aren’t using it; you have the recipie for a cake you just aren’t baking it for lack of a better phrase.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.