Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Final variant support #25

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from
Draft
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
change get_value function to new templated version
mamueluth committed Jul 29, 2024
commit d753fb4bbb26cacc6fa9a9b1d9599525a082de4f
20 changes: 10 additions & 10 deletions diff_drive_controller/test/test_diff_drive_controller.cpp
Original file line number Diff line number Diff line change
@@ -513,8 +513,8 @@ TEST_F(TestDiffDriveController, cleanup)
ASSERT_EQ(State::PRIMARY_STATE_UNCONFIGURED, state.id());

// should be stopped
EXPECT_EQ(0.0, left_wheel_vel_cmd_.get_value());
EXPECT_EQ(0.0, right_wheel_vel_cmd_.get_value());
EXPECT_EQ(0.0, left_wheel_vel_cmd_.get_value<double>());
EXPECT_EQ(0.0, right_wheel_vel_cmd_.get_value<double>());

executor.cancel();
}
@@ -534,8 +534,8 @@ TEST_F(TestDiffDriveController, correct_initialization_using_parameters)
assignResourcesPosFeedback();

ASSERT_EQ(State::PRIMARY_STATE_INACTIVE, state.id());
EXPECT_EQ(0.01, left_wheel_vel_cmd_.get_value());
EXPECT_EQ(0.02, right_wheel_vel_cmd_.get_value());
EXPECT_EQ(0.01, left_wheel_vel_cmd_.get_value<double>());
EXPECT_EQ(0.02, right_wheel_vel_cmd_.get_value<double>());

state = controller_->get_node()->activate();
ASSERT_EQ(State::PRIMARY_STATE_ACTIVE, state.id());
@@ -550,8 +550,8 @@ TEST_F(TestDiffDriveController, correct_initialization_using_parameters)
ASSERT_EQ(
controller_->update(rclcpp::Time(0, 0, RCL_ROS_TIME), rclcpp::Duration::from_seconds(0.01)),
controller_interface::return_type::OK);
EXPECT_EQ(1.0, left_wheel_vel_cmd_.get_value());
EXPECT_EQ(1.0, right_wheel_vel_cmd_.get_value());
EXPECT_EQ(1.0, left_wheel_vel_cmd_.get_value<double>());
EXPECT_EQ(1.0, right_wheel_vel_cmd_.get_value<double>());

// deactivated
// wait so controller process the second point when deactivated
@@ -562,14 +562,14 @@ TEST_F(TestDiffDriveController, correct_initialization_using_parameters)
controller_->update(rclcpp::Time(0, 0, RCL_ROS_TIME), rclcpp::Duration::from_seconds(0.01)),
controller_interface::return_type::OK);

EXPECT_EQ(0.0, left_wheel_vel_cmd_.get_value()) << "Wheels are halted on deactivate()";
EXPECT_EQ(0.0, right_wheel_vel_cmd_.get_value()) << "Wheels are halted on deactivate()";
EXPECT_EQ(0.0, left_wheel_vel_cmd_.get_value<double>()) << "Wheels are halted on deactivate()";
EXPECT_EQ(0.0, right_wheel_vel_cmd_.get_value<double>()) << "Wheels are halted on deactivate()";

// cleanup
state = controller_->get_node()->cleanup();
ASSERT_EQ(State::PRIMARY_STATE_UNCONFIGURED, state.id());
EXPECT_EQ(0.0, left_wheel_vel_cmd_.get_value());
EXPECT_EQ(0.0, right_wheel_vel_cmd_.get_value());
EXPECT_EQ(0.0, left_wheel_vel_cmd_.get_value<double>());
EXPECT_EQ(0.0, right_wheel_vel_cmd_.get_value<double>());

state = controller_->get_node()->configure();
ASSERT_EQ(State::PRIMARY_STATE_INACTIVE, state.id());
48 changes: 24 additions & 24 deletions effort_controllers/test/test_joint_group_effort_controller.cpp
Original file line number Diff line number Diff line change
@@ -105,9 +105,9 @@ TEST_F(JointGroupEffortControllerTest, CommandSuccessTest)
controller_interface::return_type::OK);

// check joint commands are still the default ones
ASSERT_EQ(joint_1_cmd_.get_value(), 1.1);
ASSERT_EQ(joint_2_cmd_.get_value(), 2.1);
ASSERT_EQ(joint_3_cmd_.get_value(), 3.1);
ASSERT_EQ(joint_1_cmd_.get_value<double>(), 1.1);
ASSERT_EQ(joint_2_cmd_.get_value<double>(), 2.1);
ASSERT_EQ(joint_3_cmd_.get_value<double>(), 3.1);

// send command
auto command_ptr = std::make_shared<forward_command_controller::CmdType>();
@@ -120,9 +120,9 @@ TEST_F(JointGroupEffortControllerTest, CommandSuccessTest)
controller_interface::return_type::OK);

// check joint commands have been modified
ASSERT_EQ(joint_1_cmd_.get_value(), 10.0);
ASSERT_EQ(joint_2_cmd_.get_value(), 20.0);
ASSERT_EQ(joint_3_cmd_.get_value(), 30.0);
ASSERT_EQ(joint_1_cmd_.get_value<double>(), 10.0);
ASSERT_EQ(joint_2_cmd_.get_value<double>(), 20.0);
ASSERT_EQ(joint_3_cmd_.get_value<double>(), 30.0);
}

