Skip to content

Commit 7ee70ac

Browse files
committed
fix: missing array check on incoming trajectory points
1 parent 121e77a commit 7ee70ac

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

src/main.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,11 @@ func run(service roverlib.Service, configuration *roverlib.ServiceConfiguration)
7272
log.Info().Msgf("Imaging service captured a %d by %d image", imagingData.Trajectory.Width, imagingData.Trajectory.Height)
7373

7474
// Print the X and Y coordinates of the middle point of the track that Imaging has detected
75-
log.Info().Msgf("The X: %d and Y: %d values of the middle point of the track", imagingData.Trajectory.Points[0].X, imagingData.Trajectory.Points[0].Y)
75+
if len(imagingData.Trajectory.Points) > 0 {
76+
log.Info().Msgf("The X: %d and Y: %d values of the middle point of the track", imagingData.Trajectory.Points[0].X, imagingData.Trajectory.Points[0].Y)
77+
} else {
78+
log.Info().Msgf("imaging could didn't detect track edges. Is the Rover on the track?")
79+
}
7680

7781
// This value holds the steering position that we want to pass to the servo (-1 = left, 0 = center, 1 = right)
7882
steerPosition := float32(-0.5)

0 commit comments

Comments
 (0)