From 2df48caf0c21c8ab14cbf17f4d9a85a497587399 Mon Sep 17 00:00:00 2001 From: PStrutz Date: Wed, 5 Jul 2023 13:13:09 -0400 Subject: [PATCH] added GetLatestMapInfo testing to integration tests --- integration_test.go | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/integration_test.go b/integration_test.go index 14d8ae43..3dd12b82 100644 --- a/integration_test.go +++ b/integration_test.go @@ -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. @@ -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) @@ -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)) @@ -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) @@ -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)