Skip to content

Commit c10eab2

Browse files
authored
RSDK-4074 - make errEndOfDataset public (#2654)
1 parent 8cdecaf commit c10eab2

File tree

3 files changed

+14
-12
lines changed

3 files changed

+14
-12
lines changed

components/camera/replaypcd/replaypcd.go

+5-3
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,10 @@ const (
3636

3737
var (
3838
// model is the model of a replay camera.
39-
model = resource.DefaultModelFamily.WithModel("replay_pcd")
40-
errEndOfDataset = errors.New("reached end of dataset")
39+
model = resource.DefaultModelFamily.WithModel("replay_pcd")
40+
41+
// ErrEndOfDataset represents that the replay sensor has reached the end of the dataset.
42+
ErrEndOfDataset = errors.New("reached end of dataset")
4143
)
4244

4345
func init() {
@@ -178,7 +180,7 @@ func (replay *pcdCamera) NextPointCloud(ctx context.Context) (pointcloud.PointCl
178180
}
179181

180182
if len(resp.GetData()) == 0 {
181-
return nil, errEndOfDataset
183+
return nil, ErrEndOfDataset
182184
}
183185
replay.lastData = resp.GetLast()
184186

components/camera/replaypcd/replaypcd_test.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ func TestNextPointCloud(t *testing.T) {
268268
// Confirm the end of the dataset was reached when expected
269269
pc, err := replayCamera.NextPointCloud(ctx)
270270
test.That(t, err, test.ShouldNotBeNil)
271-
test.That(t, err.Error(), test.ShouldContainSubstring, errEndOfDataset.Error())
271+
test.That(t, err.Error(), test.ShouldContainSubstring, ErrEndOfDataset.Error())
272272
test.That(t, pc, test.ShouldBeNil)
273273

274274
err = replayCamera.Close(ctx)
@@ -303,7 +303,7 @@ func TestLiveNextPointCloud(t *testing.T) {
303303
pc, err := replayCamera.NextPointCloud(ctx)
304304
if i == numPCDFiles {
305305
test.That(t, err, test.ShouldNotBeNil)
306-
test.That(t, err.Error(), test.ShouldContainSubstring, errEndOfDataset.Error())
306+
test.That(t, err.Error(), test.ShouldContainSubstring, ErrEndOfDataset.Error())
307307
test.That(t, pc, test.ShouldBeNil)
308308

309309
// Add new files for future processing
@@ -544,7 +544,7 @@ func TestNextPointCloudTimestamps(t *testing.T) {
544544
// Confirm the end of the dataset was reached when expected
545545
pc, err := replayCamera.NextPointCloud(ctx)
546546
test.That(t, err, test.ShouldNotBeNil)
547-
test.That(t, err.Error(), test.ShouldContainSubstring, errEndOfDataset.Error())
547+
test.That(t, err.Error(), test.ShouldContainSubstring, ErrEndOfDataset.Error())
548548
test.That(t, pc, test.ShouldBeNil)
549549

550550
err = replayCamera.Close(ctx)
@@ -610,7 +610,7 @@ func TestReconfigure(t *testing.T) {
610610
// Confirm the end of the dataset was reached when expected
611611
pc, err := replayCamera.NextPointCloud(ctx)
612612
test.That(t, err, test.ShouldNotBeNil)
613-
test.That(t, err.Error(), test.ShouldContainSubstring, errEndOfDataset.Error())
613+
test.That(t, err.Error(), test.ShouldContainSubstring, ErrEndOfDataset.Error())
614614
test.That(t, pc, test.ShouldBeNil)
615615

616616
err = replayCamera.Close(ctx)

components/camera/replaypcd/replaypcd_utils_test.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -237,12 +237,12 @@ func resourcesFromDeps(t *testing.T, r robot.Robot, deps []string) resource.Depe
237237
func getNextDataAfterFilter(filter *datapb.Filter, last string) (int, error) {
238238
// Basic component part (source) filter
239239
if filter.ComponentName != "" && filter.ComponentName != "source" {
240-
return 0, errEndOfDataset
240+
return 0, ErrEndOfDataset
241241
}
242242

243243
// Basic robot_id filter
244244
if filter.RobotId != "" && filter.RobotId != "robot_id" {
245-
return 0, errEndOfDataset
245+
return 0, ErrEndOfDataset
246246
}
247247

248248
// Apply the time-based filter based on the seconds value in the start and end fields. Because artifacts
@@ -274,20 +274,20 @@ func getFile(i, end int) (int, error) {
274274
if i < end {
275275
return i, nil
276276
}
277-
return 0, errEndOfDataset
277+
return 0, ErrEndOfDataset
278278
}
279279

280280
// getCompressedBytesFromArtifact will return an array of bytes from the
281281
// provided artifact path, compressing them using gzip.
282282
func getCompressedBytesFromArtifact(inputPath string) ([]byte, error) {
283283
artifactPath, err := artifact.Path(inputPath)
284284
if err != nil {
285-
return nil, errEndOfDataset
285+
return nil, ErrEndOfDataset
286286
}
287287
path := filepath.Clean(artifactPath)
288288
data, err := os.ReadFile(path)
289289
if err != nil {
290-
return nil, errEndOfDataset
290+
return nil, ErrEndOfDataset
291291
}
292292

293293
var dataBuf bytes.Buffer

0 commit comments

Comments
 (0)