Skip to content

Commit

Permalink
limelight setup config
Browse files Browse the repository at this point in the history
  • Loading branch information
Inspirol committed Jan 12, 2024
1 parent f59a08b commit 414e422
Show file tree
Hide file tree
Showing 5 changed files with 96 additions and 3 deletions.
75 changes: 74 additions & 1 deletion config.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,77 @@
# 3 = ERROR
# 4 = SETUP
# anything else will log nothing
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

class Type():

def KStatic(r, g, b):
return {
'type': 1,
'color': {
'r': r,
'g': g,
'b': b
}
}

def KRainbow():
return {
'type': 2
}

def KTrack(r1, g1, b1, r2, g2, b2):
return {
'type': 3,
'color': {
'r1': r1,
'g1': g1,
'b1': b1,
'r2': r2,
'g2': g2,
'b2': b2
}
}

def KBlink(r,g,b):
return {
'type': 4,
'color': {
'r': r,
'g': g,
'b': b
}
}

def KLadder(typeA,typeB,percent,speed):
return {
'type': 5,
'percent': percent, # 0-1
'typeA': typeA,
'typeB': typeB,
'speed': speed
}



class Team:

red = 0
blue = 1


class LimelightPipeline:

feducial = 0.0
neural = 1.0
retroreflective = 2.0

limelight_led_mode: int = {
'pipeline_default': 0,
'force_off': 1,
'force_blink': 2,
'force_on': 3

}

active_team: Team = Team.blue
2 changes: 1 addition & 1 deletion sensors/field_odometry.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import math
import time

from robotpy_toolkit_7407.sensors.odometry import VisionEstimator
from toolkit.sensors.odometry import VisionEstimator
from wpimath.geometry import Pose2d, Pose3d, Rotation2d, Translation2d

# from subsystem import Drivetrain
Expand Down
2 changes: 1 addition & 1 deletion sensors/limelight.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from wpimath.geometry import Pose3d, Translation3d, Rotation3d
from wpimath.filter import MedianFilter

from robotpy_toolkit_7407.sensors.limelight.limelight import VisionEstimator
from toolkit.sensors.odometry import VisionEstimator

from wpilib import Timer

Expand Down
1 change: 1 addition & 0 deletions toolkit/sensors/odometry/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from toolkit.sensors.odometry.vision_estimator import VisionEstimator
19 changes: 19 additions & 0 deletions toolkit/sensors/odometry/vision_estimator.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
from wpimath.geometry import Pose3d
from wpilib import Timer


class VisionEstimator:
"""
An estimator (e.g. limelight, photon-vision) that returns a list of robot poses relative to the field.
"""

def __init__(self):
pass

def get_estimated_robot_pose(self) -> list[Pose3d, float] | None:
"""
Returns the robot's pose relative to the field, estimated by the vision system. Override this method.
:return: Vision system estimate of robot pose along with the associated timestamp.
:rtype: list[Pose3d, seconds: float] | None
"""
raise NotImplementedError

0 comments on commit 414e422

Please sign in to comment.