Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
389b3f5
Initial test of diagonal movement
Gold872 Nov 5, 2024
3fc237c
Added turning logic to sensor and timed drive
Gold872 Nov 5, 2024
131be91
More docs
Gold872 Nov 5, 2024
f7e34f0
Added network detector
Gold872 Nov 24, 2024
e3e1173
Refactored movement units
Gold872 Nov 24, 2024
40b1441
Added tank autonomy file
Bing-Rover Nov 24, 2024
1a877fe
Tested on tank 11/25
Bing-Rover Nov 26, 2024
315c3ed
Fixed all occurances of toGps()
Gold872 Nov 28, 2024
e480c37
Fixed toGps() in task.dart
Gold872 Nov 28, 2024
a41b184
Specified networking library version
Gold872 Nov 28, 2024
e19dae7
Fixed isNear method
Gold872 Nov 28, 2024
c0d71ae
Refactor and Reorganization (#7)
Gold872 Dec 8, 2024
b0655a5
Corrected directions
Gold872 Dec 14, 2024
fa81bf8
Initial work on fixing unit tests
Gold872 Dec 17, 2024
1ceb9bd
Account for move length in heuristic
Gold872 Dec 17, 2024
d030100
Simplified heuristic calculation (again)
Gold872 Dec 17, 2024
4a03f60
Fix path following not stopping after restart
Gold872 Dec 18, 2024
9657bb4
Fixed heuristic math to use only distance
Gold872 Dec 18, 2024
4b50d0a
Add more path tests
Gold872 Dec 18, 2024
3bfe8cb
Fixed excessive turns (no idea why this fixes it but whatever)
Gold872 Dec 20, 2024
59cbc34
fix merge conflicts
Gold872 Dec 24, 2024
ede6774
Fixed sensor drive
Gold872 Dec 24, 2024
0e31908
Fixed heuristic and duplicate hashing
Gold872 Jan 16, 2025
64bf1e3
Added path optimizer and more unit tests
Gold872 Jan 24, 2025
0dffb69
Initial testing on rover
Bing-Rover Jan 24, 2025
5a5c1ff
Fixes from testing
Gold872 Jan 31, 2025
eb14e61
Began documenting
Gold872 Jan 31, 2025
a7264a2
Use sim imu in task
Gold872 Jan 31, 2025
d55748e
Use meters for goForward()
Gold872 Feb 3, 2025
758eb26
Use meters for distanceTo()
Gold872 Feb 3, 2025
991c426
Additional testing on rover
Bing-Rover Jan 24, 2025
60de9d2
Moved things into constants
Gold872 Feb 4, 2025
fd1180d
More safety replanning features:
Gold872 Feb 4, 2025
86bea08
Replan paths if timeout is hit
Gold872 Feb 4, 2025
e3f7733
GPSUtil cleanup
Gold872 Feb 4, 2025
2e24f0d
Improved heuristic and sharpen intermediate drive tolerance
Gold872 Feb 6, 2025
d9a1cd1
Point to next waypoint before driving (only with RTK)
Gold872 Feb 6, 2025
da21d76
Works on rover!
Bing-Rover Jan 24, 2025
477766e
Resolved NASTY merge conflicts
Gold872 Feb 7, 2025
d182fc1
Remove unused imports
Gold872 Feb 7, 2025
67a52fb
Update CI dependency overrides
Gold872 Feb 7, 2025
61ca97b
Return method early when timing out
Gold872 Feb 7, 2025
6073948
Fix hasValue
Gold872 Feb 7, 2025
7876520
Bump mandatory burt_network version
Gold872 Feb 9, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/pubspec_overrides.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ resolution:
dependency_overrides:
burt_network:
git:
url: https://github.com/BinghamtonRover/Networking
ref: 2.3.1
url: https://github.com/BinghamtonRover/Rover-Code.git
path: burt_network
5 changes: 5 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"cSpell.words": [
"setpoint"
]
}
17 changes: 9 additions & 8 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,24 @@ include: package:very_good_analysis/analysis_options.yaml # has more lints

analyzer:
language:
# Strict casts isn't helpful with null safety. It only notifies you on `dynamic`,
# which happens all the time in JSON.
#
# Strict casts isn't helpful with null safety. It only notifies you on `dynamic`,
# which happens all the time in JSON.
#
# See https://github.com/dart-lang/language/blob/main/resources/type-system/strict-casts.md
strict-casts: false

# Don't let any types be inferred as `dynamic`.
#
#
# See https://github.com/dart-lang/language/blob/main/resources/type-system/strict-inference.md
strict-inference: true

# Don't let Dart infer the wrong type on the left side of an assignment.
#
# Don't let Dart infer the wrong type on the left side of an assignment.
#
# See https://github.com/dart-lang/language/blob/main/resources/type-system/strict-raw-types.md
strict-raw-types: true

