private void auto_aim() {
if (gamepad1.left_bumper) {
IsAutoAming = true;
limelight.start();
LLResult result = limelight.getLatestResult();
if (result != null && result.isValid()) {
Pose3D botpose = result.getBotpose();
telemetry.addData("tx", result.getTx());
telemetry.addData("ty", result.getTy());
telemetry.addData("ta", result.getTa());
telemetry.addLine(" ");
if (result.getTx() > 1.75D) {
FL.setPower(0.175);
BL.setPower(0.175);
BR.setPower(-0.175);
FR.setPower(-0.175);
} else if (result.getTx() < -1.75D) {
FL.setPower(-0.175);
BL.setPower(-0.175);
BR.setPower(0.175);
FR.setPower(0.175);
} else {
FL.setPower(0.0D);
BR.setPower(0.0D);
BL.setPower(0.0D);
FR.setPower(0.0D);
}
I presume you’re actually asking, “How do I make this proportional?” The answer to this depends completely on the intended behavior.
I presume you want the response to be proportional to the offset? So that there’s a deadband between 1.75 and -1.75 where you do nothing, and then when it’s greater the value changes?
I noticed that 175 is common in all your numbers, so I wonder if you can manage with a direct value (is the range in-line with this?). Meaning I notice the power set is just your tx divided by 10. Such as:
double tx = result.getTx();
if ((tx > 1.75D) || (tx < -1.75D))
{
double txProportionalValue = tx / 10.0D; // power relative to tx
FL.setPower(txProportionalValue);
BL.setPower(txProportionalValue);
BR.setPower(-txProportionalValue);
FR.setPower(-txProportionalValue);
}
else
{
FL.setPower(0.0D);
BL.setPower(0.0D);
BR.setPower(0.0D);
FR.setPower(0.0D);
}
This would make your movement relative (in speed) to the distance of the offset.
-Danny
thanks for your help I’ll try implementing it into the code ![]()
how do I make it so that it overcomes friction(the min power needs to be above 0.12.5)
In this case, the minimum power that will be set is 0.175 but if it needs to be more, just add an offset. So you can change the txProportionalValue calculation to something more like:
double offset = 0.1;
double txProportionalValue = (tx / 10.0D) + offset;
This way you can tweak the offset until you find a minimum power that you’re comfortable with. With an offset of 0.1, the minimum value set to the motors is 0.175 + 0.1 = 0.275.
-Danny