Skip to content

Commit

Permalink
I made an oopsy and didn't check out the latest branch... I'll merge …
Browse files Browse the repository at this point in the history
…in a second.

Overall, the transient obstacles show three different colored boxes now, as it decays (not the prettiest, but functional). WIP because of the not-understandable graphics and the other obstacles don't show up.
  • Loading branch information
1736student committed Nov 8, 2024
1 parent bfe6be0 commit a872793
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 8 deletions.
16 changes: 12 additions & 4 deletions drivetrain/poseEstimation/drivetrainPoseTelemetry.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ def __init__(self):
wpilib.SmartDashboard.putData("DT Pose 2D", self.field)
self.curTraj = Trajectory()
self.curTrajWaypoints = []
self.obstacles = []
self.fullObstacles = []
self.thirdObstacles = []
self.almostGoneObstacles = []

self.desPose = Pose2d()

Expand Down Expand Up @@ -55,8 +57,8 @@ def addVisionObservations(self, observations:list[CameraPoseObservation]):
for obs in observations:
self.visionPoses.append(obs.estFieldPose)

def setCurObstacles(self, obstacles:list[Translation2d]):
self.obstacles = obstacles
def setCurObstacles(self, obstacles):
self.fullObstacles, self.thirdObstacles, self.almostGoneObstacles = obstacles

def clearVisionObservations(self):
self.visionPoses = []
Expand All @@ -75,7 +77,13 @@ def update(self, estPose:Pose2d, moduleAngles):
self.field.getObject("desPose").setPose(self.desPose)
self.field.getObject("desTraj").setTrajectory(self.curTraj)
self.field.getObject("desTrajWaypoints").setPoses(self.curTrajWaypoints)
self.field.getObject("curObstacles").setPoses([Pose2d(x, Rotation2d()) for x in self.obstacles])
self.field.getObject("curObstaclesFull").setPoses([Pose2d(x, Rotation2d()) for x in self.fullObstacles])
self.field.getObject("curObstaclesThird").setPoses([Pose2d(x, Rotation2d()) for x in self.thirdObstacles])
self.field.getObject("curObstaclesAlmostGone").setPoses([Pose2d(x, Rotation2d()) for x in self.almostGoneObstacles])
#print("Full: " + str(len(self.fullObstacles)))
#print("Third: " + str(len(self.thirdObstacles)))
#print("Almost gone: " + str(len(self.almostGoneObstacles)))


self.field.getObject("visionObservations").setPoses(self.visionPoses)
self.visionPoses = []
Expand Down
21 changes: 21 additions & 0 deletions navigation/repulsorFieldPlanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,11 @@ def __init__(self):
self.goal:Pose2d|None = None
self.lookaheadTraj:list[Pose2d] = []

#these actually aren't going to have any forces attached to them, it's just going to be for the graphics
self.fullTransientObstacles = []
self.thirdTransientObstacles = []
self.almostGoneTransientObstacles = []

#addLog("PotentialField Num Obstacles", lambda: (len(self.fixedObstacles) + len(self.transientObstcales)))
#addLog("PotentialField Path Active", lambda: (self.goal is not None))
#addLog("PotentialField DistToGo", lambda: self.distToGo, "m")
Expand Down Expand Up @@ -148,6 +153,22 @@ def _decayObservations(self):
# Fully decayed obstacles have zero or negative strength.
self.transientObstcales = [x for x in self.transientObstcales if x.strength > 0.0]

def getObstacleStrengths(self):
#these are all Translation 2ds, or should be, but we can't say that if we want to return all 3.
fullTransientObstacles = []
thirdTransientObstacles = []
almostGoneTransientObstacles = []

for x in self.transientObstcales:
if x.strength > .5:
fullTransientObstacles.extend(x.getTelemTrans())
elif x.strength > .33:
thirdTransientObstacles.extend(x.getTelemTrans())
else:
almostGoneTransientObstacles.extend(x.getTelemTrans())

return fullTransientObstacles, thirdTransientObstacles, almostGoneTransientObstacles

def getObstacleTransList(self) -> list[Translation2d]:
"""
Return a list of translations (x/y points), representing the current obstacles
Expand Down
3 changes: 2 additions & 1 deletion robot.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ def robotPeriodic(self):

self.autodrive.updateTelemetry()
self.driveTrain.poseEst._telemetry.setCurAutoDriveWaypoints(self.autodrive.getWaypoints())
self.driveTrain.poseEst._telemetry.setCurObstacles(self.autodrive.getObstacles())
#self.driveTrain.poseEst._telemetry.setCurObstacles(self.autodrive.getObstacles())
self.driveTrain.poseEst._telemetry.setCurObstacles(self.autodrive.rfp.getObstacleStrengths())
self.stt.mark("Telemetry")

self.ledCtrl.setAutoDrive(self.autodrive.isRunning())
Expand Down
4 changes: 4 additions & 0 deletions simgui-ds.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@
}
],
"robotJoysticks": [
{
"guid": "78696e70757401000000000000000000",
"useGamepad": true
},
{
"guid": "Keyboard0"
}
Expand Down
34 changes: 31 additions & 3 deletions simgui.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,19 +60,44 @@
"style": "Line (Closed)"
},
"bottom": 1476,
"curObstacles": {
"curObstaclesAlmostGone": {
"arrows": false,
"color": [
255.0,
0.0,
232.50010681152344,
255.0
],
"length": 0.6859999895095825,
"selectable": false,
"style": "Box/Image",
"weight": 5.0
},
"curObstaclesFull": {
"arrows": false,
"color": [
0.18339098989963531,
0.19835130870342255,
0.3529411554336548,
255.0
],
"length": 0.6859999895095825,
"selectable": false,
"style": "Box/Image",
"weight": 5.0
},
"curObstaclesThird": {
"arrows": false,
"color": [
0.5098038911819458,
0.26989617943763733,
0.02998846210539341,
255.0
],
"image": "obstacle.png",
"length": 0.6859999895095825,
"selectable": false,
"style": "Box/Image",
"weight": 16.0
"weight": 5.0
},
"desTraj": {
"arrowColor": [
Expand Down Expand Up @@ -141,6 +166,9 @@
"open": true
},
"SmartDashboard": {
"DT Pose 2D": {
"open": true
},
"open": true
}
}
Expand Down

0 comments on commit a872793

Please sign in to comment.