Skip to content

Commit

Permalink
added GetLatestMapInfo testing to integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
pstrutz committed Jul 5, 2023
1 parent 6037e4f commit 2df48ca
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,25 @@ const (
)

// Checks the cartographer map and confirms there at least 100 map points.
func testCartographerMap(t *testing.T, svc slam.Service) {
func testCartographerMap(t *testing.T, svc slam.Service, localizationMode bool) {
timestamp1, err := svc.GetLatestMapInfo(context.Background())
test.That(t, err, test.ShouldBeNil)
pcd, err := slam.GetPointCloudMapFull(context.Background(), svc)
test.That(t, err, test.ShouldBeNil)
test.That(t, pcd, test.ShouldNotBeNil)
timestamp2, err := svc.GetLatestMapInfo(context.Background())
test.That(t, err, test.ShouldBeNil)

if localizationMode == true {
test.That(t, timestamp1, test.ShouldResemble, timestamp2)
} else {
test.That(t, timestamp2.After(timestamp1), test.ShouldBeTrue)
}

pointcloud, _ := pointcloud.ReadPCD(bytes.NewReader(pcd))
t.Logf("Pointcloud points: %v", pointcloud.Size())
test.That(t, pointcloud.Size(), test.ShouldBeGreaterThanOrEqualTo, 100)

}

// Checks the cartographer position within a defined tolerance.
Expand Down Expand Up @@ -156,7 +167,7 @@ func integrationtestHelperCartographer(t *testing.T, subAlgo viamcartographer.Su
}

testCartographerPosition(t, svc, attrCfg.Sensors[0])
testCartographerMap(t, svc)
testCartographerMap(t, svc, false)

// Close out slam service
test.That(t, svc.Close(context.Background()), test.ShouldBeNil)
Expand Down Expand Up @@ -230,7 +241,7 @@ func integrationtestHelperCartographer(t *testing.T, subAlgo viamcartographer.Su
}

testCartographerPosition(t, svc, "") // leaving this empty because cartographer does not interpret the component reference in offline mode
testCartographerMap(t, svc)
testCartographerMap(t, svc, false)

// Sleep to ensure cartographer saves at least one map
time.Sleep(time.Second * time.Duration(*attrCfg.MapRateSec))
Expand Down Expand Up @@ -307,7 +318,7 @@ func integrationtestHelperCartographer(t *testing.T, subAlgo viamcartographer.Su
}

testCartographerPosition(t, svc, attrCfg.Sensors[0])
testCartographerMap(t, svc)
testCartographerMap(t, svc, true)

// Remove maps so that testing is done on the map generated by the internal map
test.That(t, testhelper.ResetFolder(dataDir+"/map"), test.ShouldBeNil)
Expand Down Expand Up @@ -385,7 +396,7 @@ func integrationtestHelperCartographer(t *testing.T, subAlgo viamcartographer.Su
}

testCartographerPosition(t, svc, attrCfg.Sensors[0])
testCartographerMap(t, svc)
testCartographerMap(t, svc, false)

// Close out slam service
test.That(t, svc.Close(context.Background()), test.ShouldBeNil)
Expand Down

0 comments on commit 2df48ca

Please sign in to comment.