Skip to content
This repository has been archived by the owner on Sep 27, 2024. It is now read-only.

Scoring Algorithm Added #54

Merged
merged 9 commits into from
Dec 5, 2023
Merged

Conversation

Picklze1
Copy link
Contributor

Changes:

  • Added Scoring Algorithm
    -Changed Claw Values

Copy link
Contributor

@GabrielAndrus GabrielAndrus left a comment

Choose a reason for hiding this comment

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

All good! Thanks, George.

Copy link
Contributor

@RZW-13 RZW-13 left a comment

Choose a reason for hiding this comment

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

Didn't we want the viper slides to move in sync?

@Picklze1
Copy link
Contributor Author

Didn't we want the viper slides to move in sync?

Would you like me to separate them??

Copy link
Contributor

@RZW-13 RZW-13 left a comment

Choose a reason for hiding this comment

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

Looks pretty good, just a couple changes. :)

public void setViperSlidePos() {
telemetry.addData("Scoring Status", "Setting VS Pos");
// Setting ViperSlidePoses based on Targets.
while (robot.<DcMotor>get("rightViperSlideMotor").getCurrentPosition() != viperSlideTargetPos) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you're mimicking a .setTargetPosition command for all of these. Either way, I think you need to adjust this to let us run both viper slides simultaneously.

Copy link
Contributor

Choose a reason for hiding this comment

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

You also might need to make this use tolerance (eg. Math.abs(currentPosition - targetPosition) < tolerance), since exactly hitting it's target is unlikely, esp with your current system that only lets the viper slides move one way.

Copy link
Contributor

Choose a reason for hiding this comment

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

same thing throughout your code

Copy link
Contributor

@RZW-13 RZW-13 left a comment

Choose a reason for hiding this comment

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

just a couple fixes

}

