From 8c5d8caa70e5639f033366c7e9884edd0b0f79b0 Mon Sep 17 00:00:00 2001 From: jeremyrhyde <34897732+jeremyrhyde@users.noreply.github.com> Date: Mon, 11 Sep 2023 15:28:41 -0400 Subject: [PATCH] Rsdk 4495 integration tests (Updating comments) (#263) --- sensorprocess/imusensorprocess.go | 28 ++++++++++++++-------------- sensorprocess/lidarsensorprocess.go | 10 +++++----- testhelper/integrationtesthelper.go | 8 ++++---- 3 files changed, 23 insertions(+), 23 deletions(-) diff --git a/sensorprocess/imusensorprocess.go b/sensorprocess/imusensorprocess.go index cdd9e688..34615a85 100644 --- a/sensorprocess/imusensorprocess.go +++ b/sensorprocess/imusensorprocess.go @@ -15,7 +15,7 @@ import ( ) // StartIMU polls the IMU to get the next sensor reading and adds it to the cartofacade. -// stops when the context is Done. +// Stops when the context is Done. func (config *Config) StartIMU(ctx context.Context) bool { for { select { @@ -29,7 +29,7 @@ func (config *Config) StartIMU(ctx context.Context) bool { } } -// addIMUReading adds a imu reading to the cartofacade, using the lidar's data rate to determine whether to run in +// addIMUReading adds an IMU reading to the cartofacade, using the lidar's data rate to determine whether to run in // offline or online mode. func (config *Config) addIMUReading(ctx context.Context) bool { if config.LidarDataRateMsec != 0 { @@ -38,24 +38,24 @@ func (config *Config) addIMUReading(ctx context.Context) bool { return config.addIMUReadingInOffline(ctx) } -// addIMUReadingInOnline ensure the most recent imu scan, after corresponding lidar scans, gets processed by cartographer. +// addIMUReadingInOnline ensures the most recent IMU scan, after corresponding lidar scans, gets processed by cartographer. func (config *Config) addIMUReadingInOnline(ctx context.Context) bool { - // get next imu data response + // get next IMU data response tsr, status, err := getTimedIMUSensorReading(ctx, config) if err != nil { return status } - // parse imu reading + // parse IMU reading sr := cartofacade.IMUReading{ LinearAcceleration: tsr.LinearAcceleration, AngularVelocity: tsr.AngularVelocity, } - // update stored imu time + // update stored IMU time config.updateMutexProtectedIMUData(tsr.ReadingTime, sr) - // add imu data to cartographer and sleep remainder of time interval + // add IMU data to cartographer and sleep remainder of time interval timeToSleep := config.tryAddIMUReading(ctx, sr, tsr.ReadingTime) time.Sleep(time.Duration(timeToSleep) * time.Millisecond) config.Logger.Debugf("imu sleep for %vms", timeToSleep) @@ -63,7 +63,7 @@ func (config *Config) addIMUReadingInOnline(ctx context.Context) bool { return false } -// addIMUReadingInOffline ensures imu scans get added in a time ordered series with any desired lidar scans without skipping any. +// addIMUReadingInOffline ensures IMU scans get added in a time ordered series with any desired lidar scans without skipping any. func (config *Config) addIMUReadingInOffline(ctx context.Context) bool { // extract current lidar reading time for ordering data ingestion config.Mutex.Lock() @@ -71,7 +71,7 @@ func (config *Config) addIMUReadingInOffline(ctx context.Context) bool { config.Mutex.Unlock() if sensorProcessStartTime != defaultTime && config.currentIMUData.time != defaultTime { - // skip adding measurement if imu data has been defined but occurs before first lidar data + // skip adding measurement if IMU data has been defined but occurs before first lidar data if sensorProcessStartTime.Sub(config.currentIMUData.time).Milliseconds() >= 0 { time.Sleep(10 * time.Millisecond) return false @@ -81,21 +81,21 @@ func (config *Config) addIMUReadingInOffline(ctx context.Context) bool { config.tryAddIMUReadingUntilSuccess(ctx, config.currentIMUData.data, config.currentIMUData.time) } - // get next imu data response + // get next IMU data response tsr, status, err := getTimedIMUSensorReading(ctx, config) if err != nil { return status } - // parse imu reading + // parse IMU reading sr := cartofacade.IMUReading{ LinearAcceleration: tsr.LinearAcceleration, AngularVelocity: tsr.AngularVelocity, } - // TODO: Remove dropping out of order imu readings after DATA-1812 has been complete + // TODO: Remove dropping out of order IMU readings after DATA-1812 has been complete // JIRA Ticket: https://viam.atlassian.net/browse/DATA-1812 - // update current imu data and time + // update current IMU data and time if config.currentIMUData.time.Sub(tsr.ReadingTime).Milliseconds() < 0 { config.updateMutexProtectedIMUData(tsr.ReadingTime, sr) } else { @@ -144,7 +144,7 @@ func (config *Config) tryAddIMUReading(ctx context.Context, reading cartofacade. return int(math.Max(0, float64(config.IMUDataRateMsec-timeElapsedMs))) } -// getTimedIMUSensorReading returns the next imu reading if available along with a status denoting if the end of dataset has been reached. +// getTimedIMUSensorReading returns the next IMU reading if available along with a status denoting if the end of dataset has been reached. func getTimedIMUSensorReading(ctx context.Context, config *Config) (sensors.TimedIMUSensorReadingResponse, bool, error) { tsr, err := config.IMU.TimedIMUSensorReading(ctx) if err != nil { diff --git a/sensorprocess/lidarsensorprocess.go b/sensorprocess/lidarsensorprocess.go index 3e17b8ea..10263504 100644 --- a/sensorprocess/lidarsensorprocess.go +++ b/sensorprocess/lidarsensorprocess.go @@ -15,7 +15,7 @@ import ( ) // StartLidar polls the lidar to get the next sensor reading and adds it to the cartofacade. -// stops when the context is Done. +// Stops when the context is Done. func (config *Config) StartLidar(ctx context.Context) bool { for { select { @@ -43,7 +43,7 @@ func (config *Config) addLidarReading(ctx context.Context) bool { return config.addLidarReadingsInOffline(ctx) } -// addLidarReadingsInOnline ensure the most recent lidar scan, after any corresponding imu scans, gets processed by cartographer. +// addLidarReadingsInOnline ensures the most recent lidar scan, after any corresponding IMU scans, gets processed by cartographer. func (config *Config) addLidarReadingsInOnline(ctx context.Context) bool { // get next lidar data response tsr, status, err := getTimedLidarSensorReading(ctx, config) @@ -62,14 +62,14 @@ func (config *Config) addLidarReadingsInOnline(ctx context.Context) bool { return false } -// addLidarReadingsInOffline ensures lidar scans get added in a time ordered series with any desired imu scans without skipping any. +// addLidarReadingsInOffline ensures lidar scans get added in a time ordered series with any desired IMU scans without skipping any. func (config *Config) addLidarReadingsInOffline(ctx context.Context) bool { - // Extract current imu reading time for ordering data ingestion + // Extract current IMU reading time for ordering data ingestion config.Mutex.Lock() currentIMUTime := config.currentIMUData.time config.Mutex.Unlock() - // If an IMU exists, skip adding measurement until the current lidar time is after the current imu timestamp + // If an IMU exists, skip adding measurement until the current lidar time is after the current IMU timestamp if config.IMUName != "" && config.currentLidarData.time.Sub(currentIMUTime).Milliseconds() > 0 { time.Sleep(10 * time.Millisecond) return false diff --git a/testhelper/integrationtesthelper.go b/testhelper/integrationtesthelper.go index b8315423..67261049 100644 --- a/testhelper/integrationtesthelper.go +++ b/testhelper/integrationtesthelper.go @@ -63,7 +63,7 @@ type TimeTracker struct { // ReadingTime incremented by the sensorReadingInterval. // The Replay sensor field of the mock readings will match the replay parameter. // When the end of the mock lidar readings is reached, the done channel -// is written to once so the caller can detect all lidar readings have been emitted +// is written to once so the caller can detect when all lidar readings have been emitted // from the mock. This is intended to match the same "end of dataset" behavior of a // replay sensor. // It is important to provide deterministic time information to cartographer to @@ -76,7 +76,7 @@ func IntegrationTimedLidarSensor( done chan struct{}, timeTracker *TimeTracker, ) (sensors.TimedLidarSensor, error) { - // Check required amount of lidar data is present + // Check that the required amount of lidar data is present err := mockLidarReadingsValid() if err != nil { return nil, err @@ -143,7 +143,7 @@ func IntegrationTimedLidarSensor( // ReadingTime incremented by the sensorReadingInterval. // The Replay sensor field of the mock readings will match the replay parameter. // When the end of the mock IMU readings is reached, the done channel -// is written to once so the caller can detect all IMU readings have been emitted +// is written to once so the caller can detect when all IMU readings have been emitted // from the mock. This is intended to match the same "end of dataset" behavior of a // replay sensor. // It is important to provide deterministic time information to cartographer to @@ -162,7 +162,7 @@ func IntegrationTimedIMUSensor( return nil, nil } - // Check required amount of IMU data is present and creates mock dataset from provided mock data artifact file. + // Check that the required amount of IMU data is present and create a mock dataset from provided mock data artifact file. mockDataset, err := mockIMUReadingsValid(t) if err != nil { return nil, err