Skip to content
This repository was archived by the owner on Nov 11, 2025. It is now read-only.

Conversation

@stavit456
Copy link
Contributor

No description provided.

private CANSparkMax master;
private CANSparkMax follower;
private PidController pid;
private final double KP = 0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add the word static to each constant field.


@Override
public void initialize(ActionControl control) {
arm.pidReset();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great

this.master = master;
this.follower = follower;

follower.follow(master);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great

}

public double getAngle(){
return 5; //Will change
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In here, read the absolute encoder in order to find out current angle.
How to read and use the encoder

Moreover, you can always use Ctrl + B in order to see how the DutyCycelEncoder works

}

public void stop(){ master.stopMotor();}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Once you've fixed everything, commit & push, and pull request again

Copy link
Contributor

@NoamZW NoamZW left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't seen you creating in SystemFactory the arm system-so create it(and use RobotMap as well)


public class Arm extends Subsystem {

private double angle;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Specify the variable to angle2Target

Copy link
Contributor

@NoamZW NoamZW left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When you write 500 lines of code and exit without saving it;
⚰️

public Robot(FrcRobotControl robotControl) {

super(robotControl);
arm = SystemFactory.createArm();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great

public static final int ARM_MASTER = 3;
public static final int ARM_FOLLOW = 3;
public static final HidChannel ARM_ENCODER = RoboRio.newHidChannel(0);
public static final double ARM_ANGLE = 0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is that?

CANSparkMax master = new CANSparkMax(RobotMap.ARM_MASTER, CANSparkMaxLowLevel.MotorType.kBrushed);
CANSparkMax follow = new CANSparkMax(RobotMap.ARM_FOLLOW, CANSparkMaxLowLevel.MotorType.kBrushless);
DutyCycleEncoder encoder = new DutyCycleEncoder((DutyCycle) RobotMap.ARM_ENCODER);
double angle2Target = RobotMap.ARM_ANGLE;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The angle2Target is set by the encoder value! :) use the encoder.position

CANSparkMax follow = new CANSparkMax(RobotMap.ARM_FOLLOW, CANSparkMaxLowLevel.MotorType.kBrushless);
DutyCycleEncoder encoder = new DutyCycleEncoder((DutyCycle) RobotMap.ARM_ENCODER);
double angle2Target = RobotMap.ARM_ANGLE;
return new Arm(angle2Target, master, follow, encoder);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without angle2Target

private static final double KI = 0;
private static final double KD = 0;
private static final double KF = 0;
private static final double ERROR = 0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Set error and limit values- it's an angle, so don't use set too much but not so little as well. Choose from 0.5-1

}

public double getAngle2Target(){
encoder.reset();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It shouldn't be here. It should be in the initialize- We don't want everysingle second to reset the encoder


public double getAngle2Target(){
encoder.reset();
return encoder.getPositionOffset();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great

}

public double speed(){
return pid.applyAsDouble(getAngle2Target(), angle2Target);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome

Copy link
Member

@tomtzook tomtzook left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few problems I noticed

@@ -0,0 +1,23 @@
<component name="ProjectRunConfigurationManager">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh those files again.

@Maayan-Luzon
@NoamZW

Remember what I told you about how to fix this?

@tomtzook
Copy link
Member

@NoamZW there are conflicts.

Copy link
Member

@tomtzook tomtzook left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some more things. Sorry for not commenting all at once. Kinda preoccupied with other stuff.

return encoder.getPositionOffset();
}

public double speed(){
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't want to use just a specific set point, as you do with angle2Target value. But rather we are looking for the target angle to be provided depending on use, so it should actually be a parameter.

@NoamZW @Maayan-Luzon you may want to discuss this with @stavit456.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants