Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
nicksanford committed Nov 18, 2024
1 parent 0199242 commit 33c6fab
Show file tree
Hide file tree
Showing 3 changed files with 405 additions and 387 deletions.
68 changes: 0 additions & 68 deletions data/capture_file.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import (
"google.golang.org/protobuf/types/known/anypb"

"go.viam.com/rdk/resource"
"go.viam.com/rdk/utils"
)

// TODO Data-343: Reorganize this into a more standard interface/package, and add tests.
Expand Down Expand Up @@ -240,73 +239,6 @@ func getFileTimestampName() string {
return time.Now().Format(time.RFC3339Nano)
}

// CaptureType represents captured tabular or binary data.
type CaptureType int

const (
// CaptureTypeUnspecified represents that the data type of the captured data was not specified.
CaptureTypeUnspecified CaptureType = iota
// CaptureTypeTabular represents that the data type of the captured data is tabular.
CaptureTypeTabular
// CaptureTypeBinary represents that the data type of the captured data is binary.
CaptureTypeBinary
)

// ToProto converts a DataType into a v1.DataType.
func (dt CaptureType) ToProto() v1.DataType {
switch dt {
case CaptureTypeTabular:
return v1.DataType_DATA_TYPE_TABULAR_SENSOR
case CaptureTypeBinary:
return v1.DataType_DATA_TYPE_BINARY_SENSOR
case CaptureTypeUnspecified:
return v1.DataType_DATA_TYPE_UNSPECIFIED
default:
return v1.DataType_DATA_TYPE_UNSPECIFIED
}
}

// GetDataType returns the DataType of the method.
func GetDataType(methodName string) CaptureType {
switch methodName {
case nextPointCloud, readImage, pointCloudMap, GetImages:
return CaptureTypeBinary
default:
return CaptureTypeTabular
}
}

// getFileExt gets the file extension for a capture file.
func getFileExt(dataType CaptureType, methodName string, parameters map[string]string) string {
defaultFileExt := ""
switch dataType {
case CaptureTypeTabular:
return ".dat"
case CaptureTypeBinary:
if methodName == nextPointCloud {
return ".pcd"
}
if methodName == readImage {
// TODO: Add explicit file extensions for all mime types.
switch parameters["mime_type"] {
case utils.MimeTypeJPEG:
return ".jpeg"
case utils.MimeTypePNG:
return ".png"
case utils.MimeTypePCD:
return ".pcd"
default:
return defaultFileExt
}
}
case CaptureTypeUnspecified:
return defaultFileExt
default:
return defaultFileExt
}
return defaultFileExt
}

// SensorDataFromCaptureFilePath returns all readings in the file at filePath.
// NOTE: (Nick S) At time of writing this is only used in tests.
func SensorDataFromCaptureFilePath(filePath string) ([]*v1.SensorData, error) {
Expand Down
Loading

0 comments on commit 33c6fab

Please sign in to comment.