public void resetPos() {
telemetry.addData("Scoring Status1` ", "Resetting Pos");
Copy link
Contributor

Choose a reason for hiding this comment

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

not sure what happened here...

Copy link
Contributor

Choose a reason for hiding this comment

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

you didn't fix this. try not to mark things as resolved if you don't address them.


setArmPos();

setJointPos();
Copy link
Contributor

Choose a reason for hiding this comment

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

please remove the random line breaks

Copy link
Contributor

Choose a reason for hiding this comment

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

don't mark it as resolved if you don't do it lmao-

Copy link
Contributor

@RZW-13 RZW-13 left a comment

Choose a reason for hiding this comment

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

progress!

@@ -17,8 +17,12 @@ public class ScoringAlgorithm extends OpMode {
boolean pixelsInClaw = false;
double armStartPos = 0.0;
double armTargetPos = 0.0;
double armStartTolerance = 0.0;
Copy link
Contributor

Choose a reason for hiding this comment

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

tolerance doesn't work if the tolerance is set to zero...


setArmPos();

setJointPos();
Copy link
Contributor

Choose a reason for hiding this comment

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

don't mark it as resolved if you don't do it lmao-

// Setting ViperSlidePoses based on Targets.
while (Math.abs(robot.<DcMotor>get("leftViperSlideMotor").getCurrentPosition() - viperSlideTargetPos) > viperSlideTolerance) {

robot.<DcMotor>get("rightViperSlideMotor").setPower(0.4);
Copy link
Contributor

Choose a reason for hiding this comment

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

fix this indentation

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it is.

public void setViperSlidePos() {
telemetry.addData("Scoring Status", "Setting VS Pos");
// Setting ViperSlidePoses based on Targets.
while (Math.abs(robot.<DcMotor>get("leftViperSlideMotor").getCurrentPosition() - viperSlideTargetPos) > viperSlideTolerance) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Checking the left viper slide values to run both slides is a bad way to do this; if there's any difference in the speeds of the motors, then the difference is going to compound and you're going to end up with inaccurate parts at best, broken parts at worst.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed...


while (Math.abs(robot.<DcMotor>get("armMotor").getCurrentPosition() - armStartPos) > armStartTolerance) {
Copy link
Contributor

Choose a reason for hiding this comment

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

same thing as above

there's a chance you might want to add a condition to catch if it would ever miss your entire section. you can solve this by either changing the while condition to be while (robot.get("armMotor").getCurrentPosition < armTargetPos){} which would work well to catch it as soon as it passes that threshold

however, if you're more concerned with accuracy and willing to sacrifice some time, you can do something that's basically inside of your while loop that checks if (robot.get("armMotor").getCurrentPosition < armTargetPos - armTolerance){} and add an else if to check else if (robot.get("armMotor").getCurrentPosition > armTargetPos + armTolerance){} which would basically let it self correct

Copy link
Contributor Author

Choose a reason for hiding this comment

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

see above....

}
robot.<DcMotor>get("armMotor").setPower(0);

while (Math.abs(robot.<DcMotor>get("leftViperSlideMotor").getCurrentPosition() - viperSlideStartPos) > viperSlideStartTolerance) {

robot.<DcMotor>get("rightViperSlideMotor").setPower(0.4);
Copy link
Contributor

Choose a reason for hiding this comment

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

same thing here, right motor is based off of left motor values and cannot run on its own (eg. left motor cannot be stopped while right motor is running)

private void scoring() {


public void scoring() {
Copy link
Contributor

@RZW-13 RZW-13 Nov 30, 2023

Choose a reason for hiding this comment

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

this isn't functional as a proof of concept if you don't call this method anywhere


private Hardware robot;

public void init() {
Copy link
Contributor

Choose a reason for hiding this comment

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

remove line breaks within init()

}

telemetry.addData("CRServo", "Running");

Copy link
Contributor

Choose a reason for hiding this comment

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

remove this line break

Copy link
Contributor

@RZW-13 RZW-13 left a comment

Choose a reason for hiding this comment

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

someone else should probably look over this seeing as i wrote it...

private Hardware robot;
// TODO: Get values for variables.
boolean pixelsInClaw = false;
double armStartPos = 0.0;
double armTargetPos = 0.0;
double armStartTolerance = 0.0;
double armTolerance = 0.0;
double armTolerance = 2.5;
double viperSlideStartPos = 0.0;
double viperSlideTargetPos = 0.0;
Copy link
Contributor

Choose a reason for hiding this comment

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

let's get values for this

@@ -11,28 +11,27 @@

@Autonomous(name = "Scoring Algorithm", group = "auton")
public class ScoringAlgorithm extends OpMode {

private Hardware robot;
// TODO: Get values for variables.
boolean pixelsInClaw = false;
double armStartPos = 0.0;
double armTargetPos = 0.0;
Copy link
Contributor

Choose a reason for hiding this comment

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

let's get a value for this

double viperSlideStartPos = 0.0;
double viperSlideTargetPos = 0.0;
double viperSlideStartTolerance = 0.0;
double viperSlideTolerance = 0;
double jointStartPos = 0.0;
double jointTargetPos = 0.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 this to not zero :)

}

public void setViperSlidePos() {
// If this is not true, the rest of the code will not function.
assert viperSlideTargetPos > viperSlideStartPos;
Copy link
Contributor

Choose a reason for hiding this comment

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

should be >=

telemetry.addData("Scoring Status", "VS Pos Set");
}

public void setArmPos() {
// If this is not true, the rest of the code will not function.
assert armTargetPos > armStartPos;
Copy link
Contributor

Choose a reason for hiding this comment

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

should be >=

Copy link
Member

@milobanks milobanks left a comment

Choose a reason for hiding this comment

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

Fix the stuff, and come up with more creative method names.

Copy link
Member

@milobanks milobanks left a comment

Choose a reason for hiding this comment

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

Deferring to Rayne.

Copy link
Contributor

@RZW-13 RZW-13 left a comment

Choose a reason for hiding this comment

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

thank you :)

@Picklze1 Picklze1 merged commit ff9c857 into master Dec 5, 2023
@Picklze1 Picklze1 deleted the George-Jensen-Scoring-Algorithm branch December 5, 2023 22:58
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.

4 participants