Skip to content

Commit

Permalink
updated component base class destructor to contain log flushing in de…
Browse files Browse the repository at this point in the history
…structor. shifted ros::init around in main.
  • Loading branch information
finger563 committed Apr 9, 2018
1 parent 17549eb commit 8c45dc1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
8 changes: 7 additions & 1 deletion src/rosmod_actor/src/rosmod_actor/component.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,14 @@ Component::Component(Json::Value& _config) {

// Destructor
Component::~Component() {
std::cout << "~Component() for " <<
config["Name"].asString() <<
" - writing out logs!" << "\n";
comp_queue.disable();
init_timer.stop();
// make sure all user logs are written
logger->write();
// make sure all trace logs are written
trace->write();
}

// Component Operation Queue Handler
Expand Down
16 changes: 8 additions & 8 deletions src/rosmod_actor/src/rosmod_actor/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,17 @@ int main(int argc, char **argv)
ROS_ERROR_STREAM("Unhandled exception caught trying to open / parse config file!");
}

nodeName = root["Name"].asString();
ros::init(argc, argv, nodeName.c_str(), ros::init_options::NoSigintHandler);
signal(SIGINT, rosmod_actor_SigInt_handler);

ROS_INFO_STREAM( std::string("Root Node name: ") << root["Name"].asString() << std::endl);
ROS_INFO_STREAM( std::string("Root Node priority: ") << root["Priority"].asInt() << std::endl);

// Create Node Handle
ros::NodeHandle n;
ROS_INFO_STREAM(nodeName << " thread id = " << boost::this_thread::get_id());

int ret;
pthread_t this_thread = pthread_self();

Expand Down Expand Up @@ -117,14 +125,6 @@ int main(int argc, char **argv)
ROS_INFO_STREAM("SCHED_RR OK" << std::endl);
// Print thread scheduling priority
ROS_INFO_STREAM("Thread priority is " << params.sched_priority << std::endl);

nodeName = root["Name"].asString();
ros::init(argc, argv, nodeName.c_str(), ros::init_options::NoSigintHandler);
signal(SIGINT, rosmod_actor_SigInt_handler);
// Create Node Handle
ros::NodeHandle n;

ROS_INFO_STREAM(nodeName << " thread id = " << boost::this_thread::get_id());

for (unsigned int i = 0; i < root["Component Instances"].size(); i++) {
std::string libraryLocation = root["Component Instances"][i]["Definition"].asString();
Expand Down

0 comments on commit 8c45dc1

Please sign in to comment.