Skip to content

Commit fdf73b1

Browse files
committedNov 8, 2024·
Merge remote-tracking branch 'origin/main_nav' into main_nav
2 parents c5d2ce3 + 3ab1987 commit fdf73b1

File tree

5 files changed

+70
-8
lines changed

5 files changed

+70
-8
lines changed
 

‎drivetrain/poseEstimation/drivetrainPoseTelemetry.py

+12-4
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ def __init__(self):
2121
wpilib.SmartDashboard.putData("DT Pose 2D", self.field)
2222
self.curTraj = Trajectory()
2323
self.curTrajWaypoints = []
24-
self.obstacles = []
24+
self.fullObstacles = []
25+
self.thirdObstacles = []
26+
self.almostGoneObstacles = []
2527

2628
self.desPose = Pose2d()
2729

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

58-
def setCurObstacles(self, obstacles:list[Translation2d]):
59-
self.obstacles = obstacles
60+
def setCurObstacles(self, obstacles):
61+
self.fullObstacles, self.thirdObstacles, self.almostGoneObstacles = obstacles
6062

6163
def clearVisionObservations(self):
6264
self.visionPoses = []
@@ -75,7 +77,13 @@ def update(self, estPose:Pose2d, moduleAngles):
7577
self.field.getObject("desPose").setPose(self.desPose)
7678
self.field.getObject("desTraj").setTrajectory(self.curTraj)
7779
self.field.getObject("desTrajWaypoints").setPoses(self.curTrajWaypoints)
78-
self.field.getObject("curObstacles").setPoses([Pose2d(x, Rotation2d()) for x in self.obstacles])
80+
self.field.getObject("curObstaclesFull").setPoses([Pose2d(x, Rotation2d()) for x in self.fullObstacles])
81+
self.field.getObject("curObstaclesThird").setPoses([Pose2d(x, Rotation2d()) for x in self.thirdObstacles])
82+
self.field.getObject("curObstaclesAlmostGone").setPoses([Pose2d(x, Rotation2d()) for x in self.almostGoneObstacles])
83+
#print("Full: " + str(len(self.fullObstacles)))
84+
#print("Third: " + str(len(self.thirdObstacles)))
85+
#print("Almost gone: " + str(len(self.almostGoneObstacles)))
86+
7987

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

‎navigation/repulsorFieldPlanner.py

+21
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,11 @@ def __init__(self):
108108
# Track the "lookahead" - a series of steps predicting where we will go next
109109
self.lookaheadTraj:list[Pose2d] = []
110110

111+
#these actually aren't going to have any forces attached to them, it's just going to be for the graphics
112+
self.fullTransientObstacles = []
113+
self.thirdTransientObstacles = []
114+
self.almostGoneTransientObstacles = []
115+
111116
# Keep things slow right when the goal changes
112117
self.startSlowFactor = 0.0
113118

@@ -161,6 +166,22 @@ def _decayObservations(self):
161166
# Fully decayed obstacles have zero or negative strength.
162167
self.transientObstcales = [x for x in self.transientObstcales if x.strength > 0.0]
163168

169+
def getObstacleStrengths(self):
170+
#these are all Translation 2ds, or should be, but we can't say that if we want to return all 3.
171+
fullTransientObstacles = []
172+
thirdTransientObstacles = []
173+
almostGoneTransientObstacles = []
174+
175+
for x in self.transientObstcales:
176+
if x.strength > .5:
177+
fullTransientObstacles.extend(x.getTelemTrans())
178+
elif x.strength > .33:
179+
thirdTransientObstacles.extend(x.getTelemTrans())
180+
else:
181+
almostGoneTransientObstacles.extend(x.getTelemTrans())
182+
183+
return fullTransientObstacles, thirdTransientObstacles, almostGoneTransientObstacles
184+
164185
def getObstacleTransList(self) -> list[Translation2d]:
165186
"""
166187
Return a list of translations (x/y points), representing the current obstacles

‎robot.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@ def robotPeriodic(self):
7171

7272
self.autodrive.updateTelemetry()
7373
self.driveTrain.poseEst._telemetry.setCurAutoDriveWaypoints(self.autodrive.getWaypoints())
74-
self.driveTrain.poseEst._telemetry.setCurObstacles(self.autodrive.getObstacles())
74+
#self.driveTrain.poseEst._telemetry.setCurObstacles(self.autodrive.getObstacles())
75+
self.driveTrain.poseEst._telemetry.setCurObstacles(self.autodrive.rfp.getObstacleStrengths())
7576
self.stt.mark("Telemetry")
7677

7778
self.ledCtrl.setAutoDrive(self.autodrive.isRunning())

‎simgui-ds.json

+4
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,10 @@
9696
}
9797
],
9898
"robotJoysticks": [
99+
{
100+
"guid": "78696e70757401000000000000000000",
101+
"useGamepad": true
102+
},
99103
{
100104
"guid": "Keyboard0"
101105
}

‎simgui.json

+31-3
Original file line numberDiff line numberDiff line change
@@ -67,19 +67,44 @@
6767
"weight": 2.0
6868
},
6969
"bottom": 1476,
70-
"curObstacles": {
70+
"curObstaclesAlmostGone": {
71+
"arrows": false,
72+
"color": [
73+
255.0,
74+
0.0,
75+
232.50010681152344,
76+
255.0
77+
],
78+
"length": 0.6859999895095825,
79+
"selectable": false,
80+
"style": "Box/Image",
81+
"weight": 5.0
82+
},
83+
"curObstaclesFull": {
84+
"arrows": false,
85+
"color": [
86+
0.18339098989963531,
87+
0.19835130870342255,
88+
0.3529411554336548,
89+
255.0
90+
],
91+
"length": 0.6859999895095825,
92+
"selectable": false,
93+
"style": "Box/Image",
94+
"weight": 5.0
95+
},
96+
"curObstaclesThird": {
7197
"arrows": false,
7298
"color": [
7399
0.5098038911819458,
74100
0.26989617943763733,
75101
0.02998846210539341,
76102
255.0
77103
],
78-
"image": "obstacle.png",
79104
"length": 0.6859999895095825,
80105
"selectable": false,
81106
"style": "Box/Image",
82-
"weight": 16.0
107+
"weight": 5.0
83108
},
84109
"desTraj": {
85110
"arrowColor": [
@@ -148,6 +173,9 @@
148173
"open": true
149174
},
150175
"SmartDashboard": {
176+
"DT Pose 2D": {
177+
"open": true
178+
},
151179
"open": true
152180
}
153181
}

0 commit comments

Comments
 (0)
Please sign in to comment.