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

Gpio command controller #1251

Merged
merged 68 commits into from
Nov 18, 2024
Merged
Changes from 1 commit
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
5fecf27
added gpio_command_controller
mcbed Nov 2, 2022
6ffda9d
added doc to gpio controllers
mcbed Nov 2, 2022
f88fc7d
changed parameter interface_names to command_interfaces
mcbed Nov 2, 2022
56fc1e5
added test
mcbed Nov 2, 2022
9e73ab7
code formating
mcbed Nov 2, 2022
1cbd3a6
added gpio state publisher
Nov 2, 2022
7228e06
fixed broken node_state
Nov 2, 2022
880aeea
added DynamicJointState message for Gpio state
Nov 2, 2022
94befb0
fixed tests and added gpio state tests
Nov 2, 2022
882c936
fixed format
Nov 16, 2022
efce87a
Apply pre-commit fix
Wiktor-99 Jul 31, 2024
b53bff6
Fix compilation on ros rolling
Wiktor-99 Aug 1, 2024
67b6069
Add parameters file, use generated gpio_command_controller_parameters…
Wiktor-99 Aug 3, 2024
30d2604
Remove unnecessary members: interface_names_, gpios_names_ and use pa…
Wiktor-99 Aug 4, 2024
4c824e8
Refactor of storing interface types
Wiktor-99 Aug 4, 2024
dd86d9e
Remove unnecessary includes
Wiktor-99 Aug 4, 2024
4ac938d
Refacotr on_activate method. Add validate_configured_interfaces and i…
Wiktor-99 Aug 4, 2024
aa59297
Refactor update method, split update of state if and command if
Wiktor-99 Aug 4, 2024
6276617
Move test fixture form hpp to cpp
Wiktor-99 Aug 4, 2024
66bd971
Update docks and package.xml
Wiktor-99 Aug 4, 2024
7b70159
Add state validation
Wiktor-99 Aug 4, 2024
58c1afc
Store command and state ifs in the map
Wiktor-99 Aug 5, 2024
e5c65db
Use interface maps for command and state update. Use DynamicJointStat…
Wiktor-99 Aug 5, 2024
0dc5c87
Use ordered state if vector instead of map
Wiktor-99 Aug 6, 2024
765a3cb
Restore state if validation
Wiktor-99 Aug 6, 2024
a1c8fa3
Align logging
Wiktor-99 Aug 6, 2024
de8acba
Update code layout
Wiktor-99 Aug 7, 2024
aebbf0b
Simplifie test fixture
Wiktor-99 Aug 7, 2024
0deb417
Update tests. Stop using pointer, set members as public
Wiktor-99 Aug 7, 2024
3e7a12a
Add set of test for init
Wiktor-99 Aug 9, 2024
373053e
Add setup_command_and_state_interfaces as refactor UTs
Wiktor-99 Aug 13, 2024
1dc481f
Add two UTs to check wrong ifs assing
Wiktor-99 Aug 15, 2024
2bad07b
Add create node option function and remove redundant test
Wiktor-99 Aug 15, 2024
f78158e
Extract redundant code to methods
Wiktor-99 Aug 15, 2024
815f85e
Reafactor command UTs
Wiktor-99 Aug 16, 2024
0265503
Add two UTs for different commands
Wiktor-99 Aug 16, 2024
28db5aa
Add one more test with command with different ports order
Wiktor-99 Aug 16, 2024
4be8fac
Add UT for the wrong gpio/port name in the command
Wiktor-99 Aug 17, 2024
fc10ad5
Update package.xml
Wiktor-99 Aug 17, 2024
1ac37e4
Merge branch 'master' into gpio_controllers
Wiktor-99 Aug 17, 2024
e89d814
Update pkg version
Wiktor-99 Aug 22, 2024
9c90fb2
Fix includes
Wiktor-99 Aug 22, 2024
c165c1d
Fix linters
Wiktor-99 Aug 24, 2024
dd19879
Update toctree, add gpio controller info
Wiktor-99 Aug 24, 2024
b3d9ef4
Merge branch 'master' into gpio_controllers
Wiktor-99 Aug 26, 2024
4b60038
Merge branch 'master' into gpio_controllers
Wiktor-99 Sep 9, 2024
9fb380a
Merge branch 'master' into gpio_controllers
Wiktor-99 Sep 22, 2024
a2b1f4f
Merge branch 'master' into gpio_controllers
bmagyar Sep 26, 2024
b2eab6a
Merge branch 'master' into gpio_controllers
christophfroehlich Nov 3, 2024
510d847
Rename parameter and update docs
christophfroehlich Nov 3, 2024
4518b58
Set parameter read-only
christophfroehlich Nov 3, 2024
071e190
Update docs and improve error message
christophfroehlich Nov 3, 2024
fdfe17b
Fix tests
christophfroehlich Nov 3, 2024
8a8cd04
Merge pull request #2 from ros-controls/gpio_controllers
Wiktor-99 Nov 4, 2024
1e61111
Parametrize state interfaces
Wiktor-99 Nov 4, 2024
9929eb1
Parse URDF to get gpio state interfaces, add test and docs
Wiktor-99 Nov 4, 2024
13ba72b
Remove urdf model from controller
Wiktor-99 Nov 5, 2024
a8228af
Update docs after review
Wiktor-99 Nov 7, 2024
7bf2d4e
Create command subscriber only when any command interface is present.…
Wiktor-99 Nov 7, 2024
a8bc556
Merge branch 'master' into gpio_controllers
christophfroehlich Nov 11, 2024
9c30814
Update pkg xmls
Wiktor-99 Nov 16, 2024
39d885a
Add control_msgs to CMakeLists
Wiktor-99 Nov 16, 2024
305ab61
Use DynamicInterfaceGroupValues instead of DynamicInterfaceValues
Wiktor-99 Nov 16, 2024
2f49765
Merge branch 'master' into gpio_controllers
christophfroehlich Nov 17, 2024
5c32a72
Add gpio_controllers to the release_notes and add minor fixes to the …
Wiktor-99 Nov 18, 2024
4cd5772
Update compile flags
christophfroehlich Nov 18, 2024
6ef4023
Fix format
christophfroehlich Nov 18, 2024
bc3eb30
Merge branch 'master' into gpio_controllers
christophfroehlich Nov 18, 2024
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
Prev Previous commit
Next Next commit
Simplifie test fixture
  • Loading branch information
