Skip to content

Commit

Permalink
adding obstacle telemetry
Browse files Browse the repository at this point in the history
  • Loading branch information
gerth2 committed Sep 27, 2024
1 parent 9ca2def commit 5346cf2
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 5 deletions.
2 changes: 1 addition & 1 deletion drivetrain/controlStrategies/autoDrive.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def getWaypoints(self) -> list[Pose2d]:
return self._telemTraj

def getObstacles(self) -> list[Translation2d]:
return [x.translation() for x in self._rfp.getObstaclePoseList()]
return self._rfp.getObstacleTransList()

def update(self, cmdIn: DrivetrainCommand, curPose: Pose2d) -> DrivetrainCommand:

Expand Down
10 changes: 8 additions & 2 deletions drivetrain/poseEstimation/drivetrainPoseTelemetry.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import wpilib
from wpimath.units import metersToFeet
from wpimath.trajectory import Trajectory
from wpimath.geometry import Pose2d, Pose3d, Transform2d
from wpimath.geometry import Pose2d, Pose3d, Transform2d, Rotation2d, Translation2d
from ntcore import NetworkTableInstance

from utils.signalLogging import log
Expand All @@ -23,6 +23,8 @@ def __init__(self):
wpilib.SmartDashboard.putData("DT Pose 2D", self.field)
self.curTraj = Trajectory()
self.curTrajWaypoints = []
self.obstacles = []

self.desPose = Pose2d()

self.leftCamPosePublisher = (
Expand All @@ -42,14 +44,17 @@ def __init__(self):
def setDesiredPose(self, desPose):
self.desPose = desPose

def setCurTrajWaypoints(self, waypoints):
def setCurTrajWaypoints(self, waypoints:list[Pose2d]):
self.curTrajWaypoints = waypoints

def addVisionObservations(self, observations:list[CameraPoseObservation]):
if(len(observations) > 0):
for obs in observations:
self.visionPoses.append(obs.estFieldPose)

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

def clearVisionObservations(self):
self.visionPoses = []

Expand All @@ -67,6 +72,7 @@ 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("visionObservations").setPoses(self.visionPoses)
self.visionPoses = []
Expand Down
2 changes: 1 addition & 1 deletion navigation/repulsorFieldPlanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def decay_observations(self):
# Only keep obstacles with positive strength
self.transientObstcales = [x for x in self.transientObstcales if x.strength > 0.0]

def getObstaclePoseList(self) -> list[Pose2d]:
def getObstacleTransList(self) -> list[Translation2d]:
retArr = []
for obstacle in self.fixedObstacles:
retArr.extend(obstacle.getTelemTrans())
Expand Down
2 changes: 1 addition & 1 deletion robot.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def teleopPeriodic(self):
self.autodrive.updateTelemetry()
self.driveTrain.poseEst.telemetry.setWPITrajectory(self.autodrive.getTrajectory())
self.driveTrain.poseEst.telemetry.setCurTrajWaypoints(self.autodrive.getWaypoints())
self.driveTrain.poseEst.telemetry.setCurTrajWaypoints(self.autodrive.getWaypoints())
self.driveTrain.poseEst.telemetry.setCurObstacles(self.autodrive.getObstacles())

# No trajectory in Teleop
Trajectory().setCmd(None)
Expand Down
12 changes: 12 additions & 0 deletions simgui.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,18 @@
"style": "Line (Closed)"
},
"bottom": 1476,
"curObstacles": {
"arrows": false,
"color": [
0.5098038911819458,
0.26989617943763733,
0.02998846210539341,
255.0
],
"selectable": false,
"style": "Box/Image",
"weight": 16.0
},
"desTraj": {
"arrowColor": [
187.2151641845703,
Expand Down

0 comments on commit 5346cf2

Please sign in to comment.