Skip to content

Commit

Permalink
Add check for Position Supported in dualgps creator (#4527)
Browse files Browse the repository at this point in the history
Co-authored-by: martha-johnston <[email protected]>
  • Loading branch information
2 people authored and hexbabe committed Nov 6, 2024
1 parent 59c7a89 commit f90689b
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions components/movementsensor/dualgps/dualgps.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ package dualgps
import (
"context"
"errors"
"fmt"
"math"
"sync"

"github.com/golang/geo/r3"
geo "github.com/kellydunn/golang-geo"
"go.uber.org/multierr"

"go.viam.com/rdk/components/movementsensor"
"go.viam.com/rdk/logging"
Expand Down Expand Up @@ -114,14 +116,41 @@ func (dg *dualGPS) Reconfigure(ctx context.Context, deps resource.Dependencies,
if err != nil {
return err
}

firstProps, err := first.Properties(ctx, nil)
if err != nil {
return err
}
dg.gps1 = first

second, err := movementsensor.FromDependencies(deps, newConf.Gps2)
if err != nil {
return err
}
secondProps, err := second.Properties(ctx, nil)
if err != nil {
return err
}
dg.gps2 = second

var errs error
if !firstProps.PositionSupported {
errs = multierr.Combine(
errs,
fmt.Errorf(
"configured movement sensor %v does not support reporting its Position, it cannot be used for dual-gps calculations",
first.Name().ShortName()))
}
if !secondProps.PositionSupported {
errs = multierr.Combine(errs,
fmt.Errorf(
"configured movement sensor %v does not support reporting its Position, it cannot be used for dual-gps calculations",
second.Name().ShortName()))
}
if errs != nil {
return errs
}

dg.offset = defaultOffsetDegrees
if newConf.Offset != nil {
dg.offset = *newConf.Offset
Expand Down

0 comments on commit f90689b

Please sign in to comment.