Skip to content

Commit

Permalink
Fixed some bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
Levi-Lesches committed Jul 28, 2023
1 parent 254d8b8 commit bb8ddb1
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 16 deletions.
29 changes: 17 additions & 12 deletions lib/src/collection.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,15 @@ import "camera.dart";
/// Default details for a camera
///
/// Used when first creating the camera objects
final defaultDetails = CameraDetails(resolutionWidth: 300, resolutionHeight: 300, quality: 50, fps: 24, status: CameraStatus.CAMERA_ENABLED);
CameraDetails getDefaultDetails(CameraName name) => CameraDetails(
name: name,
resolutionWidth: 300,
resolutionHeight: 300,
quality: 50,
fps: 24,
status:
CameraStatus.CAMERA_ENABLED,
);

/// Returns the camera depending on device program is running
///
Expand All @@ -23,10 +31,11 @@ class VideoCollection{
/// Holds a list of available cameras
Map<CameraName, CameraManager> cameras = {
for (final name in CameraName.values)
name: CameraManager(
camera: getCamera(name),
details: defaultDetails,
)
if (name != CameraName.CAMERA_NAME_UNDEFINED)
name: CameraManager(
camera: getCamera(name),
details: getDefaultDetails(name),
)
};

/// [VideoServer] to send messages through
Expand All @@ -36,16 +45,12 @@ class VideoCollection{

/// Function to initiliaze cameras
Future<void> init() async{
BurtLogger.level = LogLevel.debug;
await videoServer.init();
logger.info("Starting Cameras...");
await connectCameras();
}

/// Connects to all [cameras]
Future<void> connectCameras() async{
for(final camera in cameras.values){
for (final camera in cameras.values) {
await camera.init();
}
logger.info("Video program initialized");
}
}

Expand Down
4 changes: 2 additions & 2 deletions lib/src/constants.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import "package:burt_network/burt_network.dart";
/// Map for MAC or LINUX devices
Map<CameraName, String> cameraNames = {
CameraName.ROVER_FRONT: "/dev/realsense_rgb",
//CameraName.ROVER_REAR: "...",
CameraName.ROVER_REAR: "...",
CameraName.AUTONOMY_DEPTH: "/dev/realsense_depth",
CameraName.SUBSYSTEM1: "/dev/subsystem1",
CameraName.SUBSYSTEM2: "/dev/subsystem2",
Expand All @@ -17,7 +17,7 @@ Map<CameraName, String> cameraNames = {
/// Map for WINDOWS devices
Map<CameraName, int> cameraIndexes = {
CameraName.ROVER_FRONT: 0,
//CameraName.ROVER_REAR: 1,
CameraName.ROVER_REAR: 1,
CameraName.AUTONOMY_DEPTH: 1,
CameraName.SUBSYSTEM1: 2,
CameraName.SUBSYSTEM2: 3,
Expand Down
4 changes: 2 additions & 2 deletions lib/src/udp.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ class VideoServer extends ServerSocket{
void onMessage(WrappedMessage wrapper) {
// ignore message if not a video message
if(wrapper.name != VideoCommand().messageName) return;
// Return the message to tell dashboard the message was received
sendMessage(wrapper);
final command = VideoCommand.fromBuffer(wrapper.data);
// Return the message to tell dashboard the message was received
sendMessage(command);
// Send LOADING before making any changes
sendMessage(VideoData(id: command.id, details: CameraDetails(status: CameraStatus.CAMERA_LOADING)));
// Change the settings
Expand Down

0 comments on commit bb8ddb1

Please sign in to comment.