Wiktor-99 committed Aug 7, 2024
commit aebbf0b966895fbdd28e187c0f875a911d3a9d03
59 changes: 24 additions & 35 deletions gpio_controllers/test/test_gpio_command_controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#include <stddef.h>

#include <functional>
#include <memory>
#include <string>
Expand All @@ -40,22 +38,24 @@ using hardware_interface::StateInterface;

class FriendGpioCommandController : public gpio_controllers::GpioCommandController
{
FRIEND_TEST(GpioCommandControllerTest, CommandSuccessTest);
FRIEND_TEST(GpioCommandControllerTest, CommandSuccessTestWithOnlyOneGpio);
FRIEND_TEST(GpioCommandControllerTest, CommandCallbackTest);
FRIEND_TEST(GpioCommandControllerTestSuite, CommandSuccessTest);
FRIEND_TEST(GpioCommandControllerTestSuite, CommandSuccessTestWithOnlyOneGpio);
FRIEND_TEST(GpioCommandControllerTestSuite, CommandCallbackTest);
};

class GpioCommandControllerTest : public ::testing::Test
class GpioCommandControllerTestSuite : public ::testing::Test
{
public:
static void SetUpTestCase();
static void TearDownTestCase();

void SetUp();
void TearDown();

void SetUpController();
void SetUpHandles();
GpioCommandControllerTestSuite()
{
controller_ = std::make_unique<FriendGpioCommandController>();
rclcpp::init(0, nullptr);
}
~GpioCommandControllerTestSuite()
{
rclcpp::shutdown();
controller_.reset(nullptr);
}

protected:
std::unique_ptr<FriendGpioCommandController> controller_;
Expand All @@ -73,25 +73,14 @@ class GpioCommandControllerTest : public ::testing::Test
StateInterface gpio_2_ana_state_{gpio_names_[1], "ana.1", &gpio_states_[2]};
};

void GpioCommandControllerTest::SetUpTestCase() { rclcpp::init(0, nullptr); }

void GpioCommandControllerTest::TearDownTestCase() { rclcpp::shutdown(); }

void GpioCommandControllerTest::SetUp()
{
controller_ = std::make_unique<FriendGpioCommandController>();
}

void GpioCommandControllerTest::TearDown() { controller_.reset(nullptr); }

TEST_F(GpioCommandControllerTest, GpiosParameterNotSet)
TEST_F(GpioCommandControllerTestSuite, GpiosParameterNotSet)
{
const auto result = controller_->init(
"test_gpio_command_controller", "", 0, "", controller_->define_custom_node_options());
ASSERT_EQ(result, controller_interface::return_type::ERROR);
}