TEST_F(JointGroupEffortControllerTest, WrongCommandCheckTest)
@@ -142,9 +142,9 @@ TEST_F(JointGroupEffortControllerTest, WrongCommandCheckTest)
controller_interface::return_type::ERROR);

// check joint commands are still the default ones
ASSERT_EQ(joint_1_cmd_.get_value(), 1.1);
ASSERT_EQ(joint_2_cmd_.get_value(), 2.1);
ASSERT_EQ(joint_3_cmd_.get_value(), 3.1);
ASSERT_EQ(joint_1_cmd_.get_value<double>(), 1.1);
ASSERT_EQ(joint_2_cmd_.get_value<double>(), 2.1);
ASSERT_EQ(joint_3_cmd_.get_value<double>(), 3.1);
}

TEST_F(JointGroupEffortControllerTest, NoCommandCheckTest)
@@ -159,9 +159,9 @@ TEST_F(JointGroupEffortControllerTest, NoCommandCheckTest)
controller_interface::return_type::OK);

// check joint commands are still the default ones
ASSERT_EQ(joint_1_cmd_.get_value(), 1.1);
ASSERT_EQ(joint_2_cmd_.get_value(), 2.1);
ASSERT_EQ(joint_3_cmd_.get_value(), 3.1);
ASSERT_EQ(joint_1_cmd_.get_value<double>(), 1.1);
ASSERT_EQ(joint_2_cmd_.get_value<double>(), 2.1);
ASSERT_EQ(joint_3_cmd_.get_value<double>(), 3.1);
}

TEST_F(JointGroupEffortControllerTest, CommandCallbackTest)
@@ -170,9 +170,9 @@ TEST_F(JointGroupEffortControllerTest, CommandCallbackTest)
controller_->get_node()->set_parameter({"joints", joint_names_});

// default values
ASSERT_EQ(joint_1_cmd_.get_value(), 1.1);
ASSERT_EQ(joint_2_cmd_.get_value(), 2.1);
ASSERT_EQ(joint_3_cmd_.get_value(), 3.1);
ASSERT_EQ(joint_1_cmd_.get_value<double>(), 1.1);
ASSERT_EQ(joint_2_cmd_.get_value<double>(), 2.1);
ASSERT_EQ(joint_3_cmd_.get_value<double>(), 3.1);

auto node_state = controller_->get_node()->configure();
ASSERT_EQ(node_state.id(), lifecycle_msgs::msg::State::PRIMARY_STATE_INACTIVE);
@@ -203,9 +203,9 @@ TEST_F(JointGroupEffortControllerTest, CommandCallbackTest)
controller_interface::return_type::OK);

// check command in handle was set
ASSERT_EQ(joint_1_cmd_.get_value(), 10.0);
ASSERT_EQ(joint_2_cmd_.get_value(), 20.0);
ASSERT_EQ(joint_3_cmd_.get_value(), 30.0);
ASSERT_EQ(joint_1_cmd_.get_value<double>(), 10.0);
ASSERT_EQ(joint_2_cmd_.get_value<double>(), 20.0);
ASSERT_EQ(joint_3_cmd_.get_value<double>(), 30.0);
}

TEST_F(JointGroupEffortControllerTest, StopJointsOnDeactivateTest)
@@ -217,15 +217,15 @@ TEST_F(JointGroupEffortControllerTest, StopJointsOnDeactivateTest)
ASSERT_EQ(controller_->on_configure(rclcpp_lifecycle::State()), CallbackReturn::SUCCESS);

// check joint commands are still the default ones
ASSERT_EQ(joint_1_cmd_.get_value(), 1.1);
ASSERT_EQ(joint_2_cmd_.get_value(), 2.1);
ASSERT_EQ(joint_3_cmd_.get_value(), 3.1);
ASSERT_EQ(joint_1_cmd_.get_value<double>(), 1.1);
ASSERT_EQ(joint_2_cmd_.get_value<double>(), 2.1);
ASSERT_EQ(joint_3_cmd_.get_value<double>(), 3.1);

// stop the controller
ASSERT_EQ(controller_->on_deactivate(rclcpp_lifecycle::State()), CallbackReturn::SUCCESS);

// check joint commands are now zero
ASSERT_EQ(joint_1_cmd_.get_value(), 0.0);
ASSERT_EQ(joint_2_cmd_.get_value(), 0.0);
ASSERT_EQ(joint_3_cmd_.get_value(), 0.0);
ASSERT_EQ(joint_1_cmd_.get_value<double>(), 0.0);
ASSERT_EQ(joint_2_cmd_.get_value<double>(), 0.0);
ASSERT_EQ(joint_3_cmd_.get_value<double>(), 0.0);
}
60 changes: 30 additions & 30 deletions forward_command_controller/test/test_forward_command_controller.cpp
Original file line number Diff line number Diff line change
@@ -212,9 +212,9 @@ TEST_F(ForwardCommandControllerTest, CommandSuccessTest)
controller_interface::return_type::OK);