exclude:
exclude:
- test/*.dart

linter:
rules:
Expand All @@ -44,7 +45,7 @@ linter:
sort_constructors_first: false # final properties, then constructor
avoid_dynamic_calls: false # this lint takes over errors in the IDE
cascade_invocations: false # cascades are often less readable

# Temporarily disabled lints
public_member_api_docs: false # until we are ready to document
flutter_style_todos: false # until we are ready to address them
2 changes: 1 addition & 1 deletion bin/arcuo.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import "package:autonomy/autonomy.dart";

void main() async {
final rover = RoverAutonomy();
rover.drive = RoverDrive(collection: rover, useImu: false, useGps: false);
rover.drive = RoverDrive(collection: rover, useImu: false, useGps: false);
await rover.init();
//await rover.waitForValue();
final didSeeAruco = await rover.drive.spinForAruco();
Expand Down
4 changes: 2 additions & 2 deletions bin/latlong.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ void printInfo(String name, double latitude) {
GpsInterface.currentLatitude = latitude;
print("At $name:");
print(" There are ${GpsUtils.metersPerLongitude.toStringAsFixed(2)} meters per 1 degree of longitude");
print(" Our max error in longitude would be ${GpsUtils.epsilonLongitude} degrees");
print(" Our max error in longitude would be ${GpsUtils.epsilonLongitude.toStringAsFixed(20)} degrees");
final isWithinRange = GpsInterface.gpsError <= GpsUtils.epsilonLongitude;
print(" Our GPS has ${GpsInterface.gpsError} degrees of error, so this would ${isWithinRange ? 'work' : 'not work'}");
}

void main() {
print("There are always ${GpsUtils.metersPerLatitude} meters in 1 degree of latitude");
print(" So our max error in latitude is always ${GpsUtils.epsilonLatitude} degrees");
print(" So our max error in latitude is always ${GpsUtils.epsilonLatitude.toStringAsFixed(20)} degrees");
printInfo("the equator", 0);
printInfo("Binghamton", binghamtonLatitude);
printInfo("Utah", utahLatitude);
Expand Down
4 changes: 2 additions & 2 deletions bin/path.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import "package:autonomy/simulator.dart";

void main() {
GpsUtils.maxErrorMeters = 1;
final destination = (1000, 1000).toGps();
final destination = (lat: 1000, long: 1000).toGps();
final simulator = AutonomySimulator();
simulator.pathfinder = RoverPathfinder(collection: simulator);
final path = simulator.pathfinder.getPath(destination);
Expand All @@ -18,7 +18,7 @@ void main() {
}
var turnCount = 0;
for (final step in path) {
if (step.direction == DriveDirection.left || step.direction == DriveDirection.right) {
if (step.instruction == DriveDirection.left || step.instruction == DriveDirection.right) {
turnCount++;
}
}
Expand Down
3 changes: 1 addition & 2 deletions bin/random.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// ignore_for_file: avoid_print

import "package:autonomy/interfaces.dart";
import "package:autonomy/src/rover/corrector.dart";

const maxError = GpsInterface.gpsError;
const maxSamples = 10;
Expand All @@ -17,7 +16,7 @@ bool test() {
corrector.addValue(value);
if (verbose) {
final calibrated = corrector.calibratedValue;
print("Current value: $value, Corrected value: $calibrated");
print("Current value: $value, Corrected value: $calibrated");
print(" Difference: ${calibrated.toStringAsFixed(7)} < ${epsilon.toStringAsFixed(7)}");
}
}
Expand Down
114 changes: 57 additions & 57 deletions bin/sensorless.dart
Original file line number Diff line number Diff line change
@@ -1,63 +1,63 @@
import "package:burt_network/logging.dart";
import "package:burt_network/protobuf.dart";
// import "package:burt_network/logging.dart";
// import "package:burt_network/protobuf.dart";

import "package:autonomy/simulator.dart";
import "package:autonomy/rover.dart";
// import "package:autonomy/simulator.dart";
// import "package:autonomy/rover.dart";

void main() async {
Logger.level = LogLevel.debug;
final simulator = AutonomySimulator();
simulator.drive = SensorlessDrive(collection: simulator, useGps: false, useImu: false);
await simulator.init();
await simulator.server.waitForConnection();
// void main() async {
// Logger.level = LogLevel.debug;
// final simulator = AutonomySimulator();
// simulator.drive = SensorlessDrive(collection: simulator, useGps: false, useImu: false);
// await simulator.init();
// await simulator.server.waitForConnection();

final message = AutonomyData(
destination: GpsCoordinates(latitude: 0, longitude: 0),
state: AutonomyState.DRIVING,
task: AutonomyTask.GPS_ONLY,
obstacles: [],
path: [
for (double x = 0; x < 3; x++)
for (double y = 0; y < 3; y++)
GpsCoordinates(latitude: y, longitude: x),
],
);
simulator.server.sendMessage(message);
// final message = AutonomyData(
// destination: GpsCoordinates(latitude: 0, longitude: 0),
// state: AutonomyState.DRIVING,
// task: AutonomyTask.GPS_ONLY,
// obstacles: [],
// path: [
// for (double x = 0; x < 3; x++)
// for (double y = 0; y < 3; y++)
// GpsCoordinates(latitude: y, longitude: x),
// ],
// );
// simulator.server.sendMessage(message);

// "Snakes" around a 3x3 meter box. (0, 0), North
await simulator.drive.goForward(); // (1, 0), North
await simulator.drive.goForward(); // (2, 0), North
await simulator.drive.turnRight(); // (2, 0), East
await simulator.drive.goForward(); // (2, 1), East
await simulator.drive.turnRight(); // (2, 1), South
await simulator.drive.goForward(); // (1, 1), South
await simulator.drive.goForward(); // (0, 1), South
await simulator.drive.turnLeft(); // (0, 1), East
await simulator.drive.goForward(); // (0, 2), East
await simulator.drive.turnLeft(); // (0, 2), North
await simulator.drive.goForward(); // (1, 2), North
await simulator.drive.goForward(); // (2, 2), North
await simulator.drive.turnLeft(); // (2, 2), West
await simulator.drive.goForward(); // (2, 1), West
await simulator.drive.goForward(); // (2, 0), West
await simulator.drive.turnLeft(); // (2, 0), South
await simulator.drive.goForward(); // (1, 0), South
await simulator.drive.goForward(); // (0, 0), South
await simulator.drive.turnLeft(); // (0, 0), East
await simulator.drive.turnLeft(); // (0, 0), North
// // "Snakes" around a 3x3 meter box. (0, 0), North
// await simulator.drive.goForward(); // (1, 0), North
// await simulator.drive.goForward(); // (2, 0), North
// await simulator.drive.turnRight(); // (2, 0), East
// await simulator.drive.goForward(); // (2, 1), East
// await simulator.drive.turnRight(); // (2, 1), South
// await simulator.drive.goForward(); // (1, 1), South
// await simulator.drive.goForward(); // (0, 1), South
// await simulator.drive.turnLeft(); // (0, 1), East
// await simulator.drive.goForward(); // (0, 2), East
// await simulator.drive.turnLeft(); // (0, 2), North
// await simulator.drive.goForward(); // (1, 2), North
// await simulator.drive.goForward(); // (2, 2), North
// await simulator.drive.turnLeft(); // (2, 2), West
// await simulator.drive.goForward(); // (2, 1), West
// await simulator.drive.goForward(); // (2, 0), West
// await simulator.drive.turnLeft(); // (2, 0), South
// await simulator.drive.goForward(); // (1, 0), South
// await simulator.drive.goForward(); // (0, 0), South
// await simulator.drive.turnLeft(); // (0, 0), East
// await simulator.drive.turnLeft(); // (0, 0), North

final message2 = AutonomyData(
state: AutonomyState.AT_DESTINATION,
task: AutonomyTask.AUTONOMY_TASK_UNDEFINED,
obstacles: [],
path: [
for (double x = 0; x < 3; x++)
for (double y = 0; y < 3; y++)
GpsCoordinates(latitude: y, longitude: x),
],
);
simulator.server.sendMessage(message2);
simulator.server.sendMessage(message2);
// final message2 = AutonomyData(
// state: AutonomyState.AT_DESTINATION,
// task: AutonomyTask.AUTONOMY_TASK_UNDEFINED,
// obstacles: [],
// path: [
// for (double x = 0; x < 3; x++)
// for (double y = 0; y < 3; y++)
// GpsCoordinates(latitude: y, longitude: x),
// ],
// );
// simulator.server.sendMessage(message2);
// simulator.server.sendMessage(message2);

await simulator.dispose();
}
// await simulator.dispose();
// }
20 changes: 10 additions & 10 deletions bin/task.dart
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
import "package:autonomy/interfaces.dart";
import "package:autonomy/simulator.dart";
import "package:autonomy/rover.dart";
import "package:burt_network/logging.dart";
import "package:burt_network/burt_network.dart";

final chair = (2, 0).toGps();
final chair = (lat: 2, long: 0).toGps();
final obstacles = <SimulatedObstacle>[
SimulatedObstacle(coordinates: (2, 0).toGps(), radius: 3),
SimulatedObstacle(coordinates: (6, -1).toGps(), radius: 3),
SimulatedObstacle(coordinates: (6, 1).toGps(), radius: 3),
SimulatedObstacle(coordinates: (lat: 6, long: -1).toGps(), radius: 3),
SimulatedObstacle(coordinates: (lat: 6, long: 1).toGps(), radius: 3),
];
// Enter in the Dashboard: Destination = (lat=7, long=0);

void main() async {
Logger.level = LogLevel.debug;
final simulator = RoverAutonomy();
simulator.detector = DetectorSimulator(collection: simulator, obstacles: obstacles);
simulator.detector = NetworkDetector(collection: simulator);
simulator.pathfinder = RoverPathfinder(collection: simulator);
simulator.orchestrator = RoverOrchestrator(collection: simulator);
simulator.drive = RoverDrive(collection: simulator, useGps: false);
simulator.drive = RoverDrive(collection: simulator, useGps: false, useImu: false);
simulator.gps = GpsSimulator(collection: simulator);
// simulator.drive = DriveSimulator(collection: simulator);
simulator.imu = ImuSimulator(collection: simulator);
simulator.video = VideoSimulator(collection: simulator);

await simulator.init();
await simulator.imu.waitForValue();
// await simulator.drive.faceNorth();
await simulator.server.waitForConnection();

}
37 changes: 18 additions & 19 deletions bin/test.dart
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
import "package:autonomy/autonomy.dart";
import "package:burt_network/logging.dart";
import "package:autonomy/src/rover/gps.dart";
import "package:autonomy/src/rover/imu.dart";
// import "package:autonomy/autonomy.dart";
// import "package:burt_network/logging.dart";

void main() async {
Logger.level = LogLevel.all;
final rover = RoverAutonomy();
rover.gps = RoverGps(collection: rover);
rover.imu = RoverImu(collection: rover);
rover.drive = RoverDrive(collection: rover, useGps: false);
// void main() async {
// Logger.level = LogLevel.all;
// final rover = RoverAutonomy();
// rover.gps = RoverGps(collection: rover);
// rover.imu = RoverImu(collection: rover);
// rover.drive = RoverDrive(collection: rover, useGps: false);

await rover.init();
// await rover.waitForReadings();
// await rover.waitForConnection();
// await rover.init();
// rover.logger.info("Waiting for readings");
// // await rover.waitForReadings();
// // await rover.waitForConnection();

rover.logger.info("Starting");
await rover.drive.turnLeft();
await rover.drive.turnRight();
// rover.logger.info("Starting");
// await rover.drive.turnLeft();
// await rover.drive.turnRight();

rover.logger.info("Done");
await rover.dispose();
}
// rover.logger.info("Done");
// await rover.dispose();
// }
27 changes: 27 additions & 0 deletions lib/constants.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
class Constants {
/// The maximum error or "tolerance" for reaching the end goal
static const double maxErrorMeters = 1;

/// How close the rover should get to a drive coordinate before
/// continuing with the path
static const double intermediateStepTolerance = 0.25;

/// The amount of meters to move per path step
static const double moveLengthMeters = 1;

/// Replan the path if the rover's position is this far away from the path
static const double replanErrorMeters = 3;

/// The IMU angle tolerance for a turn during autonomy
static const double turnEpsilon = 3;

/// The IMU angle tolerance when turning to re-correct to the
/// proper orientation before driving forward
static const double driveRealignmentEpsilon = 5;

/// The maximum time to spend waiting for the drive to reach a desired GPS coordinate.
///
/// Only applies to individual "drive forward" steps, to prevent indefinite driving
/// if it never reaches within [maxErrorMeters] of its desired position.
static const Duration driveGPSTimeout = Duration(seconds: 3, milliseconds: 53);
}
28 changes: 12 additions & 16 deletions lib/interfaces.dart
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
export "src/interfaces/a_star.dart";
export "src/interfaces/autonomy.dart";
export "src/interfaces/detector.dart";
export "src/interfaces/drive.dart";
export "src/interfaces/error.dart";
export "src/interfaces/gps.dart";
export "src/interfaces/gps_utils.dart";
export "src/interfaces/imu.dart";
export "src/interfaces/imu_utils.dart";
export "src/interfaces/pathfinding.dart";
export "src/interfaces/server.dart";
export "src/interfaces/video.dart";
export "src/interfaces/receiver.dart";
export "src/interfaces/reporter.dart";
export "src/interfaces/service.dart";
export "src/interfaces/orchestrator.dart";
export "src/autonomy_interface.dart";
export "src/detector/detector_interface.dart";
export "src/drive/drive_interface.dart";
export "src/gps/gps_interface.dart";
export "src/imu/imu_interface.dart";
export "src/imu/cardinal_direction.dart";
export "src/pathfinding/pathfinding_interface.dart";
export "src/video/video_interface.dart";
export "src/orchestrator/orchestrator_interface.dart";

export "utils.dart";
export "package:burt_network/protobuf.dart";
Loading