Skip to content
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

Note detection #57

Merged
merged 9 commits into from
Mar 13, 2024
Merged

Note detection #57

merged 9 commits into from
Mar 13, 2024

Conversation

icai0
Copy link
Contributor

@icai0 icai0 commented Mar 10, 2024

No description provided.

Copy link
Contributor

@lmaxwell24 lmaxwell24 left a comment

Choose a reason for hiding this comment

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

havn't deep dived checked the math yet but theres a bit here


def execute(self):
self.drive.arcadeDriveWithFactors(
0, 0, self.vision.dRobotAngle, self.drive.CoordinateMode.RobotRelative
Copy link
Contributor

Choose a reason for hiding this comment

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

driveWithFactors gives the rotation in radians / second, so you have to PID to get to the correct angle

as implemented its a PID loop with P gain set to 1


def execute(self):
self.drive.arcadeDriveWithFactors(
0.5, 0, 0, self.drive.CoordinateMode.RobotRelative
Copy link
Contributor

Choose a reason for hiding this comment

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

should still be actively trying to rotate here to ensure that if the note skids we still follow

commands/autonotepickup.py Show resolved Hide resolved
commands/autonotepickup.py Show resolved Hide resolved
constants.py Outdated
kNoteCameraYaw = 30 * kRadiansPerDegree
kNoteCameraHeight = 0.5 # meters
kRobotToNoteCameraTransform = Transform3d(
Pose3d(), Pose3d(0.1, -0.1, 0.5, Rotation3d(0, kNoteCameraPitch, kNoteCameraYaw))
Copy link
Contributor

Choose a reason for hiding this comment

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

what Euler order axis is Rotation3d? if its not yaw then pitch then the rotation won't do what you expect

is the note camera position proper? please take from cad

Copy link
Contributor Author

Choose a reason for hiding this comment

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

roll pitch yaw, all the numbers rn are placeholder

constants.py Outdated Show resolved Hide resolved
constants.py Outdated
@@ -236,6 +237,16 @@
kPhotonvisionBackRightCameraKey,
]

kPhotonvisionNoteCameraKey = "noteCamera"
kNoteInViewKey = "noteInView"
Copy link
Contributor

Choose a reason for hiding this comment

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

update these to use folders
also use the OptionalValueKeys class we already established for this type of purpose

@@ -121,6 +154,15 @@ def updateAdvantagescopePose(
)
SmartDashboard.putNumberArray(cameraKey, cameraPose)

def getNoteToCamera(self, note: PhotonTrackedTarget) -> Pose2d:
x = constants.kNoteCameraHeight / tan(
Copy link
Contributor

Choose a reason for hiding this comment

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

these constants for camera height should be able to come from the transform's components themselves

dist = (constants.kNoteCameraHeight**2 + x**2) ** 0.5
y = dist * tan(-note.getYaw() * constants.kRadiansPerDegree)

return Pose2d(x, y, atan(y / x))
Copy link
Contributor

Choose a reason for hiding this comment

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

since the function says note --> camera it should be a transform2d, not a pose2d

subsystems/visionsubsystem.py Show resolved Hide resolved
@icai0 icai0 requested a review from lmaxwell24 March 12, 2024 01:51
< constants.kAutoNotePickupAngleTolerance.radians()
):
self.drive.arcadeDriveWithFactors(
0.5, 0, angleOutput, self.drive.CoordinateMode.RobotRelative
Copy link
Contributor

Choose a reason for hiding this comment

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

move the 0.5 to a constant

Copy link
Contributor

Choose a reason for hiding this comment

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

or better, have a drive controller that starts with the current speed of the robot so we don't immediately come to a screeching halt with speed the second we say auto intake

SmartDashboard.putBoolean(constants.kNoteInViewKey, True)
else:
# rotate around if no note in vision
self.dRobotAngle = Rotation2d(0.1)
Copy link
Contributor

Choose a reason for hiding this comment

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

would be better to just finish silently if nothing detected or go to a standard driving instead of "search"

@icai0 icai0 requested a review from lmaxwell24 March 13, 2024 13:55
LandonBayer
LandonBayer previously approved these changes Mar 13, 2024
lmaxwell24
lmaxwell24 previously approved these changes Mar 13, 2024
@lmaxwell24 lmaxwell24 dismissed stale reviews from LandonBayer and themself via cccbd78 March 13, 2024 21:58
@lmaxwell24 lmaxwell24 merged commit e6a6a75 into main Mar 13, 2024
6 checks passed
@lmaxwell24 lmaxwell24 deleted the note-detection branch March 13, 2024 22:01
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.

3 participants