// check joint commands are still the default ones
ASSERT_EQ(joint_1_pos_cmd_.get_value(), 1.1);
ASSERT_EQ(joint_2_pos_cmd_.get_value(), 2.1);
ASSERT_EQ(joint_3_pos_cmd_.get_value(), 3.1);
ASSERT_EQ(joint_1_pos_cmd_.get_value<double>(), 1.1);
ASSERT_EQ(joint_2_pos_cmd_.get_value<double>(), 2.1);
ASSERT_EQ(joint_3_pos_cmd_.get_value<double>(), 3.1);

// send command
auto command_ptr = std::make_shared<forward_command_controller::CmdType>();
@@ -227,9 +227,9 @@ TEST_F(ForwardCommandControllerTest, CommandSuccessTest)
controller_interface::return_type::OK);

// check joint commands have been modified
ASSERT_EQ(joint_1_pos_cmd_.get_value(), 10.0);
ASSERT_EQ(joint_2_pos_cmd_.get_value(), 20.0);
ASSERT_EQ(joint_3_pos_cmd_.get_value(), 30.0);
ASSERT_EQ(joint_1_pos_cmd_.get_value<double>(), 10.0);
ASSERT_EQ(joint_2_pos_cmd_.get_value<double>(), 20.0);
ASSERT_EQ(joint_3_pos_cmd_.get_value<double>(), 30.0);
}

TEST_F(ForwardCommandControllerTest, WrongCommandCheckTest)
@@ -255,9 +255,9 @@ TEST_F(ForwardCommandControllerTest, WrongCommandCheckTest)
controller_interface::return_type::ERROR);

// check joint commands are still the default ones
ASSERT_EQ(joint_1_pos_cmd_.get_value(), 1.1);
ASSERT_EQ(joint_2_pos_cmd_.get_value(), 2.1);
ASSERT_EQ(joint_3_pos_cmd_.get_value(), 3.1);
ASSERT_EQ(joint_1_pos_cmd_.get_value<double>(), 1.1);
ASSERT_EQ(joint_2_pos_cmd_.get_value<double>(), 2.1);
ASSERT_EQ(joint_3_pos_cmd_.get_value<double>(), 3.1);
}

TEST_F(ForwardCommandControllerTest, NoCommandCheckTest)
@@ -277,9 +277,9 @@ TEST_F(ForwardCommandControllerTest, NoCommandCheckTest)
controller_interface::return_type::OK);

// check joint commands are still the default ones
ASSERT_EQ(joint_1_pos_cmd_.get_value(), 1.1);
ASSERT_EQ(joint_2_pos_cmd_.get_value(), 2.1);
ASSERT_EQ(joint_3_pos_cmd_.get_value(), 3.1);
ASSERT_EQ(joint_1_pos_cmd_.get_value<double>(), 1.1);
ASSERT_EQ(joint_2_pos_cmd_.get_value<double>(), 2.1);
ASSERT_EQ(joint_3_pos_cmd_.get_value<double>(), 3.1);
}

TEST_F(ForwardCommandControllerTest, CommandCallbackTest)
@@ -290,9 +290,9 @@ TEST_F(ForwardCommandControllerTest, CommandCallbackTest)
controller_->get_node()->set_parameter({"interface_name", "position"});

// default values
ASSERT_EQ(joint_1_pos_cmd_.get_value(), 1.1);
ASSERT_EQ(joint_2_pos_cmd_.get_value(), 2.1);
ASSERT_EQ(joint_3_pos_cmd_.get_value(), 3.1);
ASSERT_EQ(joint_1_pos_cmd_.get_value<double>(), 1.1);
ASSERT_EQ(joint_2_pos_cmd_.get_value<double>(), 2.1);
ASSERT_EQ(joint_3_pos_cmd_.get_value<double>(), 3.1);

auto node_state = controller_->get_node()->configure();
ASSERT_EQ(node_state.id(), lifecycle_msgs::msg::State::PRIMARY_STATE_INACTIVE);
@@ -323,9 +323,9 @@ TEST_F(ForwardCommandControllerTest, CommandCallbackTest)
controller_interface::return_type::OK);

// check command in handle was set
ASSERT_EQ(joint_1_pos_cmd_.get_value(), 10.0);
ASSERT_EQ(joint_2_pos_cmd_.get_value(), 20.0);
ASSERT_EQ(joint_3_pos_cmd_.get_value(), 30.0);
ASSERT_EQ(joint_1_pos_cmd_.get_value<double>(), 10.0);
ASSERT_EQ(joint_2_pos_cmd_.get_value<double>(), 20.0);
ASSERT_EQ(joint_3_pos_cmd_.get_value<double>(), 30.0);
}

TEST_F(ForwardCommandControllerTest, ActivateDeactivateCommandsResetSuccess)
@@ -336,9 +336,9 @@ TEST_F(ForwardCommandControllerTest, ActivateDeactivateCommandsResetSuccess)
controller_->get_node()->set_parameter({"interface_name", "position"});

