diff --git a/components/base/sensorcontrolled/sensorcontrolled_test.go b/components/base/sensorcontrolled/sensorcontrolled_test.go index 13a22f705f1..10828ccbd85 100644 --- a/components/base/sensorcontrolled/sensorcontrolled_test.go +++ b/components/base/sensorcontrolled/sensorcontrolled_test.go @@ -534,4 +534,10 @@ func TestSensorBaseDoCommand(t *testing.T) { resp, err := b.DoCommand(ctx, req) test.That(t, err, test.ShouldBeNil) test.That(t, resp, test.ShouldResemble, expectedeMap) + + emptyMap := make(map[string]interface{}) + req["get_tuned_pid"] = false + resp, err = b.DoCommand(ctx, req) + test.That(t, err, test.ShouldBeNil) + test.That(t, resp, test.ShouldResemble, emptyMap) } diff --git a/components/motor/gpio/controlled_test.go b/components/motor/gpio/controlled_test.go index fd53032b653..9b40a805175 100644 --- a/components/motor/gpio/controlled_test.go +++ b/components/motor/gpio/controlled_test.go @@ -114,4 +114,10 @@ func TestControlledMotorCreation(t *testing.T) { resp, err := m.DoCommand(context.Background(), req) test.That(t, err, test.ShouldBeNil) test.That(t, resp, test.ShouldResemble, expectedeMap) + + emptyMap := make(map[string]interface{}) + req["get_tuned_pid"] = false + resp, err = cm.DoCommand(context.Background(), req) + test.That(t, err, test.ShouldBeNil) + test.That(t, resp, test.ShouldResemble, emptyMap) } diff --git a/control/setup_control.go b/control/setup_control.go index deb3ef86e66..eba74b25c9d 100644 --- a/control/setup_control.go +++ b/control/setup_control.go @@ -482,12 +482,9 @@ func UpdateTrapzBlock(ctx context.Context, name string, maxVel float64, dependsO // TunedPIDErr returns an error with the stored tuned PID values. func TunedPIDErr(name string, tunedVals []PIDConfig) error { var tunedStr string - for i, pid := range tunedVals { - if i > 0 { - tunedStr += `, ` - } + for _, pid := range tunedVals { if !pid.NeedsAutoTuning() { - tunedStr += fmt.Sprintf(`{"p": %v, "i": %v, "d": %v, "type": "%v"}`, pid.P, pid.I, pid.D, pid.Type) + tunedStr += fmt.Sprintf(`{"p": %v, "i": %v, "d": %v, "type": "%v"} `, pid.P, pid.I, pid.D, pid.Type) } } return fmt.Errorf(`%v has been tuned, please copy the following control values into your config: %v`, name, tunedStr)