Skip to content

Conversation

@KaustubhKhulbe
Copy link
Contributor

Code works now.
Button press --> tracks until any other turret routine is called.
when button pressed, looks for new target and tracks that.

Copy link
Member

@aykhm aykhm left a comment

Choose a reason for hiding this comment

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

also run formatting before you commit!


val rezeroTurret by operator.rezeroTurret.readEagerly().withoutStamps
val reindexCarousel by operator.reindexCarousel.readEagerly().withoutStamps
val track by operator.trackTarget.readEagerly().withoutStamps
Copy link
Member

Choose a reason for hiding this comment

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

rename to smth slightly more descriptive

}
}

suspend fun TurretComponent.fieldOriented(drivetrain: DrivetrainComponent, limelight: LimelightComponent, turret: TurretComponent) {
Copy link
Member

Choose a reason for hiding this comment

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

turret doesn't need to be a paremeter, the function is an extension function of TurretComponent


controller {
if (lastLimelightPos != null) {
val pitch by drivetrain.hardware.pitch.readEagerly().withoutStamps
Copy link
Member

Choose a reason for hiding this comment

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

move sensor stuff to before the controller block

{ rezeroTurret } to { turret?.rezero(electrical) ?: freeze() },
{ reindexCarousel } to { whereAreMyBalls() },
{track} to {
trackTargetTurret()
Copy link
Member

Choose a reason for hiding this comment

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

you can just do turret?.fieldOriented(drivetrain, limelight) ?: freeze() and get rid of the trackTargetTurret function

if(reading != null) lastLimelightPos = reading

controller {
if (lastLimelightPos != null) {
Copy link
Member

Choose a reason for hiding this comment

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

make a copy of lastLimelightPos so you don't have to use !! later in line 95 (what if lastLimlightPos changes to null while this routine is running?)

val position = limelight.hardware.conversions.outerGoalPosition(lastLimelightPos!!, bearing, pitch)
val angle = atan2(position.x - drivetrainPosition.x, position.y - drivetrainPosition.y)
val target = (angle `coterminal +` drivetrainPosition.bearing)
if (abs(target) > 2.Degree) {
Copy link
Member

Choose a reason for hiding this comment

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

if we stop driving and aim to fire then we'll have up to 2 degrees of error D:


val safeSpeed by pref(1, Volt)
val windupPosition by pref(-90, Degree)
var lastLimelightPos: LimelightReading? = null
Copy link
Member

Choose a reason for hiding this comment

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

maybe rename to lastGoalPos

Base automatically changed from 2021-offseason to master October 11, 2021 01:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants