Team841 / FRC-2019

2 stars 1 forks source link

Turn-To-Target with Limelight #3

Open samneff72 opened 4 years ago

samneff72 commented 4 years ago

The Limelight connected to Asteria Deluxe publishes the coordinates of detected targets in relation to the crosshair in the middle of the Limelight.

Therefore, we can write code that will direct the robot to turn to face the target.

The function should live in the Drivetrain object, and be called by holding a button on the driver's controller.

When the 'x' value published to NetworkTables is above a certain value, the robot should turn in a direction. When it is below a certain value, it should turn the other. When it is between the values, the robot should not turn, but instead move forward or backwards at the rate of the throttle.

For extra credit, try making the rate of turning be controlled by the rate of the throttle application.

samneff72 commented 4 years ago

There's example code for this in the 2017 Robot code, in the Drivetrain object.

samneff72 commented 4 years ago

Yesterday we implemented a bang-bang algorithm, using the same general method as 2017 Robot Code.

The constants used should be moved into c.java

Feature requests: -Proportional rather than bang-bang control -Move forward when the robot is on center -Move forward/(backward?) proportional to throttle when robot is on center -Print an error or light an indicator on the robot dashboard when the button is pressed but there is no target in view