-
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
Change behaviour of motor_power_enable to e_stop_torque_enable #479
base: ros2-devel
Are you sure you want to change the base?
Conversation
WalkthroughThis pull request introduces a significant change in the emergency stop (E-Stop) mechanism for Husarion UGV hardware interfaces. The primary modification involves replacing the Changes
Sequence DiagramsequenceDiagram
participant User
participant ROS Service
participant UGVSystem
participant RobotDriver
User->>ROS Service: Call e_stop_torque_enable
ROS Service->>UGVSystem: Invoke EStopTorqueEnable
UGVSystem->>UGVSystem: Check E-Stop state
alt E-Stop triggered
UGVSystem->>RobotDriver: Enable/Disable Torque
else E-Stop not triggered
UGVSystem-->>User: Throw Runtime Error
end
Possibly related PRs
Suggested reviewers
Finishing Touches
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: 0
🧹 Nitpick comments (3)
husarion_ugv_hardware_interfaces/src/robot_system/ugv_system.cpp (1)
Line range hint
529-552
: Robust safety implementation for E-Stop torque control!The implementation includes critical safety features:
- Validates E-Stop state before allowing torque changes
- Uses mutex for thread-safe operation
- Proper error handling and clear error messages
However, consider adding logging for successful torque state changes to aid in debugging.
Add success logging:
if (!enable) { robot_driver_->TurnOnEStop(); + RCLCPP_INFO(logger_, "Motor torque disabled successfully"); } else { robot_driver_->TurnOffEStop(); + RCLCPP_INFO(logger_, "Motor torque enabled successfully"); }husarion_ugv_hardware_interfaces/README.md (1)
29-29
: Enhance service documentation for clarity.While the service is documented, the description could be more specific about its relationship with E-Stop state.
Update the description:
-- `hardware/e_stop_torque_enable` [*std_srvs/SetBool*]: Enables or disables motor power. +- `hardware/e_stop_torque_enable` [*std_srvs/SetBool*]: Enables or disables motor torque when E-Stop is triggered. This service will fail if E-Stop is not active.ROS_API.md (1)
121-121
: Consider documenting the default state.It would be helpful to document the default state of motor torque when E-Stop is triggered (enabled/disabled by default).
Apply this diff to enhance the documentation:
-| ✅ | ❌ | `hardware/e_stop_torque_enable` | Allows enabling or disabling motor torque when the E-Stop is triggered. <br/> [std_srvs/srv/SetBool](https://docs.ros2.org/latest/api/std_srvs/srv/SetBool.html) | +| ✅ | ❌ | `hardware/e_stop_torque_enable` | Allows enabling or disabling motor torque when the E-Stop is triggered. By default, motor torque is disabled when E-Stop is triggered. <br/> [std_srvs/srv/SetBool](https://docs.ros2.org/latest/api/std_srvs/srv/SetBool.html) |
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (9)
ROS_API.md
(1 hunks)husarion_ugv_controller/launch/controller.launch.py
(1 hunks)husarion_ugv_hardware_interfaces/README.md
(1 hunks)husarion_ugv_hardware_interfaces/include/husarion_ugv_hardware_interfaces/robot_system/ugv_system.hpp
(1 hunks)husarion_ugv_hardware_interfaces/src/robot_system/lynx_system.cpp
(1 hunks)husarion_ugv_hardware_interfaces/src/robot_system/panther_system.cpp
(1 hunks)husarion_ugv_hardware_interfaces/src/robot_system/robot_driver/roboteq_data_converters.cpp
(2 hunks)husarion_ugv_hardware_interfaces/src/robot_system/system_e_stop.cpp
(1 hunks)husarion_ugv_hardware_interfaces/src/robot_system/ugv_system.cpp
(3 hunks)
🔇 Additional comments (10)
husarion_ugv_hardware_interfaces/src/robot_system/system_e_stop.cpp (1)
58-58
: LGTM! Verify E-Stop reset sequence.The addition of
TurnOffEStop()
at the start of the reset sequence is logical and aligns with the new E-Stop torque management approach.Run this script to verify the E-Stop reset sequence implementation across the codebase:
✅ Verification successful
Verified: E-Stop reset sequence is correctly implemented
The addition of
TurnOffEStop()
at the start of the reset sequence is correct and follows the documented E-Stop reset procedure, with proper safety checks in place:
- Turn off E-Stop command (new addition)
- Thread-safe GPIO manipulation
- Error flag clearing
- Reset confirmation
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the E-Stop reset sequence implementation # Expect: TurnOffEStop is called before other reset operations # Search for ResetEStop implementations ast-grep --pattern 'ResetEStop() { $$$ }' # Search for TurnOffEStop implementations ast-grep --pattern 'TurnOffEStop() { $$$ }'Length of output: 93
Script:
#!/bin/bash # Search for E-Stop related files and implementations echo "=== Files containing E-Stop related code ===" rg -l "(?i)estop|e_stop|e-stop" echo -e "\n=== E-Stop method implementations ===" rg -n "(?i)(?:reset|turn.*off).*(?:estop|e_stop)" -A 5 echo -e "\n=== Header files with E-Stop declarations ===" fd -e hpp -e h | xargs rg -n "(?i)(?:reset|turn.*off).*(?:estop|e_stop)"Length of output: 38519
husarion_ugv_hardware_interfaces/src/robot_system/lynx_system.cpp (1)
107-108
: LGTM! Improved error message formatting.The updated error message format enhances readability and maintains consistency with other error messages in the codebase.
husarion_ugv_hardware_interfaces/include/husarion_ugv_hardware_interfaces/robot_system/ugv_system.hpp (1)
113-113
: LGTM! Verify all service bindings are updated.The replacement of
MotorsPowerEnable
withEStopTorqueEnable
improves safety by specifically managing torque during E-Stop conditions.Run this script to verify all service bindings are updated:
✅ Verification successful
Service bindings successfully updated
All references to the old
motor_power_enable
service have been removed, and the newe_stop_torque_enable
service is properly bound in the launch configuration and documented in the API.🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify service bindings and usages # Expect: No references to old motor_power_enable service # Search for any remaining references to motor_power_enable rg -i "motor_power_enable" # Search for new e_stop_torque_enable service bindings rg -i "e_stop_torque_enable"Length of output: 667
husarion_ugv_hardware_interfaces/src/robot_system/panther_system.cpp (1)
128-140
: LGTM! Enhanced error diagnostics.The separation of front and rear driver error messages improves diagnostics by clearly identifying which driver is in an error state. The formatting is consistent with other error messages in the codebase.
husarion_ugv_hardware_interfaces/src/robot_system/robot_driver/roboteq_data_converters.cpp (2)
105-105
: Improved clarity in E-Stop flag naming!The updated flag name better distinguishes between Roboteq E-stop and ROS E-stop, making it clearer that this state indicates torque is disabled.
254-276
: Enhanced error log formatting and readability!The restructured error log generation:
- Only includes non-empty error logs, reducing noise
- Adds clear labels for each error type
- Properly handles trailing newlines
husarion_ugv_controller/launch/controller.launch.py (1)
221-221
: Correct remapping for the new service name!The remapping from
hardware_controller/e_stop_torque_enable
tohardware/e_stop_torque_enable
is consistent with other hardware-related remappings.husarion_ugv_hardware_interfaces/src/robot_system/ugv_system.cpp (1)
132-133
: Correct service binding for the new E-Stop torque control!The service binding is properly updated to use the new method name and maintains consistency with other service bindings.
ROS_API.md (2)
121-121
: LGTM! Clear and concise documentation of the new service.The documentation for the new
hardware/e_stop_torque_enable
service is well-written and accurately describes its functionality. The service type is correctly specified asstd_srvs/srv/SetBool
.
121-121
: Verify the service implementation matches the documentation.Let's verify that the service implementation aligns with the documented behavior.
✅ Verification successful
Service implementation matches documentation ✅
The service implementation in
UGVSystem::EStopTorqueEnable
correctly implements the documented behavior:
- Uses the documented service type (std_srvs/srv/SetBool)
- Controls motor torque when E-Stop is triggered
- Includes proper safety checks and thread synchronization
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Search for the service implementation ast-grep --pattern 'create_service<std_srvs::srv::SetBool>("hardware/e_stop_torque_enable"' # Search for any tests related to this service rg -l "e_stop_torque_enable.*test"Length of output: 141
Script:
#!/bin/bash # Search for e_stop related files rg -l "e_stop" # Search for SetBool service usage ast-grep --pattern 'create_service<std_srvs::srv::SetBool>($_)' # Search for torque enable related code rg -l "torque.*enable|enable.*torque" # Search for e_stop implementation ast-grep --pattern 'void $_($$$) { $$$ e_stop $$$ }'Length of output: 2767
Script:
#!/bin/bash # Check system_ros_interface.cpp content cat husarion_ugv_hardware_interfaces/src/robot_system/system_ros_interface.cpp # Check ugv_system.cpp for torque enable functionality cat husarion_ugv_hardware_interfaces/src/robot_system/ugv_system.cpp # Look for SetBool service handlers ast-grep --pattern 'void $_($_: std_srvs::srv::SetBool::Request::SharedPtr, $_: std_srvs::srv::SetBool::Response::SharedPtr) { $$$ }'Length of output: 29567
Description
motor_power_enable
toe_stop_torque_enable
Requirements
Tests 🧪
Summary by CodeRabbit
Release Notes
New Features
hardware/e_stop_torque_enable
for managing motor torque during emergency stopsChanges
hardware/motor_power_enable
Documentation
Beta Notice