Skip to content

Commit

Permalink
Add method to check for error in robotHW component
Browse files Browse the repository at this point in the history
  • Loading branch information
bochen87 committed Sep 17, 2018
1 parent 7202777 commit 73b4483
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,11 @@ class CombinedRobotHW : public hardware_interface::RobotHW
*/
virtual void write(const ros::Time& time, const ros::Duration& period);

/**
* Checks whether the robot HW components have errors
*/
virtual bool hasError();

protected:
ros::NodeHandle root_nh_;
ros::NodeHandle robot_hw_nh_;
Expand Down
14 changes: 14 additions & 0 deletions combined_robot_hw/src/combined_robot_hw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,20 @@ namespace combined_robot_hw
}
}

bool CombinedRobotHW::hasError()
{
// Call the hasError method of the single RobotHW objects.
std::vector<hardware_interface::RobotHWSharedPtr>::iterator robot_hw;
for (robot_hw = robot_hw_list_.begin(); robot_hw != robot_hw_list_.end(); ++robot_hw)
{
if ((*robot_hw)->hasError())
{
return true;
}
}
return false;
}

void CombinedRobotHW::filterControllerList(const std::list<hardware_interface::ControllerInfo>& list,
std::list<hardware_interface::ControllerInfo>& filtered_list,
hardware_interface::RobotHWSharedPtr robot_hw)
Expand Down
6 changes: 6 additions & 0 deletions hardware_interface/include/hardware_interface/robot_hw.h
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,12 @@ 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) {}

/**
* Check whether the robot HW has encountered an error
*/
virtual bool hasError() { return false; };

};

typedef std::shared_ptr<RobotHW> RobotHWSharedPtr;
Expand Down

0 comments on commit 73b4483

Please sign in to comment.