Skip to content

Commit

Permalink
bugfixes galore
Browse files Browse the repository at this point in the history
  • Loading branch information
gerth2 committed Sep 8, 2024
1 parent 1dcbe44 commit eeb3af2
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"type": "python",
"request": "attach",
"connect": {
"host": "roboRIO-1736-frc.local",
"host": "10.17.36.2",
"port": 5678
},
"pathMappings": [
Expand Down
3 changes: 2 additions & 1 deletion drivetrain/poseEstimation/drivetrainPoseTelemetry.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def setDesiredPose(self, desPose):
def addVisionObservations(self, observations:list[CameraPoseObservation]):
if(len(observations) > 0):
for obs in observations:
self.visionPoses.append(obs.estFieldPose())
self.visionPoses.append(obs.estFieldPose)

def clearVisionObservations(self):
self.visionPoses = []
Expand All @@ -64,6 +64,7 @@ def update(self, estPose:Pose2d, moduleAngles):
self.field.getObject("desTraj").setTrajectory(self.curTraj)

self.field.getObject("visionObservations").setPoses(self.visionPoses)
self.visionPoses = []

self.leftCamPosePublisher.set(Pose3d(estPose).transformBy(ROBOT_TO_LEFT_CAM))
self.rightCamPosePublisher.set(Pose3d(estPose).transformBy(ROBOT_TO_RIGHT_CAM))
Expand Down
17 changes: 11 additions & 6 deletions utils/extDriveManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@

class ExtDriveManager(metaclass=Singleton):
def __init__(self):
self.conn = False
self.enableDiskLogging = False
self.driveAvailableFault = Fault("Logging USB Drive Not Available")

if wpilib.RobotBase.isSimulation():
# Silently disable in sim
# Disable in sim
self.enableDiskLogging = False
self.logDir = ""
else:
Expand All @@ -21,13 +21,18 @@ def __init__(self):
except PermissionError as err:
print("Logging disabled!")
print(err)
self.enableDiskLogging = False
self.driveAvailableFault.setFaulted()

self.conn = True

if(os.path.isdir(self.logDir)):
self.enableDiskLogging = True
self.driveAvailableFault.setNoFault()
else:
self.enableDiskLogging = False
self.driveAvailableFault.setFaulted()


def getLogStoragePath(self):
return self.logDir

def isConnected(self):
return self.conn
return self.enableDiskLogging
12 changes: 7 additions & 5 deletions webserver/casseroleWebServerImpl.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,28 @@
# These imports are mostly just to make sure we put versions on the webpage
import wpilib
import rev
from photonlibpy import version

from utils.extDriveManager import ExtDriveManager

# Global list of all widgets on the dashboard.
dashboardWidgetList = []

# Where we expect to find our template files at
WEB_ROOT = pathlib.Path(__file__).parent / "www"
DASHBOARD_ROOT = WEB_ROOT / "dashboard"
WEB_ROOT = os.path.join(os.path.dirname(__file__), "www")
DASHBOARD_ROOT = os.path.join(WEB_ROOT, "dashboard")

# One-time, read in all the template files we'll fill out
INDEX_TMPLT_TXT = ""
with open(WEB_ROOT / "index.html_tmplt", "r", encoding="utf-8") as infile:
with open(os.path.join(WEB_ROOT, "index.html_tmplt"), "r", encoding="utf-8") as infile:
INDEX_TMPLT_TXT = infile.read()

HTML_TMPLT_TXT = ""
with open(DASHBOARD_ROOT / "dashboard.html_tmplt", "r", encoding="utf-8") as infile:
with open(os.path.join(DASHBOARD_ROOT, "dashboard.html_tmplt"), "r", encoding="utf-8") as infile:
HTML_TMPLT_TXT = infile.read()

JS_TMPLT_TXT = ""
with open(DASHBOARD_ROOT / "dashboard.js_tmplt", "r", encoding="utf-8") as infile:
with open(os.path.join(DASHBOARD_ROOT, "dashboard.js_tmplt"), "r", encoding="utf-8") as infile:
JS_TMPLT_TXT = infile.read()


Expand Down Expand Up @@ -83,6 +84,7 @@ def handleIndexPage(self):
deployText += f"Python - {platform.python_version()} - {sys.executable} \n"
deployText += f"WPILib - {wpilib.version.version} \n"
deployText += f"REV - {rev.version.version} \n"
deployText += f"PhotonVision - {version.PHOTONLIB_VERSION} \n"
deployText += f"Working Dir - {os.getcwd()}\n"

filledOut = INDEX_TMPLT_TXT.replace("${BUILD_INFO}", deployText)
Expand Down
5 changes: 3 additions & 2 deletions wrappers/wrapperedPhotonCamera.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import wpilib
from wpimath.units import feetToMeters
from wpimath.geometry import Pose2d
from photonlibpy.photonCamera import PhotonCamera #VisionLEDMode
from photonlibpy import PhotonCamera
from photonlibpy.photonCamera import setVersionCheckEnabled
from utils.fieldTagLayout import FieldTagLayout
from utils.faults import Fault

Expand All @@ -18,7 +19,7 @@ def __init__(self, time, estFieldPose, trustworthiness=1.0):
# 3 - Handle recording latency of when the image was actually seen
class WrapperedPhotonCamera:
def __init__(self, camName, robotToCam):
#setVersionCheckEnabled(False)
setVersionCheckEnabled(False)

self.cam = PhotonCamera(camName)

Expand Down

0 comments on commit eeb3af2

Please sign in to comment.