Skip to content

Commit

Permalink
Ensure device is properly stopped
Browse files Browse the repository at this point in the history
- add: destructor in FDEffortHardwareInterface
- add: call on_deactivate if controller manager is shutdown via ctrl+c
  • Loading branch information
CalaW committed Dec 12, 2023
1 parent c44247e commit 6b289d9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions fd_hardware/include/fd_hardware/fd_effort_hi.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ class FDEffortHardwareInterface : public hardware_interface::SystemInterface
public:
RCLCPP_SHARED_PTR_DEFINITIONS(FDEffortHardwareInterface);

virtual ~FDEffortHardwareInterface();

FD_HARDWARE_PUBLIC
CallbackReturn on_init(const hardware_interface::HardwareInfo & info) override;

Expand Down
8 changes: 8 additions & 0 deletions fd_hardware/src/fd_effort_hi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@ using CallbackReturn = rclcpp_lifecycle::node_interfaces::LifecycleNodeInterface

namespace fd_hardware
{

FDEffortHardwareInterface::~FDEffortHardwareInterface()
{
// If controller manager is shutdown via Ctrl + C, the on_deactivate methods won't be called.
// We need to call them here to ensure that the device is stopped and disconnected.
on_deactivate(rclcpp_lifecycle::State());
}

// ------------------------------------------------------------------------------------------
CallbackReturn FDEffortHardwareInterface::on_init(
const hardware_interface::HardwareInfo & info)
Expand Down

0 comments on commit 6b289d9

Please sign in to comment.