-
Notifications
You must be signed in to change notification settings - Fork 7
Mechanism2D in AdvantageScope testing #151
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
LiveWindow.disableAllTelemetry(); | ||
LiveWindow.enableTelemetry(PDH); | ||
mech = new Mechanism2d(1, 2); | ||
root = mech.getRoot("climber", 0.5 + Units.inchesToMeters(5.5), Units.inchesToMeters(19.5)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
? Not sure what the "climber" is, as this year's robot isn't supposed to climb.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Funnel pivot?
root = mech.getRoot("climber", 0.5 + Units.inchesToMeters(5.5), Units.inchesToMeters(19.5)); | ||
SmartDashboard.putData("Mechanism", mech); | ||
m_elevator = | ||
root.append(new MechanismLigament2d("elevator", 1, 90, 2, new Color8Bit(Color.kRed))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Worth a comment that this is a single-stage elevator even though the robot actually uses a multi-stage elevator.
public static final double CORAL_QUICK_INTAKE = 1.6; | ||
public static final double MIN_EMPTY_GROUND_INTAKE = 4.5; | ||
public static final double MIN_FULL_GROUND_INTAKE = 8.0; | ||
private static final double MOTOR_ROTATIONS_PER_METER = 40; // Inaccurate |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be able to make this accurate by measuring how far the elevator extends (in meters) at CORAL_LEVEL_FOUR_PRE_POS and then simply change this to 37.5 / <actual relative elevator extension>
, where <actual relative elevator extension>
is what's measured with a tape measure.
Mechanism2d mech; | ||
MechanismRoot2d root; | ||
MechanismLigament2d m_elevator; | ||
MechanismLigament2d m_wrist; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be nicer to encapsulate the Mechanism (and similar "report physical position") code in a different class instead of adding it to the main Robot
class. These are generally called 'digital twins', so could use something like DigitalTwin.java and have robotPeriodic()
simply call an update()
function on it.
m_motorOneSimState.setRawRotorPosition(targetPos); | ||
m_motorTwoSimState.setRawRotorPosition(targetPos); | ||
|
||
elevatorPose3d.set(new Pose3d(new Pose2d(0.0, getHeightMeters(), new Rotation2d(0.0,0.0)))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When running this in the simulator, it's continually logging this error here:
Error at java.base/java.lang.Thread.getStackTrace(Thread.java:1619): x and y components of Rotation2d are zero
at java.base/java.lang.Thread.getStackTrace(Thread.java:1619)
at edu.wpi.first.math.geometry.Rotation2d.<init>(Rotation2d.java:126)
at frc.robot.subsystems.ElevatorSubsystem.periodic(ElevatorSubsystem.java:388)
at edu.wpi.first.wpilibj2.command.CommandScheduler.run(CommandScheduler.java:269)
at frc.robot.Robot.robotPeriodic(Robot.java:137)
at edu.wpi.first.wpilibj.IterativeRobotBase.loopFunc(IterativeRobotBase.java:400)
at edu.wpi.first.wpilibj.TimedRobot.startCompetition(TimedRobot.java:148)
at edu.wpi.first.wpilibj.RobotBase.runRobot(RobotBase.java:419)
at edu.wpi.first.wpilibj.RobotBase.lambda$startRobot$1(RobotBase.java:490)
at java.base/java.lang.Thread.run(Thread.java:840)
No description provided.