Skip to content

Commit

Permalink
Merge pull request #86 from ipa-fxm/fix_mode_adapter_shutdown
Browse files Browse the repository at this point in the history
fix mode adapter shutdown
  • Loading branch information
Florian Weisshardt committed Feb 18, 2016
2 parents 333184b + 308a340 commit 1d8c6fb
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions cob_control_mode_adapter/src/cob_control_mode_adapter_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
class CobControlModeAdapter
{
public:
void initialize()
bool initialize()
{
bool success = false;

Expand Down Expand Up @@ -39,7 +39,7 @@ class CobControlModeAdapter
else
{
ROS_ERROR("...Load service not available!");
return;
return false;
}

while (not ros::service::waitForService("controller_manager/switch_controller", ros::Duration(5.0))){;}
Expand All @@ -51,7 +51,7 @@ class CobControlModeAdapter
else
{
ROS_ERROR("...Load service not available!");
return;
return false;
}

std::string param="max_command_silence";
Expand Down Expand Up @@ -143,6 +143,8 @@ class CobControlModeAdapter

update_rate_ = 100; //[hz]
timer_ = nh_.createTimer(ros::Duration(1/update_rate_), &CobControlModeAdapter::update, this);

return true;
}

bool loadController(std::string load_controller)
Expand Down Expand Up @@ -239,6 +241,8 @@ class CobControlModeAdapter

void update(const ros::TimerEvent& event)
{
if (!nh_.ok()) {return;}

boost::mutex::scoped_lock lock(mutex_);

ros::Duration period_vel = event.current_real - last_vel_command_;
Expand Down Expand Up @@ -375,10 +379,14 @@ int main(int argc, char** argv)
spinner.start();

CobControlModeAdapter* ccma = new CobControlModeAdapter();
ccma->initialize();

if (!ccma->initialize())
{
ROS_ERROR("Failed to initialize CobControlModeAdapter");
return -1;
}

ros::waitForShutdown();
delete ccma;
return 0;
}

0 comments on commit 1d8c6fb

Please sign in to comment.