void KeyboardControl::run(){ if (init()){ twist_pub_ = nh_.advertise<geometry_msgs::Twist>("/cmd_vel", 10); twist_pub_timer_ = nh_.createTimer(ros::Duration(1.0/rate_), &KeyboardControl::twistCallback, this); boost::thread parse_thread(boost::bind(&KeyboardControl::parseKeyboard, this)); ros::spin(); } }
void console::ted_cmd::getCommand(wxCommandEvent& WXUNUSED(event)) { if (puc) getGUInput(); // run the local GUInput parser else { wxString command = GetValue(); tell_log(MT_COMMAND, command); _cmd_history.push_back(std::string(command.mb_str())); _history_position = _cmd_history.end(); Clear(); parse_thread *pthrd = DEBUG_NEW parse_thread(command,_parent,_canvas); pthrd->Create(); pthrd->Run(); } }
inline bool PBFParser::Parse() { // Start the read and parse threads std::thread read_thread(std::bind(&PBFParser::ReadData, this)); // Open several parse threads that are synchronized before call to std::thread parse_thread(std::bind(&PBFParser::ParseData, this)); // Wait for the threads to finish read_thread.join(); parse_thread.join(); return true; }
void UWBDriver::run(){ ros::NodeHandle node; ros::NodeHandle private_node("~"); private_node.param<std::string>("port_name", port_name_, std::string("/dev/ttyUSB0")); private_node.param<std::string>("base_frame", base_frame_, std::string("base_link")); private_node.param<int>("baud_rate", baud_rate_, 115200); private_node.param<int>("sensor_rate", sensor_rate_, 10); if (init()){ // ros::Timer handle_dist_timer = node.createTimer(ros::Duration(100.0/sensor_rate_), &UWBDriver::handle_dist_msg, this); boost::thread parse_thread(boost::bind(&UWBDriver::receive_msg, this)); ros::spin(); return; } }
void console::ted_cmd::getCommandA() { if (puc) getGUInput(); // run the local GUInput parser else { wxString command = GetValue(); tell_log(MT_COMMAND, command); _cmd_history.push_back(std::string(command.mb_str())); _history_position = _cmd_history.end(); Clear(); if (!_thread) { // executing the parser without thread // essentially the same code as in parse_thread::Entry, but // without the mutexes telllloc.first_column = telllloc.first_line = 1; telllloc.last_column = telllloc.last_line = 1; telllloc.filename = NULL; void* b = tell_scan_string( command.mb_str() ); tellparse(); my_delete_yy_buffer( b ); } else { // executing the parser in a separate thread //wxTHREAD_JOINABLE, wxTHREAD_DETACHED parse_thread *pthrd = DEBUG_NEW parse_thread(command,_parent,_canvas); wxThreadError result = pthrd->Create(); if (wxTHREAD_NO_ERROR == result) pthrd->Run(); else { tell_log( MT_ERROR, "Can't execute the command in a separate thread"); delete(pthrd); } // if (_wait) pthrd->Wait(); } } }