Skip to content

Commit 65eed40

Browse files
committed
Use explicit type const double instead of auto
1 parent 543957d commit 65eed40

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

Diff for: pid_controller/test/test_pid_controller.cpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ TEST_F(PidControllerTest, test_update_logic_feedforward_off)
279279
// error = ref - state = 100.001, error_dot = error/ds = 10000.1,
280280
// p_term = 100.001 * 1, i_term = 1.00001 * 2 = 2.00002, d_term = error/ds = 10000.1 * 3
281281
// feedforward OFF -> cmd = p_term + i_term + d_term = 30102.3
282-
auto expected_command_value = 30102.30102;
282+
const double expected_command_value = 30102.30102;
283283

284284
double actual_value = std::round(controller_->command_interfaces_[0].get_value() * 1e5) / 1e5;
285285
EXPECT_NEAR(actual_value, expected_command_value, 1e-5);
@@ -346,7 +346,7 @@ TEST_F(PidControllerTest, test_update_logic_feedforward_on_with_zero_feedforward
346346
// p_term = 100.001 * 1, i_term = 1.00001 * 2 = 2.00002, d_term = error/ds = 10000.1 * 3
347347
// feedforward ON, feedforward_gain = 0
348348
// -> cmd = p_term + i_term + d_term + feedforward_gain * ref = 30102.3 + 0 * 101.101 = 30102.3
349-
auto expected_command_value = 30102.301020;
349+
const double expected_command_value = 30102.301020;
350350

351351
double actual_value = std::round(controller_->command_interfaces_[0].get_value() * 1e5) / 1e5;
352352
EXPECT_NEAR(actual_value, expected_command_value, 1e-5);
@@ -375,7 +375,7 @@ TEST_F(PidControllerTest, test_update_logic_chainable_not_use_subscriber_update)
375375
EXPECT_EQ(*(controller_->control_mode_.readFromRT()), feedforward_mode_type::OFF);
376376

377377
// update reference interface which will be used for calculation
378-
auto ref_interface_value = 5.0;
378+
const double ref_interface_value = 5.0;
379379
controller_->reference_interfaces_[0] = ref_interface_value;
380380

381381
// publish a command message which should be ignored as chain mode is on
@@ -403,7 +403,7 @@ TEST_F(PidControllerTest, test_update_logic_chainable_not_use_subscriber_update)
403403
// i_term = error * ds * i_gain = 3.9 * 0.01 * 2.0 = 0.078,
404404
// d_term = error_dot * d_gain = 390.0 * 3.0 = 1170.0
405405
// feedforward OFF -> cmd = p_term + i_term + d_term = 3.9 + 0.078 + 1170.0 = 1173.978
406-
auto expected_command_value = 1173.978;
406+
const double expected_command_value = 1173.978;
407407

408408
EXPECT_EQ(controller_->command_interfaces_[0].get_value(), expected_command_value);
409409
}
@@ -431,7 +431,7 @@ TEST_F(PidControllerTest, test_update_logic_angle_wraparound_off)
431431
controller_interface::return_type::OK);
432432

433433
// check the result of the commands - the values are not wrapped
434-
auto expected_command_value = 2679.078;
434+
const double expected_command_value = 2679.078;
435435
EXPECT_NEAR(controller_->command_interfaces_[0].get_value(), expected_command_value, 1e-5);
436436
}
437437

@@ -462,7 +462,7 @@ TEST_F(PidControllerTest, test_update_logic_angle_wraparound_on)
462462
controller_interface::return_type::OK);
463463

464464
// Check the command value
465-
auto expected_command_value = 787.713559;
465+
const double expected_command_value = 787.713559;
466466
EXPECT_NEAR(controller_->command_interfaces_[0].get_value(), expected_command_value, 1e-5);
467467
}
468468

Diff for: pid_controller/test/test_pid_controller_dual_interface.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,8 @@ TEST_F(PidControllerDualInterfaceTest, test_chained_feedforward_with_gain_dual_i
9494
controller_interface::return_type::OK);
9595

9696
// check the commands
97-
auto joint1_expected_cmd = 8.915;
98-
auto joint2_expected_cmd = 9.915;
97+
const double joint1_expected_cmd = 8.915;
98+
const double joint2_expected_cmd = 9.915;
9999
ASSERT_EQ(controller_->command_interfaces_[0].get_value(), joint1_expected_cmd);
100100
ASSERT_EQ(controller_->command_interfaces_[1].get_value(), joint2_expected_cmd);
101101
}

0 commit comments

Comments
 (0)