Skip to content

Commit

Permalink
Fixed utils test, fixed joy
Browse files Browse the repository at this point in the history
Signed-off-by: Jakub Delicat <[email protected]>
  • Loading branch information
delihus committed Nov 8, 2024
1 parent 4189b20 commit 3bd5e30
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 10 deletions.
6 changes: 3 additions & 3 deletions panther_manager/src/plugins/condition/check_joy_msg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ bool CheckJoyMsg::checkAxes(const JoyMsg::SharedPtr & last_msg)
return true;
}

if (last_msg->axes.size() != expected_axes.size()) {
if (last_msg->axes.size() < expected_axes.size()) {
RCLCPP_WARN_STREAM(
this->logger(), GetLoggerPrefix(name())
<< "Joy message has " << last_msg->axes.size()
Expand All @@ -57,11 +57,11 @@ bool CheckJoyMsg::checkButtons(const JoyMsg::SharedPtr & last_msg)
return true;
}

if (last_msg->buttons.size() != expected_buttons.size()) {
if (last_msg->buttons.size() < expected_buttons.size()) {
RCLCPP_WARN_STREAM(
this->logger(), GetLoggerPrefix(name())
<< "Joy message has " << last_msg->buttons.size()
<< " axes, expected at least " << expected_buttons.size());
<< " buttons, expected at least " << expected_buttons.size());
return false;
}

Expand Down
18 changes: 12 additions & 6 deletions panther_manager/test/plugins/condition/test_check_joy_msg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,21 @@ TEST_F(TestCheckJoyMsg, OnTickBehavior)
{BT::NodeStatus::SUCCESS,
{{"topic_name", TOPIC}, {"axes", "0.1;-0.2;1.0"}, {"buttons", ""}, {"timeout", "1.0"}},
CreateMsg({0.1, -0.2, 1.0}, {0, 0, 10, 0})},
{BT::NodeStatus::SUCCESS,
{{"topic_name", TOPIC}, {"axes", "0;0"}, {"buttons", "0;0"}, {"timeout", "1.0"}},
CreateMsg({0, 0, 0}, {0, 0})},
{BT::NodeStatus::SUCCESS,
{{"topic_name", TOPIC}, {"axes", "0;0"}, {"buttons", "0;0"}, {"timeout", "1.0"}},
CreateMsg({0, 0}, {0, 0, 0})},
{BT::NodeStatus::SUCCESS,
{{"topic_name", TOPIC}, {"axes", "0.1;-0.2;1.0"}, {"buttons", ""}, {"timeout", "1.0"}},
CreateMsg({0.1, -0.2, 1.0, 0.0, 0.0}, {0, 0, 10, 0})},
{BT::NodeStatus::SUCCESS,
{{"topic_name", TOPIC}, {"axes", ""}, {"buttons", "0;0;10;0"}, {"timeout", "1.0"}},
CreateMsg({0.1, -0.2, 1.0}, {0, 0, 10, 0})},
{BT::NodeStatus::SUCCESS,
{{"topic_name", TOPIC}, {"axes", ""}, {"buttons", "0;0;10;0"}, {"timeout", "1.0"}},
CreateMsg({0.1, -0.2, 1.0}, {0, 0, 10, 0, 0, 0})},
{BT::NodeStatus::FAILURE,
{{"topic_name", TOPIC}, {"axes", "0.1;-0.2;1.0"}, {"buttons", "0;0;10;0"}, {"timeout", "1.0"}},
CreateMsg({0.2, -0.2, 1.0}, {0, 0, 10, 0})},
Expand All @@ -147,12 +159,6 @@ TEST_F(TestCheckJoyMsg, OnTickBehavior)
{BT::NodeStatus::FAILURE,
{{"topic_name", TOPIC}, {"axes", "0;0"}, {"buttons", "0;0;0"}, {"timeout", "1.0"}},
CreateMsg({0, 0}, {0, 0})},
{BT::NodeStatus::FAILURE,
{{"topic_name", TOPIC}, {"axes", "0;0"}, {"buttons", "0;0"}, {"timeout", "1.0"}},
CreateMsg({0, 0, 0}, {0, 0})},
{BT::NodeStatus::FAILURE,
{{"topic_name", TOPIC}, {"axes", "0;0"}, {"buttons", "0;0"}, {"timeout", "1.0"}},
CreateMsg({0, 0}, {0, 0, 0})},
{BT::NodeStatus::FAILURE,
{{"topic_name", TOPIC}, {"axes", "0;0"}, {"buttons", "0;0"}, {"timeout", "1.0"}},
CreateMsg({0, 1}, {0, 0})},
Expand Down
2 changes: 1 addition & 1 deletion panther_manager/test/test_behavior_tree_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ TEST(TestConvertFromStringVectorOfDouble, GoodInput)
TEST(TestConvertFromStringVectorOfFloat, WrongInput)
{
auto str = "1;2;3;0.1;a;0.2";
EXPECT_THROW(BT::convertFromString<std::vector<float>>(str), BT::RuntimeError);
EXPECT_THROW(BT::convertFromString<std::vector<float>>(str);, std::invalid_argument);
}

int main(int argc, char ** argv)
Expand Down

0 comments on commit 3bd5e30

Please sign in to comment.