// default values
ASSERT_EQ(joint_1_pos_cmd_.get_value(), 1.1);
ASSERT_EQ(joint_2_pos_cmd_.get_value(), 2.1);
ASSERT_EQ(joint_3_pos_cmd_.get_value(), 3.1);
ASSERT_EQ(joint_1_pos_cmd_.get_value<double>(), 1.1);
ASSERT_EQ(joint_2_pos_cmd_.get_value<double>(), 2.1);
ASSERT_EQ(joint_3_pos_cmd_.get_value<double>(), 3.1);

auto node_state = controller_->configure();
ASSERT_EQ(node_state.id(), lifecycle_msgs::msg::State::PRIMARY_STATE_INACTIVE);
@@ -373,9 +373,9 @@ TEST_F(ForwardCommandControllerTest, ActivateDeactivateCommandsResetSuccess)
controller_interface::return_type::OK);

// check command in handle was set
ASSERT_EQ(joint_1_pos_cmd_.get_value(), 10);
ASSERT_EQ(joint_2_pos_cmd_.get_value(), 20);
ASSERT_EQ(joint_3_pos_cmd_.get_value(), 30);
ASSERT_EQ(joint_1_pos_cmd_.get_value<double>(), 10);
ASSERT_EQ(joint_2_pos_cmd_.get_value<double>(), 20);
ASSERT_EQ(joint_3_pos_cmd_.get_value<double>(), 30);

node_state = controller_->get_node()->deactivate();
ASSERT_EQ(node_state.id(), lifecycle_msgs::msg::State::PRIMARY_STATE_INACTIVE);
@@ -425,9 +425,9 @@ TEST_F(ForwardCommandControllerTest, ActivateDeactivateCommandsResetSuccess)
controller_interface::return_type::OK);

// values should not change
ASSERT_EQ(joint_1_pos_cmd_.get_value(), 10);
ASSERT_EQ(joint_2_pos_cmd_.get_value(), 20);
ASSERT_EQ(joint_3_pos_cmd_.get_value(), 30);
ASSERT_EQ(joint_1_pos_cmd_.get_value<double>(), 10);
ASSERT_EQ(joint_2_pos_cmd_.get_value<double>(), 20);
ASSERT_EQ(joint_3_pos_cmd_.get_value<double>(), 30);

// set commands again
controller_->rt_command_ptr_.writeFromNonRT(command_msg);
@@ -438,7 +438,7 @@ TEST_F(ForwardCommandControllerTest, ActivateDeactivateCommandsResetSuccess)
controller_interface::return_type::OK);

// check command in handle was set
ASSERT_EQ(joint_1_pos_cmd_.get_value(), 5.5);
ASSERT_EQ(joint_2_pos_cmd_.get_value(), 6.6);
ASSERT_EQ(joint_3_pos_cmd_.get_value(), 7.7);
ASSERT_EQ(joint_1_pos_cmd_.get_value<double>(), 5.5);
ASSERT_EQ(joint_2_pos_cmd_.get_value<double>(), 6.6);
ASSERT_EQ(joint_3_pos_cmd_.get_value<double>(), 7.7);
}
Original file line number Diff line number Diff line change
@@ -189,9 +189,9 @@ TEST_F(MultiInterfaceForwardCommandControllerTest, ActivateSuccess)
SetUpController(true);

// check joint commands are the default ones
ASSERT_EQ(joint_1_pos_cmd_.get_value(), 1.1);
ASSERT_EQ(joint_1_vel_cmd_.get_value(), 2.1);
ASSERT_EQ(joint_1_eff_cmd_.get_value(), 3.1);
ASSERT_EQ(joint_1_pos_cmd_.get_value<double>(), 1.1);
ASSERT_EQ(joint_1_vel_cmd_.get_value<double>(), 2.1);
ASSERT_EQ(joint_1_eff_cmd_.get_value<double>(), 3.1);
}

TEST_F(MultiInterfaceForwardCommandControllerTest, CommandSuccessTest)
@@ -209,9 +209,9 @@ TEST_F(MultiInterfaceForwardCommandControllerTest, CommandSuccessTest)
controller_interface::return_type::OK);

// check command in handle was set
ASSERT_EQ(joint_1_pos_cmd_.get_value(), 10.0);
ASSERT_EQ(joint_1_vel_cmd_.get_value(), 20.0);
ASSERT_EQ(joint_1_eff_cmd_.get_value(), 30.0);
ASSERT_EQ(joint_1_pos_cmd_.get_value<double>(), 10.0);
ASSERT_EQ(joint_1_vel_cmd_.get_value<double>(), 20.0);
ASSERT_EQ(joint_1_eff_cmd_.get_value<double>(), 30.0);
}

TEST_F(MultiInterfaceForwardCommandControllerTest, NoCommandCheckTest)
@@ -224,9 +224,9 @@ TEST_F(MultiInterfaceForwardCommandControllerTest, NoCommandCheckTest)
controller_interface::return_type::OK);

// check joint commands are still the default ones
ASSERT_EQ(joint_1_pos_cmd_.get_value(), 1.1);
ASSERT_EQ(joint_1_vel_cmd_.get_value(), 2.1);
ASSERT_EQ(joint_1_eff_cmd_.get_value(), 3.1);
ASSERT_EQ(joint_1_pos_cmd_.get_value<double>(), 1.1);
ASSERT_EQ(joint_1_vel_cmd_.get_value<double>(), 2.1);
ASSERT_EQ(joint_1_eff_cmd_.get_value<double>(), 3.1);
}

