void PluginTreeView::on_connected() { try { FawkesNetworkClient *client = m_dispatcher.get_client(); // subscribe for load-/unload messages FawkesNetworkMessage* msg = new FawkesNetworkMessage(FAWKES_CID_PLUGINMANAGER, MSG_PLUGIN_SUBSCRIBE_WATCH); client->enqueue(msg); // request list of available plugins msg = new FawkesNetworkMessage(FAWKES_CID_PLUGINMANAGER, MSG_PLUGIN_LIST_AVAIL); client->enqueue(msg); // request list of loaded plugins msg = new FawkesNetworkMessage(FAWKES_CID_PLUGINMANAGER, MSG_PLUGIN_LIST_LOADED); client->enqueue(msg); } catch (Exception& e) { e.print_trace(); } }
void try_localize(const std::string &host, unsigned short int port, std::string &interface_id, std::string frame, double translation[3], double rotation[4], double covariance[36]) { FawkesNetworkClient *c = new FawkesNetworkClient(host.c_str(), port); c->connect(); if (frame == "") { NetworkConfiguration *netconf = NULL; try { netconf = new NetworkConfiguration(c); frame = netconf->get_string("/frames/fixed"); } catch (Exception &e) { printf("WARNING: no frame set and failed to get frame from remote.\n"); e.print_trace(); } delete netconf; } BlackBoard *bb = new RemoteBlackBoard(c); LocalizationInterface *loc_if = bb->open_for_reading<LocalizationInterface>(interface_id.c_str()); if (! loc_if->has_writer()) { bb->close(loc_if); delete bb; throw Exception("No writer for interface %s, aborting", loc_if->uid()); } LocalizationInterface::SetInitialPoseMessage *ipm = new LocalizationInterface::SetInitialPoseMessage(); ipm->set_frame(frame.c_str()); ipm->set_translation(translation); ipm->set_rotation(rotation); ipm->set_covariance(covariance); loc_if->msgq_enqueue(ipm); // allow for some time so message is actually sent usleep(500000); bb->close(loc_if); delete bb; delete c; }
void NetLogGuiGtkWindow::on_connbut_clicked(Gtk::Image *image, fawkes::LogView *logview) { FawkesNetworkClient *client = logview->get_client(); if ( client->connected() ) { client->disconnect(); } else { try { client->connect(); } catch (Exception &e) { Glib::ustring message = *(e.begin()); Gtk::MessageDialog md(*this, message, /* markup */ false, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, /* modal */ true); md.set_title("Connection failed"); md.run(); } } }