Skip to content

Commit

Permalink
use (void) to discard set_value return statement
Browse files Browse the repository at this point in the history
  • Loading branch information
saikishor committed Jan 16, 2025
1 parent 3deb8b2 commit 7cd44c2
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 66 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ TEST_F(ChainableControllerInterfaceTest, setting_chained_mode)
EXPECT_FALSE(controller.is_in_chained_mode());

// Success setting chained mode
reference_interfaces[0]->set_value(0.0);
(void)reference_interfaces[0]->set_value(0.0);

EXPECT_TRUE(controller.set_chained_mode(true));
EXPECT_TRUE(controller.is_in_chained_mode());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ controller_interface::return_type TestChainableController::update_and_write_comm

for (size_t i = 0; i < command_interfaces_.size(); ++i)
{
command_interfaces_[i].set_value(
(void)command_interfaces_[i].set_value(
reference_interfaces_[i] - state_interfaces_[i].get_value<double>().value());
}
// If there is a command interface then integrate and set it to the exported state interface data
Expand Down
4 changes: 2 additions & 2 deletions controller_manager/test/test_controller/test_controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ controller_interface::return_type TestController::update(
// set value to hardware to produce and test different behaviors there
if (!std::isnan(set_first_command_interface_value_to))
{
command_interfaces_[0].set_value(set_first_command_interface_value_to);
(void)command_interfaces_[0].set_value(set_first_command_interface_value_to);
// reset to be easier to test
set_first_command_interface_value_to = std::numeric_limits<double>::quiet_NaN();
}
Expand All @@ -90,7 +90,7 @@ controller_interface::return_type TestController::update(
RCLCPP_DEBUG(
get_node()->get_logger(), "Setting value of command interface '%s' to %f",
command_interfaces_[i].get_name().c_str(), external_commands_for_testing_[i]);
command_interfaces_[i].set_value(external_commands_for_testing_[i]);
(void)command_interfaces_[i].set_value(external_commands_for_testing_[i]);
}
}

Expand Down
108 changes: 54 additions & 54 deletions hardware_interface/test/mock_components/test_generic_system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -877,10 +877,10 @@ void generic_system_functional_test(
ASSERT_TRUE(std::isnan(j2v_c.get_value<double>().value()));

// set some new values in commands
j1p_c.set_value(0.11);
j1v_c.set_value(0.22);
j2p_c.set_value(0.33);
j2v_c.set_value(0.44);
(void)j1p_c.set_value(0.11);
(void)j1v_c.set_value(0.22);
(void)j2p_c.set_value(0.33);
(void)j2v_c.set_value(0.44);

// State values should not be changed
ASSERT_EQ(3.45, j1p_s.get_value<double>().value());
Expand Down Expand Up @@ -915,10 +915,10 @@ void generic_system_functional_test(
ASSERT_EQ(0.44, j2v_c.get_value<double>().value());

// set some new values in commands
j1p_c.set_value(0.55);
j1v_c.set_value(0.66);
j2p_c.set_value(0.77);
j2v_c.set_value(0.88);
(void)j1p_c.set_value(0.55);
(void)j1v_c.set_value(0.66);
(void)j2p_c.set_value(0.77);
(void)j2v_c.set_value(0.88);

// state values should not be changed
ASSERT_EQ(0.11 + offset, j1p_s.get_value<double>().value());
Expand Down Expand Up @@ -983,10 +983,10 @@ void generic_system_error_group_test(
ASSERT_TRUE(std::isnan(j2v_c.get_value<double>().value()));

// set some new values in commands
j1p_c.set_value(0.11);
j1v_c.set_value(0.22);
j2p_c.set_value(0.33);
j2v_c.set_value(0.44);
(void)j1p_c.set_value(0.11);
(void)j1v_c.set_value(0.22);
(void)j2p_c.set_value(0.33);
(void)j2v_c.set_value(0.44);

// State values should not be changed
ASSERT_EQ(3.45, j1p_s.get_value<double>().value());
Expand Down Expand Up @@ -1021,10 +1021,10 @@ void generic_system_error_group_test(
ASSERT_EQ(0.44, j2v_c.get_value<double>().value());

// set some new values in commands
j1p_c.set_value(0.55);
j1v_c.set_value(0.66);
j2p_c.set_value(0.77);
j2v_c.set_value(0.88);
(void)j1p_c.set_value(0.55);
(void)j1v_c.set_value(0.66);
(void)j2p_c.set_value(0.77);
(void)j2v_c.set_value(0.88);

// state values should not be changed
ASSERT_EQ(0.11, j1p_s.get_value<double>().value());
Expand All @@ -1037,8 +1037,8 @@ void generic_system_error_group_test(
ASSERT_EQ(0.88, j2v_c.get_value<double>().value());

// Error testing
j1p_c.set_value(std::numeric_limits<double>::infinity());
j1v_c.set_value(std::numeric_limits<double>::infinity());
(void)j1p_c.set_value(std::numeric_limits<double>::infinity());
(void)j1v_c.set_value(std::numeric_limits<double>::infinity());
// read() should now bring error in the first component
auto read_result = rm.read(TIME, PERIOD);
ASSERT_FALSE(read_result.ok);
Expand Down Expand Up @@ -1075,8 +1075,8 @@ void generic_system_error_group_test(
}

// Error should be recoverable only after reactivating the hardware component
j1p_c.set_value(0.0);
j1v_c.set_value(0.0);
(void)j1p_c.set_value(0.0);
(void)j1v_c.set_value(0.0);
ASSERT_FALSE(rm.read(TIME, PERIOD).ok);

// Now it should be recoverable
Expand Down Expand Up @@ -1164,9 +1164,9 @@ TEST_F(TestGenericSystem, generic_system_2dof_other_interfaces)
ASSERT_TRUE(std::isnan(vo_c.get_value<double>().value()));

// set some new values in commands
j1p_c.set_value(0.11);
j2p_c.set_value(0.33);
vo_c.set_value(0.99);
(void)j1p_c.set_value(0.11);
(void)j2p_c.set_value(0.33);
(void)vo_c.set_value(0.99);

// State values should not be changed
ASSERT_EQ(1.55, j1p_s.get_value<double>().value());
Expand Down Expand Up @@ -1259,8 +1259,8 @@ TEST_F(TestGenericSystem, generic_system_2dof_sensor)
ASSERT_TRUE(std::isnan(j2p_c.get_value<double>().value()));

// set some new values in commands
j1p_c.set_value(0.11);
j2p_c.set_value(0.33);
(void)j1p_c.set_value(0.11);
(void)j2p_c.set_value(0.33);

// State values should not be changed
ASSERT_EQ(0.0, j1p_s.get_value<double>().value());
Expand Down Expand Up @@ -1366,12 +1366,12 @@ void TestGenericSystem::test_generic_system_with_mock_sensor_commands(
EXPECT_TRUE(std::isnan(sty_c.get_value<double>().value()));

// set some new values in commands
j1p_c.set_value(0.11);
j2p_c.set_value(0.33);
sfx_c.set_value(1.11);
sfy_c.set_value(2.22);
stx_c.set_value(3.33);
sty_c.set_value(4.44);
(void)j1p_c.set_value(0.11);
(void)j2p_c.set_value(0.33);
(void)sfx_c.set_value(1.11);
(void)sfy_c.set_value(2.22);
(void)stx_c.set_value(3.33);
(void)sty_c.set_value(4.44);

// State values should not be changed
ASSERT_EQ(0.0, j1p_s.get_value<double>().value());
Expand Down Expand Up @@ -1476,8 +1476,8 @@ void TestGenericSystem::test_generic_system_with_mimic_joint(
ASSERT_TRUE(std::isnan(j1v_c.get_value<double>().value()));

// set some new values in commands
j1p_c.set_value(0.11);
j1v_c.set_value(0.05);
(void)j1p_c.set_value(0.11);
(void)j1v_c.set_value(0.05);

// State values should not be changed
ASSERT_EQ(1.57, j1p_s.get_value<double>().value());
Expand Down Expand Up @@ -1587,10 +1587,10 @@ TEST_F(TestGenericSystem, generic_system_2dof_functionality_with_offset_custom_i
ASSERT_TRUE(std::isnan(j2v_c.get_value<double>().value()));

// set some new values in commands
j1p_c.set_value(0.11);
j1v_c.set_value(0.22);
j2p_c.set_value(0.33);
j2v_c.set_value(0.44);
(void)j1p_c.set_value(0.11);
(void)j1v_c.set_value(0.22);
(void)j2p_c.set_value(0.33);
(void)j2v_c.set_value(0.44);

// State values should not be changed
ASSERT_EQ(3.45, j1p_s.get_value<double>().value());
Expand Down Expand Up @@ -1627,10 +1627,10 @@ TEST_F(TestGenericSystem, generic_system_2dof_functionality_with_offset_custom_i
ASSERT_EQ(0.44, j2v_c.get_value<double>().value());

// set some new values in commands
j1p_c.set_value(0.55);
j1v_c.set_value(0.66);
j2p_c.set_value(0.77);
j2v_c.set_value(0.88);
(void)j1p_c.set_value(0.55);
(void)j1v_c.set_value(0.66);
(void)j2p_c.set_value(0.77);
(void)j2v_c.set_value(0.88);

// state values should not be changed
ASSERT_EQ(0.11, j1p_s.get_value<double>().value());
Expand Down Expand Up @@ -1711,8 +1711,8 @@ TEST_F(TestGenericSystem, valid_urdf_ros2_control_system_robot_with_gpio)
ASSERT_TRUE(std::isnan(gpio2_vac_c.get_value<double>().value()));

// set some new values in commands
gpio1_a_o1_c.set_value(0.111);
gpio2_vac_c.set_value(0.222);
(void)gpio1_a_o1_c.set_value(0.111);
(void)gpio2_vac_c.set_value(0.222);

// State values should not be changed
ASSERT_TRUE(std::isnan(gpio1_a_o1_s.get_value<double>().value()));
Expand All @@ -1735,8 +1735,8 @@ TEST_F(TestGenericSystem, valid_urdf_ros2_control_system_robot_with_gpio)
ASSERT_EQ(0.222, gpio2_vac_c.get_value<double>().value());

// set some new values in commands
gpio1_a_o1_c.set_value(0.333);
gpio2_vac_c.set_value(0.444);
(void)gpio1_a_o1_c.set_value(0.333);
(void)gpio2_vac_c.set_value(0.444);

// state values should not be changed
ASSERT_EQ(0.111, gpio1_a_o1_s.get_value<double>().value());
Expand Down Expand Up @@ -1817,10 +1817,10 @@ void TestGenericSystem::test_generic_system_with_mock_gpio_commands(
EXPECT_TRUE(std::isnan(gpio2_vac_c.get_value<double>().value()));

// set some new values in commands
gpio1_a_o1_c.set_value(0.11);
gpio1_a_i1_c.set_value(0.33);
gpio1_a_i2_c.set_value(1.11);
gpio2_vac_c.set_value(2.22);
(void)gpio1_a_o1_c.set_value(0.11);
(void)gpio1_a_i1_c.set_value(0.33);
(void)gpio1_a_i2_c.set_value(1.11);
(void)gpio2_vac_c.set_value(2.22);

// State values should not be changed
EXPECT_TRUE(std::isnan(gpio1_a_o1_s.get_value<double>().value()));
Expand Down Expand Up @@ -1989,8 +1989,8 @@ TEST_F(TestGenericSystem, simple_dynamics_pos_vel_acc_control_modes_interfaces)
true);

// set some new values in commands
j1p_c.set_value(0.11);
j2a_c.set_value(3.5);
(void)j1p_c.set_value(0.11);
(void)j2a_c.set_value(3.5);

// State values should not be changed
EXPECT_EQ(3.45, j1p_s.get_value<double>().value());
Expand Down Expand Up @@ -2061,8 +2061,8 @@ TEST_F(TestGenericSystem, simple_dynamics_pos_vel_acc_control_modes_interfaces)
ASSERT_EQ(rm.perform_command_mode_switch({"joint1/velocity", "joint2/velocity"}, {}), true);

// set some new values in commands
j1v_c.set_value(0.5);
j2v_c.set_value(2.0);
(void)j1v_c.set_value(0.5);
(void)j2v_c.set_value(2.0);

// State values should not be changed
EXPECT_EQ(0.11, j1p_s.get_value<double>().value());
Expand Down Expand Up @@ -2143,7 +2143,7 @@ TEST_F(TestGenericSystem, disabled_commands_flag_is_active)
ASSERT_TRUE(std::isnan(j1p_c.get_value<double>().value()));

// set some new values in commands
j1p_c.set_value(0.11);
(void)j1p_c.set_value(0.11);

// State values should not be changed
ASSERT_EQ(3.45, j1p_s.get_value<double>().value());
Expand Down
16 changes: 8 additions & 8 deletions hardware_interface/test/test_component_interfaces.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -765,7 +765,7 @@ TEST(TestComponentInterfaces, dummy_actuator)
EXPECT_EQ("joint1", command_interfaces[0]->get_prefix_name());

double velocity_value = 1.0;
command_interfaces[0]->set_value(velocity_value); // velocity
(void)command_interfaces[0]->set_value(velocity_value); // velocity
ASSERT_EQ(hardware_interface::return_type::OK, actuator_hw.write(TIME, PERIOD));

// Noting should change because it is UNCONFIGURED
Expand Down Expand Up @@ -887,7 +887,7 @@ TEST(TestComponentInterfaces, dummy_actuator_default)
double velocity_value = 1.0;
auto ci_joint1_vel =
test_components::vector_contains(command_interfaces, "joint1/velocity").second;
command_interfaces[ci_joint1_vel]->set_value(velocity_value); // velocity
(void)command_interfaces[ci_joint1_vel]->set_value(velocity_value); // velocity
ASSERT_EQ(hardware_interface::return_type::OK, actuator_hw.write(TIME, PERIOD));

// Noting should change because it is UNCONFIGURED
Expand Down Expand Up @@ -1145,9 +1145,9 @@ TEST(TestComponentInterfaces, dummy_system)
EXPECT_EQ("joint3", command_interfaces[2]->get_prefix_name());

double velocity_value = 1.0;
command_interfaces[0]->set_value(velocity_value); // velocity
command_interfaces[1]->set_value(velocity_value); // velocity
command_interfaces[2]->set_value(velocity_value); // velocity
(void)command_interfaces[0]->set_value(velocity_value); // velocity
(void)command_interfaces[1]->set_value(velocity_value); // velocity
(void)command_interfaces[2]->set_value(velocity_value); // velocity
ASSERT_EQ(hardware_interface::return_type::OK, system_hw.write(TIME, PERIOD));

// Noting should change because it is UNCONFIGURED
Expand Down Expand Up @@ -1347,9 +1347,9 @@ TEST(TestComponentInterfaces, dummy_system_default)
auto ci_joint3_vel =
test_components::vector_contains(command_interfaces, "joint3/velocity").second;
double velocity_value = 1.0;
command_interfaces[ci_joint1_vel]->set_value(velocity_value); // velocity
command_interfaces[ci_joint2_vel]->set_value(velocity_value); // velocity
command_interfaces[ci_joint3_vel]->set_value(velocity_value); // velocity
(void)command_interfaces[ci_joint1_vel]->set_value(velocity_value); // velocity
(void)command_interfaces[ci_joint2_vel]->set_value(velocity_value); // velocity
(void)command_interfaces[ci_joint3_vel]->set_value(velocity_value); // velocity
ASSERT_EQ(hardware_interface::return_type::OK, system_hw.write(TIME, PERIOD));

// Noting should change because it is UNCONFIGURED
Expand Down

0 comments on commit 7cd44c2

Please sign in to comment.