TEST_F(MultiInterfaceForwardCommandControllerTest, WrongCommandCheckTest)
@@ -244,9 +244,9 @@ TEST_F(MultiInterfaceForwardCommandControllerTest, WrongCommandCheckTest)
controller_interface::return_type::ERROR);

// check joint commands are still the default ones
ASSERT_EQ(joint_1_pos_cmd_.get_value(), 1.1);
ASSERT_EQ(joint_1_vel_cmd_.get_value(), 2.1);
ASSERT_EQ(joint_1_eff_cmd_.get_value(), 3.1);
ASSERT_EQ(joint_1_pos_cmd_.get_value<double>(), 1.1);
ASSERT_EQ(joint_1_vel_cmd_.get_value<double>(), 2.1);
ASSERT_EQ(joint_1_eff_cmd_.get_value<double>(), 3.1);
}

TEST_F(MultiInterfaceForwardCommandControllerTest, CommandCallbackTest)
@@ -276,9 +276,9 @@ TEST_F(MultiInterfaceForwardCommandControllerTest, CommandCallbackTest)
controller_interface::return_type::OK);

// check command in handle was set
ASSERT_EQ(joint_1_pos_cmd_.get_value(), 10.0);
ASSERT_EQ(joint_1_vel_cmd_.get_value(), 20.0);
ASSERT_EQ(joint_1_eff_cmd_.get_value(), 30.0);
ASSERT_EQ(joint_1_pos_cmd_.get_value<double>(), 10.0);
ASSERT_EQ(joint_1_vel_cmd_.get_value<double>(), 20.0);
ASSERT_EQ(joint_1_eff_cmd_.get_value<double>(), 30.0);
}

TEST_F(MultiInterfaceForwardCommandControllerTest, ActivateDeactivateCommandsResetSuccess)
@@ -304,9 +304,9 @@ TEST_F(MultiInterfaceForwardCommandControllerTest, ActivateDeactivateCommandsRes
controller_interface::return_type::OK);

// check command in handle was set
ASSERT_EQ(joint_1_pos_cmd_.get_value(), 10.0);
ASSERT_EQ(joint_1_vel_cmd_.get_value(), 20.0);
ASSERT_EQ(joint_1_eff_cmd_.get_value(), 30.0);
ASSERT_EQ(joint_1_pos_cmd_.get_value<double>(), 10.0);
ASSERT_EQ(joint_1_vel_cmd_.get_value<double>(), 20.0);
ASSERT_EQ(joint_1_eff_cmd_.get_value<double>(), 30.0);

auto node_state = controller_->get_node()->deactivate();
ASSERT_EQ(node_state.id(), lifecycle_msgs::msg::State::PRIMARY_STATE_INACTIVE);
@@ -355,9 +355,9 @@ TEST_F(MultiInterfaceForwardCommandControllerTest, ActivateDeactivateCommandsRes
controller_interface::return_type::OK);

// values should not change
ASSERT_EQ(joint_1_pos_cmd_.get_value(), 10.0);
ASSERT_EQ(joint_1_vel_cmd_.get_value(), 20.0);
ASSERT_EQ(joint_1_eff_cmd_.get_value(), 30.0);
ASSERT_EQ(joint_1_pos_cmd_.get_value<double>(), 10.0);
ASSERT_EQ(joint_1_vel_cmd_.get_value<double>(), 20.0);
ASSERT_EQ(joint_1_eff_cmd_.get_value<double>(), 30.0);

// set commands again
controller_->rt_command_ptr_.writeFromNonRT(command_msg);
@@ -368,7 +368,7 @@ TEST_F(MultiInterfaceForwardCommandControllerTest, ActivateDeactivateCommandsRes
controller_interface::return_type::OK);

// check command in handle was set
ASSERT_EQ(joint_1_pos_cmd_.get_value(), 5.5);
ASSERT_EQ(joint_1_vel_cmd_.get_value(), 6.6);
ASSERT_EQ(joint_1_eff_cmd_.get_value(), 7.7);
ASSERT_EQ(joint_1_pos_cmd_.get_value<double>(), 5.5);
ASSERT_EQ(joint_1_vel_cmd_.get_value<double>(), 6.6);
ASSERT_EQ(joint_1_eff_cmd_.get_value<double>(), 7.7);
}
Original file line number Diff line number Diff line change
@@ -637,19 +637,21 @@ class TrajectoryControllerTest : public ::testing::Test
for (size_t i = 0; i < 3; i++)
{
EXPECT_TRUE(is_same_sign_or_zero(
position.at(i) - pos_state_interfaces_[i].get_value(), joint_vel_[i]))
position.at(i) - pos_state_interfaces_[i].get_value<double>(), joint_vel_[i]))
<< "test position point " << position.at(i) << ", position state is "
<< pos_state_interfaces_[i].get_value() << ", velocity command is " << joint_vel_[i];
<< pos_state_interfaces_[i].get_value<double>() << ", velocity command is "
<< joint_vel_[i];
}
}
if (traj_controller_->has_effort_command_interface())
{
for (size_t i = 0; i < 3; i++)
{
EXPECT_TRUE(is_same_sign_or_zero(
position.at(i) - pos_state_interfaces_[i].get_value(), joint_eff_[i]))
position.at(i) - pos_state_interfaces_[i].get_value<double>(), joint_eff_[i]))
<< "test position point " << position.at(i) << ", position state is "
<< pos_state_interfaces_[i].get_value() << ", effort command is " << joint_eff_[i];
<< pos_state_interfaces_[i].get_value<double>() << ", effort command is "
<< joint_eff_[i];
}
}
}
36 changes: 18 additions & 18 deletions position_controllers/test/test_joint_group_position_controller.cpp
Original file line number Diff line number Diff line change
@@ -105,9 +105,9 @@ TEST_F(JointGroupPositionControllerTest, CommandSuccessTest)
controller_interface::return_type::OK);

