Skip to content

Commit

Permalink
Handshaking with wanted robot NT keys
Browse files Browse the repository at this point in the history
  • Loading branch information
loqoman committed Feb 15, 2020
1 parent af25585 commit 47789cf
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
11 changes: 6 additions & 5 deletions 2020/comm.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ def PutNumberArray(key, value):
if theComm != None:
theComm.sd.putNumberArray("Vision/"+key, value)

def getCurrentPose():
def getCurrentTime():
if theComm != None:
# Get the current pose
robotState = theComm.controlTable.getNumberArray("robotPose",(-1,-1,-1))
return robotState # x,y,time
# Get the current time
timestamp = theComm.robotTable.getNumber("timestamp",(-1))
return timestamp # x,y,time

def getCameraPosition():
if theComm != None:
Expand Down Expand Up @@ -80,7 +80,8 @@ def __init__(self, serverIP):
self.UpdateVisionState("Standby")

# We communicate target to robot via Vision table.
self.controlTable = NetworkTables.getTable("/VisionControl`")
self.controlTable = NetworkTables.getTable("/VisionControl")
self.robotTable = NetworkTables.getTable("SmartDashboard/RobotState") #XXX: Might not work
self.control = Control()

# Robot communicates to us via fields within the Vision/Control
Expand Down
7 changes: 4 additions & 3 deletions 2020/targets.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class TargetPNP(Target):
def __init__(self):
super().__init__(self)
# Should be /SmartDashboard/Vision/PNPValue
self.subkey = "RobotPose"
self.subkey = "Target"
self.poseValue = None # Should be a tuple?
self.timeValue = None

Expand All @@ -94,7 +94,8 @@ def update(self, pose, time):

def send(self):
# Push to network tables
comm.PutNumberArray(self.subkey, (self.poseValue,self.timeValue))
# Should result in a key of '/Vision/Target/Result'
comm.PutNumberArray(self.subkey + "/Result", (self.poseValue,self.timeValue))

# Currently no doctests, however if needed un-comment
'''
Expand All @@ -107,4 +108,4 @@ def send(self):
logging.info("Began logger")
doctest.testmod()
'''
'''

0 comments on commit 47789cf

Please sign in to comment.