Brighton-FTC / 2024

Our FIRST® Tech Challenge Code for the 2023-2024 season.
BSD 3-Clause Clear License
2 stars 0 forks source link

Make grabber code #6

Closed 12sliu closed 7 months ago

12sliu commented 1 year ago

This is just making a simple grabber like last time. Shouldn't be that hard, use last year's grabber as a example and we should be fine.

sbottingota commented 1 year ago

https://github.com/Brighton-FTC/2024/commit/943b61b352d12679ea17121939ff985aac3f246a Made a very basic implementation of the grabber code. Code is a bit sloppy, but I'll work on it tomorrow.

sbottingota commented 1 year ago

Here it says that ServoEx should be initialized like this:

ServoEx servo = new SimpleServo(
    hardwareMap, "servo_name", MIN_ANGLE, MAX_ANGLE
);

I think I should probably do that instead of what I did in my code; now that I think about it, it doesn't make much sense that a Servo object should just magically get all the methods of ServoEx, but I don't know much about type conversions in java, so i don't really know how what I did in my code would work:

ServoEx servo = (ServoEx) hardwareMap.servo.get("servo_name");
12sliu commented 1 year ago

Best to follow FTCLib example, I suppose.

By the way, you do have tests this week, maybe consider taking a break from robotics to study? Engineers haven't done anything we can test on, so we won't be able to test anything we write; there's time pressure, but it's not THAT urgent. I'm swamped with tests (8 in the next 7 days), so I also won't be able to work too much on the code; I won't think less of you if you don't complete your issue as fast as possible within these few days.

sbottingota commented 1 year ago

https://github.com/Brighton-FTC/2024/commit/79e4caa8020a858b1e11e0bf40dfef572942a322
Ok I implemented the SimpleServo thing.

sbottingota commented 1 year ago

@12sliu, do we know what the servo names are?

sbottingota commented 1 year ago

Also, how do we find angle the servos need to be at to open/close/tilt the grabber? I was thinking of making a separate opmode to get those values, but do you know of a better way?

The scrappy opmode I was making to get the correct servo positions ```java package org.firstinspires.ftc.teamcode.components.test; import com.arcrobotics.ftclib.gamepad.GamepadEx; import com.arcrobotics.ftclib.gamepad.GamepadKeys; import com.arcrobotics.ftclib.hardware.ServoEx; import com.arcrobotics.ftclib.hardware.SimpleServo; import com.qualcomm.robotcore.eventloop.opmode.OpMode; import com.qualcomm.robotcore.eventloop.opmode.TeleOp; /** * Some code I made to get the servo positions for the grabber.
* * Controls: *
    *
  • Change servo - dpad left & dpad right
  • *
  • Change rotation angle - dpad down & dpad up
  • *
  • Rotate servo by rotation angle - A (cross on playstation) and B (circle on playstation)
  • *
* */ @TeleOp(name = "Grabber Servo Position Tester", group = "components_test") public class ServoPositionTester extends OpMode { private ServoEx[] servos; private int currentServoIndex = 0; private GamepadEx gamepad = new GamepadEx(gamepad1); private int rotationAngle = 20; @Override public void init() { servos = new ServoEx[]{ new SimpleServo(hardwareMap, "servo_name", 0, 360), new SimpleServo(hardwareMap, "servo_name", 0, 360) }; } @Override public void loop() { if (gamepad.wasJustPressed(GamepadKeys.Button.DPAD_LEFT)) { currentServoIndex--; currentServoIndex %= servos.length; } if (gamepad.wasJustPressed(GamepadKeys.Button.DPAD_RIGHT)) { currentServoIndex++; currentServoIndex %= servos.length; } if (gamepad.wasJustPressed(GamepadKeys.Button.DPAD_DOWN)) { rotationAngle -= 5; } if (gamepad.wasJustPressed(GamepadKeys.Button.DPAD_UP)) { rotationAngle += 5; } if (gamepad.wasJustPressed(GamepadKeys.Button.A)) { servos[currentServoIndex].rotateByAngle(rotationAngle); } if (gamepad.wasJustPressed(GamepadKeys.Button.B)) { servos[currentServoIndex].rotateByAngle(-rotationAngle); } telemetry.addData("Current servo index", currentServoIndex); telemetry.addData("Rotation angle", rotationAngle); telemetry.addData("Current servo angle", servos[currentServoIndex].getAngle()); } } ```
12sliu commented 1 year ago

Pretty sure we get to name them in the software ourselves while setting things up, though I'm not entirely sure; we'll ask Oliver today

I'll have to talk to Nick if our grabber uses 1 or 2 servos

Also, I noticed you use gamepad.WasJustPressed, I remember there was a way to bind a command to a trigger in init; they should be the same functionally, but is there any difference between the two I haven't noticed?

Otherwise, thing looks good; we can modify it for the other components. Yay! Less work.

sbottingota commented 1 year ago

I remember there might have been some problem with gamepad.wasJustPressed() last year, but I can't remember. Either way, if you think it's more elegant, or there's some problem with gamepad.wasJustPressed(), it should be easy to change the code to bind the commands in init.

12sliu commented 1 year ago

No need to change it, just leave as is.

sbottingota commented 1 year ago

https://github.com/Brighton-FTC/2024/commit/d267bbe28d38b214a3928da093f789c629620d1d

Made grabber into component class.

sbottingota commented 9 months ago

Deprecated, as we plan to use active intake instead.

sbottingota commented 7 months ago

Grabber is not used anymore; not sure why this is still here.