Skip to content
This repository has been archived by the owner on Apr 23, 2023. It is now read-only.

Commit

Permalink
DIST SENSROS FULLY WORKING (POGER)
Browse files Browse the repository at this point in the history
  • Loading branch information
chop0 committed Apr 8, 2022
1 parent eb1a5e1 commit ab1856a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,20 @@ public class DistanceSensorLocaliser implements Module, LocationProvider {

private final LocationProvider locationProvider;
private final ExtendedKalmanFilter filter;
private final SharpIRDistance frontLeft, backLeft/*, frontRight, backRight*/;
private final SharpIRDistance frontLeft, backLeft, frontRight, backRight;

private double x, y, heading;

public DistanceSensorLocaliser(LocationProvider locationProvider, ExtendedKalmanFilter filter,
SharpIRDistance frontLeft, SharpIRDistance backLeft) {
SharpIRDistance frontLeft, SharpIRDistance backLeft,
SharpIRDistance frontRight, SharpIRDistance backRight) {
this.locationProvider = locationProvider;
this.filter = filter;

this.frontLeft = frontLeft;
this.backLeft = backLeft;
// this.frontRight = hardwareMap.get(DistanceSensor.class, "frontRight");
// this.backRight = hardwareMap.get(DistanceSensor.class, "backRight");
this.frontRight = frontRight;
this.backRight = backRight;
}

private void processPartialState(Double[] sensorData) {
Expand Down Expand Up @@ -92,15 +93,15 @@ public void update() {
));
}

/* {
var bestWallRight = DistanceSensorPair.RIGHT.bestWall(locationProvider.getPose());
{
var bestWallRight = DistanceSensorPair.RIGHT.bestWall(Pose.of(filter.getVariance()), locationProvider.getPose());
if (bestWallRight != null)
processPartialState(DistanceSensorPair.RIGHT.getPartialState(
frontRight.getDistance(DistanceUnit.INCH),
backRight.getDistance(DistanceUnit.INCH),
frontRight.getDistance(),
backRight.getDistance(),
bestWallRight
));
}*/
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,15 @@ public SensorThread(Robot robot) {

var frontLeft = new SharpIRDistance(robot.getHardwareMap(), "frontLeft");
var backLeft = new SharpIRDistance(robot.getHardwareMap(), "backLeft");
var frontRight = new SharpIRDistance(robot.getHardwareMap(), "frontRight");
var backRight = new SharpIRDistance(robot.getHardwareMap(), "backRight");
this.distanceSensorLocaliser = new DistanceSensorLocaliser(
robot,
theKalmanFilter,
frontLeft,
backLeft
backLeft,
frontRight,
backRight
);

sensors = new HashSet<>();
Expand All @@ -69,6 +73,8 @@ public SensorThread(Robot robot) {
.chain(odometry)
.chain(frontLeft)
.chain(backLeft)
.chain(frontRight)
.chain(backRight)
.chain(distanceSensorLocaliser));

sensors.forEach(robot.getTelemetryDump()::registerTelemeter);
Expand Down

0 comments on commit ab1856a

Please sign in to comment.