// check joint commands are still the default ones
ASSERT_EQ(joint_1_pos_cmd_.get_value(), 1.1);
ASSERT_EQ(joint_2_pos_cmd_.get_value(), 2.1);
ASSERT_EQ(joint_3_pos_cmd_.get_value(), 3.1);
ASSERT_EQ(joint_1_pos_cmd_.get_value<double>(), 1.1);
ASSERT_EQ(joint_2_pos_cmd_.get_value<double>(), 2.1);
ASSERT_EQ(joint_3_pos_cmd_.get_value<double>(), 3.1);

// send command
auto command_ptr = std::make_shared<forward_command_controller::CmdType>();
@@ -120,9 +120,9 @@ TEST_F(JointGroupPositionControllerTest, CommandSuccessTest)
controller_interface::return_type::OK);

// check joint commands have been modified
ASSERT_EQ(joint_1_pos_cmd_.get_value(), 10.0);
ASSERT_EQ(joint_2_pos_cmd_.get_value(), 20.0);
ASSERT_EQ(joint_3_pos_cmd_.get_value(), 30.0);
ASSERT_EQ(joint_1_pos_cmd_.get_value<double>(), 10.0);
ASSERT_EQ(joint_2_pos_cmd_.get_value<double>(), 20.0);
ASSERT_EQ(joint_3_pos_cmd_.get_value<double>(), 30.0);
}

TEST_F(JointGroupPositionControllerTest, WrongCommandCheckTest)
@@ -142,9 +142,9 @@ TEST_F(JointGroupPositionControllerTest, WrongCommandCheckTest)
controller_interface::return_type::ERROR);

// check joint commands are still the default ones
ASSERT_EQ(joint_1_pos_cmd_.get_value(), 1.1);
ASSERT_EQ(joint_2_pos_cmd_.get_value(), 2.1);
ASSERT_EQ(joint_3_pos_cmd_.get_value(), 3.1);
ASSERT_EQ(joint_1_pos_cmd_.get_value<double>(), 1.1);
ASSERT_EQ(joint_2_pos_cmd_.get_value<double>(), 2.1);
ASSERT_EQ(joint_3_pos_cmd_.get_value<double>(), 3.1);
}

TEST_F(JointGroupPositionControllerTest, NoCommandCheckTest)
@@ -159,9 +159,9 @@ TEST_F(JointGroupPositionControllerTest, NoCommandCheckTest)
controller_interface::return_type::OK);

// check joint commands are still the default ones
ASSERT_EQ(joint_1_pos_cmd_.get_value(), 1.1);
ASSERT_EQ(joint_2_pos_cmd_.get_value(), 2.1);
ASSERT_EQ(joint_3_pos_cmd_.get_value(), 3.1);
ASSERT_EQ(joint_1_pos_cmd_.get_value<double>(), 1.1);
ASSERT_EQ(joint_2_pos_cmd_.get_value<double>(), 2.1);
ASSERT_EQ(joint_3_pos_cmd_.get_value<double>(), 3.1);
}

TEST_F(JointGroupPositionControllerTest, CommandCallbackTest)
@@ -170,9 +170,9 @@ TEST_F(JointGroupPositionControllerTest, CommandCallbackTest)
controller_->get_node()->set_parameter({"joints", joint_names_});

// default values
ASSERT_EQ(joint_1_pos_cmd_.get_value(), 1.1);
ASSERT_EQ(joint_2_pos_cmd_.get_value(), 2.1);
ASSERT_EQ(joint_3_pos_cmd_.get_value(), 3.1);
ASSERT_EQ(joint_1_pos_cmd_.get_value<double>(), 1.1);
ASSERT_EQ(joint_2_pos_cmd_.get_value<double>(), 2.1);
ASSERT_EQ(joint_3_pos_cmd_.get_value<double>(), 3.1);

auto node_state = controller_->get_node()->configure();
ASSERT_EQ(node_state.id(), lifecycle_msgs::msg::State::PRIMARY_STATE_INACTIVE);
@@ -203,7 +203,7 @@ TEST_F(JointGroupPositionControllerTest, CommandCallbackTest)
controller_interface::return_type::OK);

