-
Notifications
You must be signed in to change notification settings - Fork 11
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
ROS 2 lights initialization #365
Conversation
WalkthroughThe updates to Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant ROS2Node
participant DriverNode
participant LEDController
User->>ROS2Node: Sends Image Message
ROS2Node->>DriverNode: Publish Image Message
DriverNode->>LEDController: Process Image and Control LEDs
LEDController-->>DriverNode: LED Status
DriverNode->>User: Update Status
sequenceDiagram
participant DiagnosticSystem
participant DriverNode
participant LEDController
loop Periodic Check
DiagnosticSystem->>DriverNode: Trigger Diagnostic
DriverNode->>LEDController: Get LED Status
LEDController-->>DriverNode: Return Status
DriverNode->>DiagnosticSystem: Report Status
end
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 as PR comments)
Additionally, you can add CodeRabbit Configuration File (
|
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: 1
Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Files selected for processing (10)
- panther_lights/CMakeLists.txt (4 hunks)
- panther_lights/README.md (2 hunks)
- panther_lights/include/panther_lights/lights_controller_node.hpp (4 hunks)
- panther_lights/include/panther_lights/lights_driver_node.hpp (4 hunks)
- panther_lights/launch/lights.launch.py (3 hunks)
- panther_lights/package.xml (1 hunks)
- panther_lights/src/lights_controller_node.cpp (3 hunks)
- panther_lights/src/lights_driver_node.cpp (8 hunks)
- panther_lights/test/test_lights_controller_node.cpp (2 hunks)
- panther_lights/test/test_lights_driver_node.cpp (1 hunks)
Files skipped from review due to trivial changes (1)
- panther_lights/package.xml
Additional comments not posted (43)
panther_lights/include/panther_lights/lights_driver_node.hpp (6)
15-16
: Header guard updated correctly.The header guard has been updated to reflect the new file name.
24-24
: Include directive updated correctly.The include directive for
sensor_msgs/msg/image.hpp
has been added to replace the removedimage_transport/image_transport.hpp
.
38-44
: EnumLEDControlStatus
defined correctly.The enum
LEDControlStatus
improves code readability and maintainability.
53-53
: Constructor updated to use intra-process communication.The constructor now uses intra-process communication by default, enhancing performance.
59-59
: Member variableled_control_status_
introduced.The member variable
led_control_status_
is necessary to track the LED control status.
113-114
: Subscriber declarations updated correctly.The subscriber declarations now use
rclcpp::Subscription
instead ofimage_transport::Subscriber
.panther_lights/launch/lights.launch.py (6)
26-27
: Imports forComposableNodeContainer
andComposableNode
added correctly.These imports are necessary for the new node management approach.
62-66
:ComposableNodeContainer
initialized correctly.The
lights_container
is now initialized usingComposableNodeContainer
, enhancing modularity and performance.
68-75
:DriverNode
added as aComposableNode
.The
DriverNode
is now managed as a component within the container.
76-85
:ControllerNode
added as aComposableNode
.The
ControllerNode
is now managed as a component within the container.
96-96
:lights_container
added to actions.The
lights_container
is now included in the launch description.
Line range hint
1-99
:
Launch file structure updated correctly.The overall structure of the launch file has been updated to use composable nodes, improving modularity and performance.
panther_lights/include/panther_lights/lights_controller_node.hpp (3)
15-16
: Header guard updated correctly.The header guard has been updated to reflect the new file name.
45-45
: Constructor updated to use intra-process communication.The constructor now uses intra-process communication by default, enhancing performance.
Line range hint
1-159
:
Class structure updated correctly.The overall class structure has been updated to remove the
SetAnimation
method, ensuring consistency with the new design.panther_lights/test/test_lights_driver_node.cpp (5)
33-50
:DriverNodeWrapper
class added correctly.The
DriverNodeWrapper
class facilitates testing of theDriverNode
by providing access to protected members.
52-103
:TestDriverNode
class added correctly.The
TestDriverNode
class sets up the test environment and provides utility functions in a structured manner.
105-115
:ServiceTestSuccess
test case added correctly.The
ServiceTestSuccess
test case verifies successful service interaction with valid service requests.
117-127
:ServiceTestFail
test case added correctly.The
ServiceTestFail
test case verifies service interaction failure with invalid service requests.
1-215
: Test file structure updated correctly.The overall structure of the test file has been updated to include new test cases and classes, improving test coverage and organization.
panther_lights/CMakeLists.txt (7)
15-15
: Dependency Addition ApprovedThe addition of
find_package(rclcpp_components REQUIRED)
is necessary for the new node components.
30-38
: Addition oflights_driver_node_component
ApprovedThe addition of the
lights_driver_node_component
library and its dependencies is appropriate for the new node component.
42-54
: Addition oflights_controller_node_component
ApprovedThe addition of the
lights_controller_node_component
library and its dependencies is appropriate for the new node component.
56-58
: Registration oflights_driver_node_component
ApprovedThe registration of the
lights_driver_node_component
withrclcpp_components
is necessary for component usage.
60-62
: Registration oflights_controller_node_component
ApprovedThe registration of the
lights_controller_node_component
withrclcpp_components
is necessary for component usage.
175-189
: Addition of Test Cases forlights_controller_node
ApprovedThe addition of test cases for the
lights_controller_node
ensures that the new component's functionality is properly tested.
198-208
: Addition of Test Cases forlights_driver_node
ApprovedThe addition of test cases for the
lights_driver_node
ensures that the new component's functionality is properly tested.panther_lights/src/lights_driver_node.cpp (9)
29-29
: Header Inclusion ApprovedThe inclusion of
#include "sensor_msgs/msg/image.hpp"
is necessary for theImageMsg
type used in the subscriptions.
Line range hint
42-92
: Constructor Updates ApprovedThe updates to the constructor, including the initialization of
led_control_status_
, setting up callback groups, and creating subscriptions, are necessary for the new component architecture.
64-68
: Callback Group and Client Initialization ApprovedThe creation of the callback group and initialization of the
enable_led_control_client_
with the new callback group is appropriate for ensuring mutually exclusive callbacks.
74-85
: Subscription Updates ApprovedThe updates to the subscription creation to use
ImageMsg::UniquePtr
are appropriate for improving efficiency in intra-process communication.
87-88
: Diagnostic Updater Initialization ApprovedThe initialization of the diagnostic updater with the hardware ID and the addition of a diagnostic task for the lights driver status are appropriate for monitoring the node's health.
144-153
: Callback Updates ApprovedThe updates to the
ToggleLEDControlCB
method to handle the newled_control_status_
and provide appropriate logging are necessary for the new component architecture.
Line range hint
159-192
: Frame Callback Updates ApprovedThe updates to the
FrameCB
method to useImageMsg::UniquePtr
and handle the newled_control_status_
are appropriate for the new component architecture.
Line range hint
238-242
: Diagnostic Method Updates ApprovedThe updates to the
DiagnoseLights
method to handle the newled_control_status_
and provide appropriate diagnostics are necessary for the new component architecture.
248-249
: Node Registration ApprovedThe registration of the
DriverNode
withrclcpp_components
is necessary for component usage.panther_lights/test/test_lights_controller_node.cpp (1)
35-35
: Constructor Update ApprovedThe update to the constructor of
ControllerNodeWrapper
to match the new constructor ofControllerNode
ensures consistency.panther_lights/src/lights_controller_node.cpp (4)
43-44
: Constructor Update ApprovedThe update to the constructor to initialize the node with the new options and parameters, including the use of intra-process communication, is appropriate for the new component architecture.
Line range hint
159-160
: Frame Callback Update ApprovedThe update to the
FrameCB
method to useImageMsg::UniquePtr
is appropriate for improving efficiency in intra-process communication.
372-374
: Node Registration ApprovedThe registration of the
ControllerNode
withrclcpp_components
is necessary for component usage.
Line range hint
248-249
: Diagnostic Updater Initialization ApprovedThe initialization of the diagnostic updater with the hardware ID and the addition of a diagnostic task for the lights controller status are appropriate for monitoring the node's health.
panther_lights/README.md (2)
20-20
: LGTM! Consistent renaming ofdriver_node
tolights_driver_node
.The section has been renamed correctly and the information is consistent.
78-78
: LGTM! Consistent renaming ofcontroller_node
tolights_controller_node
.The section has been renamed correctly and the information is consistent.
panther_lights/include/panther_lights/lights_controller_node.hpp
Outdated
Show resolved
Hide resolved
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_lights/include/panther_lights/lights_controller_node.hpp (4 hunks)
- panther_lights/include/panther_lights/lights_driver_node.hpp (4 hunks)
- panther_lights/launch/lights.launch.py (3 hunks)
- panther_lights/src/led_animations_queue.cpp (1 hunks)
- panther_lights/src/lights_driver_node.cpp (8 hunks)
Files skipped from review as they are similar to previous changes (3)
- panther_lights/include/panther_lights/lights_controller_node.hpp
- panther_lights/include/panther_lights/lights_driver_node.hpp
- panther_lights/src/lights_driver_node.cpp
Additional comments not posted (2)
panther_lights/launch/lights.launch.py (1)
62-91
: Review ofComposableNodeContainer
andComposableNode
setupThe setup of the
ComposableNodeContainer
andComposableNode
is correctly implemented. The use of intra-process communication is consistent with the PR's objectives to enhance performance. However, ensure that theextra_arguments
are correctly applied to all nodes within the container to fully utilize intra-process communication capabilities.panther_lights/src/led_animations_queue.cpp (1)
121-121
: Logger name updated inValidate
functionThe update to the logger name to "lights_controller" is consistent with the renaming of nodes and components. This change helps in maintaining clarity and traceability in log outputs.
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 (2)
- panther_lights/include/panther_lights/lights_driver_node.hpp (3 hunks)
- panther_lights/src/lights_driver_node.cpp (8 hunks)
Files skipped from review as they are similar to previous changes (2)
- panther_lights/include/panther_lights/lights_driver_node.hpp
- panther_lights/src/lights_driver_node.cpp
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 (1)
- panther_lights/src/lights_driver_node.cpp (8 hunks)
Files skipped from review as they are similar to previous changes (1)
- panther_lights/src/lights_driver_node.cpp
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: 1
Outside diff range, codebase verification and nitpick comments (1)
panther_lights/src/lights_driver_node.cpp (1)
Line range hint
96-101
: Review of Shutdown HandlingThe
OnShutdown
function correctly clears the LEDs and toggles LED control based on theled_control_granted_
flag. This ensures that resources are properly released when the node is shutting down. However, based on previous discussions, there seems to be an issue with theToggleLEDControl
freezing the system. This needs further investigation, as it could lead to problems during shutdown.
Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Files selected for processing (2)
- panther_lights/include/panther_lights/lights_driver_node.hpp (3 hunks)
- panther_lights/src/lights_driver_node.cpp (9 hunks)
Files skipped from review as they are similar to previous changes (1)
- panther_lights/include/panther_lights/lights_driver_node.hpp
Additional comments not posted (3)
panther_lights/src/lights_driver_node.cpp (3)
Line range hint
42-96
: Constructor Review: Initialization and SetupThe constructor has been refactored to remove the
node_name
parameter and directly use"lights_driver"
as the node name. This simplifies the initialization but assumes that the node name does not need to be configurable, which should be verified if it aligns with the system's requirements.
- Initialization of Parameters: Parameters like
global_brightness
,frame_timeout
, andnum_led
are declared and retrieved correctly.- Error Handling: There is no error handling if the parameters are set to values that are not sensible (e.g., negative numbers for
num_led
). Consider adding checks or constraints on these parameters.- Resource Initialization: The use of
chanel_1_
andchanel_2_
for setting global brightness directly after declaring parameters is efficient.Overall, the constructor setup appears robust, but adding parameter validation could improve reliability.
108-132
: Review of Initialization Timer CallbackThe
InitializationTimerCB
function implements a retry mechanism for LED control initialization. It uses a combination of state flags (led_control_granted_
,led_control_pending_
) and timing checks to manage retries. Here are a few points to consider:
- Error Handling: The function throws a runtime error if the maximum number of initialization attempts is exceeded. This is a good practice as it fails fast, preventing the system from being stuck in an indefinite initialization state.
- Resource Management: The function correctly cancels the timer if LED control is granted, which is efficient in terms of resource usage.
- Timing and Delays: The use of
led_control_call_time_
to check for service response timeouts is a robust way to handle potential communication delays or failures.This function appears well-implemented with proper error handling and resource management strategies.
257-274
: Review of Diagnostic FunctionalityThe
DiagnoseLights
function effectively uses the diagnostic updater to report the status of the lights driver. It appropriately sets the error level and message based on the state of LED control. This function is a good example of how to implement diagnostics in a ROS node.
- Error Levels and Messages: The use of different error levels (
ERROR
,WARN
,OK
) based on the state (led_control_granted_
,led_control_pending_
) is a best practice in ROS diagnostics.- Status Reporting: The function reports the status in a clear and concise manner, which is beneficial for system monitoring and troubleshooting.
This diagnostic implementation is robust and follows best practices.
Description
Modifications
Summary by CodeRabbit
Bug Fixes
Refactor
DriverNode
class to improve performance and maintainability.New Features