-
Notifications
You must be signed in to change notification settings - Fork 10
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
JoySubscription BT node #397
Conversation
Signed-off-by: Jakub Delicat <[email protected]>
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Base branches to auto review (1)
Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the WalkthroughThe changes introduce a new shared library for Changes
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 4
Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Files selected for processing (16)
- panther_manager/CMakeLists.txt (2 hunks)
- panther_manager/include/panther_manager/behavior_tree_utils.hpp (1 hunks)
- panther_manager/include/panther_manager/plugins/action/joy_subscription_node.hpp (1 hunks)
- panther_manager/package.xml (1 hunks)
- panther_manager/src/plugins/action/joy_subscription_node.cpp (1 hunks)
- panther_manager/test/plugins/action/test_call_set_bool_service_node.cpp (1 hunks)
- panther_manager/test/plugins/action/test_call_set_led_animation_service_node.cpp (1 hunks)
- panther_manager/test/plugins/action/test_call_trigger_service_node.cpp (1 hunks)
- panther_manager/test/plugins/action/test_joy_subscription_node.cpp (1 hunks)
- panther_manager/test/plugins/action/test_shutdown_hosts_from_file_node.cpp (1 hunks)
- panther_manager/test/plugins/action/test_shutdown_single_host_node.cpp (1 hunks)
- panther_manager/test/plugins/action/test_signal_shutdown_node.cpp (1 hunks)
- panther_manager/test/plugins/decorator/test_tick_after_timeout_node.cpp (1 hunks)
- panther_manager/test/plugins/test_shutdown_host.cpp (1 hunks)
- panther_manager/test/plugins/test_shutdown_hosts_node.cpp (1 hunks)
- panther_manager/test/test_behavior_tree_utils.cpp (1 hunks)
Files skipped from review due to trivial changes (9)
- panther_manager/test/plugins/action/test_call_set_bool_service_node.cpp
- panther_manager/test/plugins/action/test_call_set_led_animation_service_node.cpp
- panther_manager/test/plugins/action/test_call_trigger_service_node.cpp
- panther_manager/test/plugins/action/test_shutdown_hosts_from_file_node.cpp
- panther_manager/test/plugins/action/test_shutdown_single_host_node.cpp
- panther_manager/test/plugins/action/test_signal_shutdown_node.cpp
- panther_manager/test/plugins/decorator/test_tick_after_timeout_node.cpp
- panther_manager/test/plugins/test_shutdown_host.cpp
- panther_manager/test/plugins/test_shutdown_hosts_node.cpp
Additional comments not posted (11)
panther_manager/package.xml (1)
29-29
: Dependency onsensor_msgs
is appropriate for joystick input handling.The addition of
sensor_msgs
as a dependency is necessary for handling joystick messages, which aligns with the PR's objectives to enhance interactive control of robotic actions. This change is well-justified and integrates seamlessly with the existing dependencies.panther_manager/test/plugins/action/test_joy_subscription_node.cpp (7)
47-52
: Review ofPublishJoyMessage
method.The method correctly constructs and publishes a
sensor_msgs::msg::Joy
message. The use of vector for buttons is appropriate and matches the expected message format.This method is implemented correctly and follows ROS message publishing conventions.
54-57
: Test case review: Loading theJoySubscription
plugin.This test validates that the
JoySubscription
node can be loaded correctly using the provided parameters.The test is well-structured and effectively checks the plugin's loadability without errors.
59-66
: Test case review: Handling no joystick message.This test effectively checks the
JoySubscription
node's behavior when no messages are published. The expected status isFAILURE
, which is correctly asserted.The test is correctly designed to validate the node's behavior in the absence of input, adhering to the expected behavior described in the node's documentation.
68-77
: Test case review: Handling joystick message with too few buttons.This test correctly simulates a scenario where the joystick message does not meet the expected button count, leading to a
FAILURE
status.The test is well-implemented to check the node's robustness against insufficient input data, aligning with the expected functionality.
79-88
: Test case review: Correct button count but incorrect state.This test effectively evaluates the node's response to a joystick message with the correct number of buttons but incorrect states, resulting in a
FAILURE
.The test is appropriately designed to assess the node's functionality when the input meets the size criteria but fails state validation.
90-99
: Test case review: Excess buttons but correct initial states.This test accurately assesses the
JoySubscription
node's ability to handle joystick messages with more buttons than necessary, provided the required initial states are correct, resulting in aSUCCESS
.The test is well-designed to verify the node's tolerance for additional buttons beyond the specified configuration, as long as the necessary conditions are met.
101-110
: Test case review: Correct button count and correct state.This test effectively evaluates the
JoySubscription
node's response to a joystick message with the correct number of buttons and states, resulting in aSUCCESS
.The test is correctly designed to validate the node's functionality when the input fully meets the specified requirements.
panther_manager/CMakeLists.txt (2)
54-56
: Properly added new library forjoy_subscription_bt_node
.The library
joy_subscription_bt_node
is correctly defined as a shared library and added to theplugin_libs
list. This ensures it will be linked and compiled with the appropriate flags and dependencies as defined later in the CMakeLists.txt.
143-147
: Correct setup for testingjoy_subscription_bt_node
.The test for
joy_subscription_bt_node
is properly set up usingament_add_gtest
. This includes both the test file and the source file, ensuring that the node is tested in isolation. It's also correctly appended to theplugin_tests
list, which likely is used to manage all test targets.panther_manager/test/test_behavior_tree_utils.cpp (1)
124-152
: Review of unit tests forconvertFromString<std::vector<int>>
The unit tests provided for the
convertFromString<std::vector<int>>
function are comprehensive and cover various edge cases effectively. The tests are well-structured and use the Google Test framework appropriately.
- Test
GoodVectorInt
: Validates the correct parsing and vector creation from a semicolon-separated string of integers.- Test
EmptyVectorInt
: Ensures that an empty input string correctly throws aBT::RuntimeError
, which is consistent with the function's error handling strategy.- Test
InvalidVectorIntWithFloat
andInvalidVectorIntWithLetter
: These tests check the function's robustness against invalid input formats, ensuring that it throws exceptions as expected.Overall, these tests are well-implemented and should effectively safeguard the functionality of the
convertFromString<std::vector<int>>
method.
panther_manager/include/panther_manager/plugins/action/joy_subscription_node.hpp
Outdated
Show resolved
Hide resolved
panther_manager/test/plugins/action/test_joy_subscription_node.cpp
Outdated
Show resolved
Hide resolved
panther_manager/include/panther_manager/behavior_tree_utils.hpp
Outdated
Show resolved
Hide resolved
panther_manager/include/panther_manager/behavior_tree_utils.hpp
Outdated
Show resolved
Hide resolved
panther_manager/include/panther_manager/plugins/action/joy_subscription_node.hpp
Outdated
Show resolved
Hide resolved
panther_manager/include/panther_manager/plugins/action/joy_subscription_node.hpp
Outdated
Show resolved
Hide resolved
panther_manager/include/panther_manager/plugins/action/joy_subscription_node.hpp
Outdated
Show resolved
Hide resolved
Signed-off-by: Jakub Delicat <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Files selected for processing (5)
- panther_manager/CMakeLists.txt (2 hunks)
- panther_manager/include/panther_manager/behavior_tree_utils.hpp (1 hunks)
- panther_manager/include/panther_manager/plugins/condition/are_buttons_pressed.hpp (1 hunks)
- panther_manager/src/plugins/condition/are_buttons_pressed.cpp (1 hunks)
- panther_manager/test/plugins/condition/test_are_buttons_pressed.cpp (1 hunks)
Files skipped from review as they are similar to previous changes (2)
- panther_manager/CMakeLists.txt
- panther_manager/include/panther_manager/behavior_tree_utils.hpp
Additional comments not posted (7)
panther_manager/src/plugins/condition/are_buttons_pressed.cpp (1)
22-43
: Review the logic and error handling inonTick
.
- Null Pointer Check: The check for
last_msg
being null is appropriate and prevents dereferencing a null pointer.- Button Count Check: The method correctly checks if the received message has fewer buttons than expected, which is good for avoiding out-of-range errors.
- Button State Comparison: The use of
std::equal
assumes thatlast_msg->buttons
has at least as many elements asbuttons_
. This is implicitly guaranteed by the previous size check, but it might be clearer to explicitly mention this assumption in the comments for future maintainability.Consider adding a comment before the
std::equal
call to clarify the assumption about vector sizes being adequate due to the earlier check.The method logic is correct, but consider enhancing the comments for clarity and maintainability.
panther_manager/include/panther_manager/plugins/condition/are_buttons_pressed.hpp (1)
32-51
: Review the class design ofAreButtonsPressed
.The class is well-structured for its purpose as a Behavior Tree node handling joystick input:
- Inheritance and Constructor: Properly inherits from
BT::RosTopicSubNode
and initializes it in the constructor.- Method
onTick
: Appropriately handles the logic for checking button presses.- Method
providedPorts
: Correctly defines the input ports needed for the node to function, which is essential for integrating with the BT framework.Overall, the class design follows good OOP practices and is consistent with the Behavior Tree framework's requirements.
The class design is approved as it meets the requirements and follows best practices.
panther_manager/test/plugins/condition/test_are_buttons_pressed.cpp (5)
54-57
: Approve the test case for loading the plugin.The test case
LoadingAreButtonsPressedPlugin
correctly verifies that the plugin can be loaded without throwing exceptions, which is a fundamental check for any plugin.The test case is approved as it effectively checks the basic functionality.
59-66
: Approve the test case for handling no message scenario.The test case
NoMessage
effectively checks the node's behavior when no joystick message is received, expecting a failure status, which is the correct behavior in such a scenario.The test case is approved as it correctly tests the node's response to missing input.
68-77
: Approve the test case for handling messages with too few buttons.The test case
WrongMessageTooFewButtons
checks the node's behavior when the received joystick message has fewer buttons than expected, correctly expecting a failure status. This ensures that the node robustly handles input validation.The test case is approved as it effectively tests for proper input validation.
79-88
: Approve the test case for handling correct number of buttons with wrong states.The test case
GoodMessageWrongButtonsState
effectively evaluates the node's response when the joystick message has the correct number of buttons but the states do not match the expected configuration, correctly expecting a failure status. This test ensures that the node accurately assesses button states.The test case is approved as it thoroughly tests the node's logic in evaluating button states.
90-99
: Approve the test case for handling messages with extra buttons but correct states.The test case
GoodMessageWithTooMuchButtonsAndGoodButtonsState
checks the node's behavior when the joystick message includes more buttons than expected but contains the correct states for the required buttons, correctly expecting a success status. This test ensures that the node is flexible in handling inputs with additional data as long as the necessary conditions are met.The test case is approved as it effectively tests the node's flexibility in handling varied input sizes.
Description
JoySubscription
is a BT node for reading buttons state and run dedicated commands.Example BT tree:
Modifications
std::vector<int> convertFromString<std::vector<int>>(StringView str)
JoySubscription
result
to the manager's tests.Summary by CodeRabbit
New Features
Bug Fixes
Tests
JoySubscription
plugin to validate functionality with joystick messages.convertFromString
function to cover various input scenarios and edge cases.