TEST_F(GpioCommandControllerTest, GpiosParameterIsEmpty)
TEST_F(GpioCommandControllerTestSuite, GpiosParameterIsEmpty)
{
std::vector<rclcpp::Parameter> parameters;
parameters.emplace_back("gpios", std::vector<std::string>{});
Expand All @@ -102,7 +91,7 @@ TEST_F(GpioCommandControllerTest, GpiosParameterIsEmpty)
ASSERT_EQ(result, controller_interface::return_type::ERROR);
}

TEST_F(GpioCommandControllerTest, GpioWithMissingGpioParams)
TEST_F(GpioCommandControllerTestSuite, GpioWithMissingGpioParams)
{
std::vector<rclcpp::Parameter> parameters;
parameters.emplace_back("gpios", std::vector<std::string>{"gpio1", "gpio2"});
Expand All @@ -116,7 +105,7 @@ TEST_F(GpioCommandControllerTest, GpioWithMissingGpioParams)
ASSERT_EQ(result, controller_interface::return_type::ERROR);
}

TEST_F(GpioCommandControllerTest, ConfigureAndActivateParamsSuccess)
TEST_F(GpioCommandControllerTestSuite, ConfigureAndActivateParamsSuccess)
{
std::vector<rclcpp::Parameter> parameters;
parameters.emplace_back("gpios", gpio_names_);
Expand Down Expand Up @@ -144,7 +133,7 @@ TEST_F(GpioCommandControllerTest, ConfigureAndActivateParamsSuccess)
ASSERT_EQ(controller_->on_activate(rclcpp_lifecycle::State()), CallbackReturn::SUCCESS);
}

TEST_F(GpioCommandControllerTest, ActivateWithWrongGpiosNamesFails)
TEST_F(GpioCommandControllerTestSuite, ActivateWithWrongGpiosNamesFails)
{
std::vector<rclcpp::Parameter> parameters;
parameters.emplace_back("gpios", std::vector<std::string>{"gpio1", "gpio4"});
Expand Down Expand Up @@ -172,7 +161,7 @@ TEST_F(GpioCommandControllerTest, ActivateWithWrongGpiosNamesFails)
ASSERT_EQ(controller_->on_activate(rclcpp_lifecycle::State()), CallbackReturn::ERROR);
}

TEST_F(GpioCommandControllerTest, CommandSuccessTest)
TEST_F(GpioCommandControllerTestSuite, CommandSuccessTest)
{
std::vector<rclcpp::Parameter> parameters;
parameters.emplace_back("gpios", std::vector<std::string>{"gpio1", "gpio2"});
Expand Down Expand Up @@ -227,7 +216,7 @@ TEST_F(GpioCommandControllerTest, CommandSuccessTest)
ASSERT_EQ(gpio_2_ana_cmd_.get_value(), 30.0);
}

TEST_F(GpioCommandControllerTest, CommandSuccessTestWithOnlyOneGpio)
TEST_F(GpioCommandControllerTestSuite, CommandSuccessTestWithOnlyOneGpio)
{
std::vector<rclcpp::Parameter> parameters;
parameters.emplace_back("gpios", std::vector<std::string>{"gpio1", "gpio2"});
Expand Down Expand Up @@ -271,7 +260,7 @@ TEST_F(GpioCommandControllerTest, CommandSuccessTestWithOnlyOneGpio)
ASSERT_EQ(gpio_2_ana_cmd_.get_value(), 3.1);
}

TEST_F(GpioCommandControllerTest, NoCommandCheckTest)
TEST_F(GpioCommandControllerTestSuite, NoCommandCheckTest)
{
std::vector<rclcpp::Parameter> parameters;
parameters.emplace_back("gpios", std::vector<std::string>{"gpio1", "gpio2"});
Expand Down Expand Up @@ -307,7 +296,7 @@ TEST_F(GpioCommandControllerTest, NoCommandCheckTest)
ASSERT_EQ(gpio_2_ana_cmd_.get_value(), 3.1);
}

TEST_F(GpioCommandControllerTest, CommandCallbackTest)
TEST_F(GpioCommandControllerTestSuite, CommandCallbackTest)
{
std::vector<rclcpp::Parameter> parameters;
parameters.emplace_back("gpios", std::vector<std::string>{"gpio1", "gpio2"});
Expand Down Expand Up @@ -381,7 +370,7 @@ TEST_F(GpioCommandControllerTest, CommandCallbackTest)
ASSERT_EQ(gpio_2_ana_cmd_.get_value(), 30.0);
}

TEST_F(GpioCommandControllerTest, StateCallbackTest)
TEST_F(GpioCommandControllerTestSuite, StateCallbackTest)
{
std::vector<rclcpp::Parameter> parameters;
parameters.emplace_back("gpios", std::vector<std::string>{"gpio1", "gpio2"});
Expand Down