// check command in handle was set
ASSERT_EQ(joint_1_pos_cmd_.get_value(), 10.0);
ASSERT_EQ(joint_2_pos_cmd_.get_value(), 20.0);
ASSERT_EQ(joint_3_pos_cmd_.get_value(), 30.0);
ASSERT_EQ(joint_1_pos_cmd_.get_value<double>(), 10.0);
ASSERT_EQ(joint_2_pos_cmd_.get_value<double>(), 20.0);
ASSERT_EQ(joint_3_pos_cmd_.get_value<double>(), 30.0);
}
22 changes: 12 additions & 10 deletions tricycle_controller/test/test_tricycle_controller.cpp
Original file line number Diff line number Diff line change
@@ -289,8 +289,8 @@ TEST_F(TestTricycleController, cleanup)
ASSERT_EQ(State::PRIMARY_STATE_UNCONFIGURED, state.id());

// should be stopped
EXPECT_EQ(0.0, steering_joint_pos_cmd_.get_value());
EXPECT_EQ(0.0, traction_joint_vel_cmd_.get_value());
EXPECT_EQ(0.0, steering_joint_pos_cmd_.get_value<double>());
EXPECT_EQ(0.0, traction_joint_vel_cmd_.get_value<double>());

executor.cancel();
}
@@ -310,8 +310,8 @@ TEST_F(TestTricycleController, correct_initialization_using_parameters)
assignResources();

ASSERT_EQ(State::PRIMARY_STATE_INACTIVE, state.id());
EXPECT_EQ(position_, steering_joint_pos_cmd_.get_value());
EXPECT_EQ(velocity_, traction_joint_vel_cmd_.get_value());
EXPECT_EQ(position_, steering_joint_pos_cmd_.get_value<double>());
EXPECT_EQ(velocity_, traction_joint_vel_cmd_.get_value<double>());

state = controller_->get_node()->activate();
ASSERT_EQ(State::PRIMARY_STATE_ACTIVE, state.id());
@@ -326,8 +326,8 @@ TEST_F(TestTricycleController, correct_initialization_using_parameters)
ASSERT_EQ(
controller_->update(rclcpp::Time(0, 0, RCL_ROS_TIME), rclcpp::Duration::from_seconds(0.01)),
controller_interface::return_type::OK);
EXPECT_EQ(0.0, steering_joint_pos_cmd_.get_value());
EXPECT_EQ(1.0, traction_joint_vel_cmd_.get_value());
EXPECT_EQ(0.0, steering_joint_pos_cmd_.get_value<double>());
EXPECT_EQ(1.0, traction_joint_vel_cmd_.get_value<double>());

// deactivated
// wait so controller process the second point when deactivated
@@ -338,14 +338,16 @@ TEST_F(TestTricycleController, correct_initialization_using_parameters)
controller_->update(rclcpp::Time(0, 0, RCL_ROS_TIME), rclcpp::Duration::from_seconds(0.01)),
controller_interface::return_type::OK);

EXPECT_EQ(0.0, steering_joint_pos_cmd_.get_value()) << "Wheels are halted on deactivate()";
EXPECT_EQ(0.0, traction_joint_vel_cmd_.get_value()) << "Wheels are halted on deactivate()";
EXPECT_EQ(0.0, steering_joint_pos_cmd_.get_value<double>())
<< "Wheels are halted on deactivate()";
EXPECT_EQ(0.0, traction_joint_vel_cmd_.get_value<double>())
<< "Wheels are halted on deactivate()";

// cleanup
state = controller_->get_node()->cleanup();
ASSERT_EQ(State::PRIMARY_STATE_UNCONFIGURED, state.id());
EXPECT_EQ(0.0, steering_joint_pos_cmd_.get_value());
EXPECT_EQ(0.0, traction_joint_vel_cmd_.get_value());
EXPECT_EQ(0.0, steering_joint_pos_cmd_.get_value<double>());
EXPECT_EQ(0.0, traction_joint_vel_cmd_.get_value<double>());

state = controller_->get_node()->configure();
ASSERT_EQ(State::PRIMARY_STATE_INACTIVE, state.id());
48 changes: 24 additions & 24 deletions velocity_controllers/test/test_joint_group_velocity_controller.cpp
Original file line number Diff line number Diff line change
@@ -105,9 +105,9 @@ TEST_F(JointGroupVelocityControllerTest, CommandSuccessTest)
controller_interface::return_type::OK);

// check joint commands are still the default ones
ASSERT_EQ(joint_1_cmd_.get_value(), 1.1);
ASSERT_EQ(joint_2_cmd_.get_value(), 2.1);
ASSERT_EQ(joint_3_cmd_.get_value(), 3.1);
ASSERT_EQ(joint_1_cmd_.get_value<double>(), 1.1);
ASSERT_EQ(joint_2_cmd_.get_value<double>(), 2.1);
ASSERT_EQ(joint_3_cmd_.get_value<double>(), 3.1);

// send command
auto command_ptr = std::make_shared<forward_command_controller::CmdType>();
@@ -120,9 +120,9 @@ TEST_F(JointGroupVelocityControllerTest, CommandSuccessTest)
controller_interface::return_type::OK);

