diff --git a/combined_robot_hw/include/combined_robot_hw/combined_robot_hw.h b/combined_robot_hw/include/combined_robot_hw/combined_robot_hw.h index 720689c9c..ce7dee6eb 100644 --- a/combined_robot_hw/include/combined_robot_hw/combined_robot_hw.h +++ b/combined_robot_hw/include/combined_robot_hw/combined_robot_hw.h @@ -98,6 +98,12 @@ class CombinedRobotHW : public hardware_interface::RobotHW */ virtual void write(const ros::Time& time, const ros::Duration& period); + /** + * Checks whether the robot HW requires to reset controllers + * + */ + virtual bool isResetRequired(); + protected: ros::NodeHandle root_nh_; ros::NodeHandle robot_hw_nh_; diff --git a/combined_robot_hw/src/combined_robot_hw.cpp b/combined_robot_hw/src/combined_robot_hw.cpp index 24b24f491..b0c9dc73b 100644 --- a/combined_robot_hw/src/combined_robot_hw.cpp +++ b/combined_robot_hw/src/combined_robot_hw.cpp @@ -195,6 +195,18 @@ namespace combined_robot_hw } } + bool CombinedRobotHW::isResetRequired() + { + // Call the isResetRequired method of the single RobotHW objects. + std::vector::iterator robot_hw; + for (robot_hw = robot_hw_list_.begin(); robot_hw != robot_hw_list_.end(); ++robot_hw) + { + if((*robot_hw)->isResetRequired()) + return true; + } + return false; + } + void CombinedRobotHW::filterControllerList(const std::list& list, std::list& filtered_list, hardware_interface::RobotHWSharedPtr robot_hw) diff --git a/hardware_interface/include/hardware_interface/robot_hw.h b/hardware_interface/include/hardware_interface/robot_hw.h index a70340898..78e4603c7 100644 --- a/hardware_interface/include/hardware_interface/robot_hw.h +++ b/hardware_interface/include/hardware_interface/robot_hw.h @@ -175,6 +175,26 @@ class RobotHW : public InterfaceManager * \param period The time passed since the last call to \ref write */ virtual void write(const ros::Time& /*time*/, const ros::Duration& /*period*/) {} + + /** + * Each robot HW might require to reset controllers, rising reset_ to true, this + * method returns true if that is the case + */ + virtual bool isResetRequired() + { + if(reset_once_) + { + reset_once_ = false; + return true; + } + else + { + return false; + } + } + +protected: + bool reset_once_; }; typedef std::shared_ptr RobotHWSharedPtr;