Skip to content

Commit

Permalink
RSDK-8926: Rover canary motor test fail because failure to set pins (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
martha-johnston authored Nov 14, 2024
1 parent 3439e38 commit 8bbc629
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
4 changes: 2 additions & 2 deletions components/motor/gpio/basic.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ func (m *Motor) setPWM(ctx context.Context, powerPct float64, extra map[string]i
switch m.motorType {
case ABPwm, DirectionPwm:
if math.Abs(powerPct) <= 0.001 {
return m.turnOff(ctx, extra)
return m.turnOff(context.Background(), extra)
}
pwmPin = m.PWM
case AB:
Expand Down Expand Up @@ -310,7 +310,7 @@ func (m *Motor) Stop(ctx context.Context, extra map[string]interface{}) error {
m.opMgr.CancelRunning(ctx)
m.mu.Lock()
defer m.mu.Unlock()
return m.setPWM(ctx, 0, extra)
return m.setPWM(context.Background(), 0, extra)
}

// IsMoving returns if the motor is currently on or off.
Expand Down
13 changes: 7 additions & 6 deletions robot/impl/local_robot.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,25 +193,26 @@ func (r *localRobot) StopAll(ctx context.Context, extra map[resource.Name]map[st
}

// Stop all stoppable resources
resourceErrs := []string{}
resourceErrs := make(map[string]error)
for _, name := range r.ResourceNames() {
res, err := r.ResourceByName(name)
if err != nil {
resourceErrs = append(resourceErrs, name.Name)
resourceErrs[name.Name] = err
continue
}

if actuator, ok := res.(resource.Actuator); ok {
if err := actuator.Stop(ctx, extra[name]); err != nil {
resourceErrs = append(resourceErrs, name.Name)
resourceErrs[name.Name] = err
}
}
}

if len(resourceErrs) > 0 {
return errors.Errorf("failed to stop components named %s", strings.Join(resourceErrs, ","))
var errs error
for k, v := range resourceErrs {
errs = multierr.Combine(errs, errors.Errorf("failed to stop component named %s with error %v", k, v))
}
return nil
return errs
}

// Config returns a config representing the current state of the robot.
Expand Down

0 comments on commit 8bbc629

Please sign in to comment.