1
0
mirror of https://gitlab.com/obbart/universal_robots_ros_driver.git synced 2026-04-10 01:50:46 +02:00

disable starting controllers when robot control is inactive

Since we use the external controller stopper to take down controllers when
robot control is inactive, we also do not want that users can start controllers
while robot control is deactivated. The only exception is at startup time.
This commit is contained in:
Felix Mauch
2019-06-27 13:25:07 +02:00
committed by Tristan Schnell
parent cb64e68100
commit a6a06526ac
2 changed files with 19 additions and 2 deletions

View File

@@ -133,6 +133,7 @@ protected:
ros::Publisher program_state_pub_; ros::Publisher program_state_pub_;
bool controller_reset_necessary_; bool controller_reset_necessary_;
bool controllers_initialized_;
std::string robot_ip_; std::string robot_ip_;
}; };

View File

@@ -47,6 +47,7 @@ HardwareInterface::HardwareInterface()
, position_controller_running_(false) , position_controller_running_(false)
, pausing_state_(PausingState::RUNNING) , pausing_state_(PausingState::RUNNING)
, pausing_ramp_up_increment_(0.01) , pausing_ramp_up_increment_(0.01)
, controllers_initialized_(false)
{ {
} }
@@ -301,8 +302,23 @@ void HardwareInterface ::write(const ros::Time& time, const ros::Duration& perio
bool HardwareInterface ::prepareSwitch(const std::list<hardware_interface::ControllerInfo>& start_list, bool HardwareInterface ::prepareSwitch(const std::list<hardware_interface::ControllerInfo>& start_list,
const std::list<hardware_interface::ControllerInfo>& stop_list) const std::list<hardware_interface::ControllerInfo>& stop_list)
{ {
// TODO: Implement bool ret_val = true;
return true; if (controllers_initialized_ && !isRobotProgramRunning() && !start_list.empty())
{
for (auto& controller : start_list)
{
if (!controller.claimed_resources.empty())
{
ROS_ERROR_STREAM("Robot control is currently inactive. Starting controllers that claim resources is currently "
"not possible. Not starting controller '"
<< controller.name << "'");
ret_val = false;
}
}
}
controllers_initialized_ = true;
return ret_val;
} }
void HardwareInterface ::doSwitch(const std::list<hardware_interface::ControllerInfo>& start_list, void HardwareInterface ::doSwitch(const std::list<hardware_interface::ControllerInfo>& start_list,