// check joint commands have been modified
ASSERT_EQ(joint_1_cmd_.get_value(), 10.0);
ASSERT_EQ(joint_2_cmd_.get_value(), 20.0);
ASSERT_EQ(joint_3_cmd_.get_value(), 30.0);
ASSERT_EQ(joint_1_cmd_.get_value<double>(), 10.0);
ASSERT_EQ(joint_2_cmd_.get_value<double>(), 20.0);
ASSERT_EQ(joint_3_cmd_.get_value<double>(), 30.0);
}

TEST_F(JointGroupVelocityControllerTest, WrongCommandCheckTest)
@@ -142,9 +142,9 @@ TEST_F(JointGroupVelocityControllerTest, WrongCommandCheckTest)
controller_interface::return_type::ERROR);

// check joint commands are still the default ones
ASSERT_EQ(joint_1_cmd_.get_value(), 1.1);
ASSERT_EQ(joint_2_cmd_.get_value(), 2.1);
ASSERT_EQ(joint_3_cmd_.get_value(), 3.1);
ASSERT_EQ(joint_1_cmd_.get_value<double>(), 1.1);
ASSERT_EQ(joint_2_cmd_.get_value<double>(), 2.1);
ASSERT_EQ(joint_3_cmd_.get_value<double>(), 3.1);
}

TEST_F(JointGroupVelocityControllerTest, NoCommandCheckTest)
@@ -159,9 +159,9 @@ TEST_F(JointGroupVelocityControllerTest, NoCommandCheckTest)
controller_interface::return_type::OK);

// check joint commands are still the default ones
ASSERT_EQ(joint_1_cmd_.get_value(), 1.1);
ASSERT_EQ(joint_2_cmd_.get_value(), 2.1);
ASSERT_EQ(joint_3_cmd_.get_value(), 3.1);
ASSERT_EQ(joint_1_cmd_.get_value<double>(), 1.1);
ASSERT_EQ(joint_2_cmd_.get_value<double>(), 2.1);
ASSERT_EQ(joint_3_cmd_.get_value<double>(), 3.1);
}

TEST_F(JointGroupVelocityControllerTest, CommandCallbackTest)
@@ -170,9 +170,9 @@ TEST_F(JointGroupVelocityControllerTest, CommandCallbackTest)
controller_->get_node()->set_parameter({"joints", joint_names_});

// default values
ASSERT_EQ(joint_1_cmd_.get_value(), 1.1);
ASSERT_EQ(joint_2_cmd_.get_value(), 2.1);
ASSERT_EQ(joint_3_cmd_.get_value(), 3.1);
ASSERT_EQ(joint_1_cmd_.get_value<double>(), 1.1);
ASSERT_EQ(joint_2_cmd_.get_value<double>(), 2.1);
ASSERT_EQ(joint_3_cmd_.get_value<double>(), 3.1);

auto node_state = controller_->get_node()->configure();
ASSERT_EQ(node_state.id(), lifecycle_msgs::msg::State::PRIMARY_STATE_INACTIVE);
@@ -203,9 +203,9 @@ TEST_F(JointGroupVelocityControllerTest, CommandCallbackTest)
controller_interface::return_type::OK);

// check command in handle was set
ASSERT_EQ(joint_1_cmd_.get_value(), 10.0);
ASSERT_EQ(joint_2_cmd_.get_value(), 20.0);
ASSERT_EQ(joint_3_cmd_.get_value(), 30.0);
ASSERT_EQ(joint_1_cmd_.get_value<double>(), 10.0);
ASSERT_EQ(joint_2_cmd_.get_value<double>(), 20.0);
ASSERT_EQ(joint_3_cmd_.get_value<double>(), 30.0);
}

TEST_F(JointGroupVelocityControllerTest, StopJointsOnDeactivateTest)
@@ -217,15 +217,15 @@ TEST_F(JointGroupVelocityControllerTest, StopJointsOnDeactivateTest)
ASSERT_EQ(controller_->on_configure(rclcpp_lifecycle::State()), CallbackReturn::SUCCESS);

// check joint commands are still the default ones
ASSERT_EQ(joint_1_cmd_.get_value(), 1.1);
ASSERT_EQ(joint_2_cmd_.get_value(), 2.1);
ASSERT_EQ(joint_3_cmd_.get_value(), 3.1);
ASSERT_EQ(joint_1_cmd_.get_value<double>(), 1.1);
ASSERT_EQ(joint_2_cmd_.get_value<double>(), 2.1);
ASSERT_EQ(joint_3_cmd_.get_value<double>(), 3.1);

// stop the controller
ASSERT_EQ(controller_->on_deactivate(rclcpp_lifecycle::State()), CallbackReturn::SUCCESS);

// check joint commands are now zero
ASSERT_EQ(joint_1_cmd_.get_value(), 0.0);
ASSERT_EQ(joint_2_cmd_.get_value(), 0.0);
ASSERT_EQ(joint_3_cmd_.get_value(), 0.0);
ASSERT_EQ(joint_1_cmd_.get_value<double>(), 0.0);
ASSERT_EQ(joint_2_cmd_.get_value<double>(), 0.0);
ASSERT_EQ(joint_3_cmd_.get_value<double>(), 0.0);
}