handleDrag method
- AutonomyCell data,
- MapCellData cell
Handles when a specific tile was dropped onto a grid cell.
- If it's a destination tile, then the rover will go there
- If it's an obstacle tile, the rover will avoid it
- If it's a marker tile, draws or removes a Dashboard marker
Implementation
void handleDrag(AutonomyCell data, MapCellData cell) {
switch (data) {
case AutonomyCell.destination:
if (models.rover.isConnected && RoverStatus.AUTONOMOUS != models.rover.status.value) {
models.home.setMessage(
severity: Severity.error,
text: "You must be in autonomy mode",
);
return;
}
final command = AutonomyCommand(
task: AutonomyTask.GPS_ONLY,
destination: GpsCoordinates(
latitude: cell.coordinates.latitude,
longitude: cell.coordinates.longitude,
),
);
commandBuilder.submit(command);
case AutonomyCell.obstacle:
final obstacleData = AutonomyData(obstacles: [cell.coordinates]);
models.sockets.autonomy.sendMessage(obstacleData);
case AutonomyCell.marker:
toggleMarker(cell);
case AutonomyCell.rover:
break;
case AutonomyCell.path:
break;
case AutonomyCell.empty:
break;
}
}