bool SeaBee3GUIService::start(int argc, char* argv[]) { QApplication app(argc, argv); itsMgr = new ModelManager("SeaBeeIIIGUIManager"); char adapterStr[255]; LINFO("Creating Adapter"); sprintf(adapterStr, "default -p %i", 12345); itsAdapter = communicator()->createObjectAdapterWithEndpoints("RobotBrainPort", adapterStr); nub::ref<MainWindow> mainWindow(new MainWindow(*itsMgr)); itsMgr->addSubComponent(mainWindow); LINFO("Starting Up GUI Comm"); mainWindow->initIce(communicator(), itsAdapter); itsMgr->parseCommandLine(argc, argv, "", 0, 0); itsAdapter->activate(); itsMgr->start(); mainWindow->setGeometry(100,100,900,800); mainWindow->show(); return app.exec(); }
bool RobotBrainServiceService::start(int argc, char* argv[]) { char adapterStr[255]; //Create the topics SimEventsUtils::createTopic(communicator(), "SalientPointMessageTopic"); //Create the adapter sprintf(adapterStr, "default -p %i", RobotBrainObjects::RobotBrainPort); itsAdapter = communicator()->createObjectAdapterWithEndpoints("SaliencyModule", adapterStr); //Create the manager and its objects itsMgr = new ModelManager("SaliencyModuleService"); LINFO("Starting SaliencyModule"); nub::ref<SaliencyModuleI> ret(new SaliencyModuleI(*itsMgr)); itsMgr->addSubComponent(ret); ret->init(communicator(), itsAdapter); itsMgr->parseCommandLine((const int)argc, (const char**)argv, "", 0, 0); itsAdapter->activate(); itsMgr->start(); return true; }
bool RobotBrainServiceService::start(int argc, char* argv[]) #endif { MYLOGVERB = LOG_INFO; char adapterStr[255]; //Create the adapter int port = RobotBrainObjects::RobotBrainPort; bool connected = false; // try to connect to ports until successful LDEBUG("Opening Connection"); while(!connected) { try { LINFO("Trying Port:%d", port); sprintf(adapterStr, "default -p %i", port); itsAdapter = communicator()->createObjectAdapterWithEndpoints ("GistSal_Navigation", adapterStr); connected = true; } catch(Ice::SocketException) { port++; } } //Create the manager and its objects itsMgr = new ModelManager("BeoLocalizationService"); LINFO("Starting BeoLocalization System"); nub::ref<BeoLocalizer> bl(new BeoLocalizer (*itsMgr, "BeoLocalizer", "BeoLocalizer")); LINFO("BeoLocalizer created"); itsMgr->addSubComponent(bl); LINFO("BeoLocalizer Added As a subcomponent"); bl->init(communicator(), itsAdapter); LINFO("BeoLocalizer initiated"); // check command line inputs/options if (itsMgr->parseCommandLine((const int)argc, (const char**)argv, "", 0, 0) == false) return(1); // FIXXX: in the future the map should be specificable // from the command line to allow for stand alone application // check app-Beobot2_GistSalLocalizer.C // activate manager and adapter itsAdapter->activate(); itsMgr->start(); return true; }
bool RobotBrainServiceService::start(int argc, char* argv[]) { char adapterStr[255]; //Create the adapter int port = RobotBrainObjects::RobotBrainPort; bool connected = false; while(!connected) { try { LINFO("Trying Port:%d", port); sprintf(adapterStr, "default -p %i", port); itsAdapter = communicator()->createObjectAdapterWithEndpoints("SeaBee3SimulatorAdapter", adapterStr); connected = true; } catch(Ice::SocketException) { port++; } } //Create the manager and its objects itsMgr = new ModelManager("SeaBee3SimulatorServiceManager"); nub::ref<OutputFrameSeries> ofs(new OutputFrameSeries(*itsMgr)); itsMgr->addSubComponent(ofs); LINFO("Starting SeaBee3 Simulator"); nub::ref<SeaBee3Simulator> subSim(new SeaBee3Simulator(*itsMgr, "SeaBee3Simulator", "SeaBee3Simulator")); itsMgr->addSubComponent(subSim); subSim->init(communicator(), itsAdapter); itsMgr->parseCommandLine((const int)argc, (const char**)argv, "", 0, 0); itsAdapter->activate(); itsMgr->start(); while(1){ Layout<PixRGB<byte> > outDisp; subSim->simLoop(); Image<PixRGB<byte> > forwardCam = flipVertic(subSim->getFrame(1)); Image<PixRGB<byte> > downwardCam = flipVertic(subSim->getFrame(2)); outDisp = vcat(outDisp, hcat(forwardCam, downwardCam)); ofs->writeRgbLayout(outDisp, "subSim", FrameInfo("subSim", SRC_POS)); handle_keys(ofs, subSim); } return true; }
bool RobotBrainServiceService::start(int argc, char* argv[]) #endif { MYLOGVERB = LOG_INFO; char adapterStr[255]; //Create the topics // SimEventsUtils::createTopic(communicator(), "BeoGPSMessageTopic"); //Create the adapter int port = RobotBrainObjects::RobotBrainPort; bool connected = false; // try to connect to ports until successful LDEBUG("Opening Connection"); while(!connected) { try { LINFO("Trying Port:%d", port); sprintf(adapterStr, "default -p %i", port); itsAdapter = communicator()->createObjectAdapterWithEndpoints ("BeoGPS", adapterStr); connected = true; } catch(Ice::SocketException) { port++; } } //Create the manager and its objects itsMgr = new ModelManager("BeoGPSService"); LINFO("Starting BeoGPS System"); nub::ref<BeoGPS> gps(new BeoGPS(*itsMgr, "BeoGPS", "BeoGPS")); LINFO("BeoGPS created"); itsMgr->addSubComponent(gps); LINFO("BeoGPS Added As a subcomponent"); gps->init(communicator(), itsAdapter); LINFO("BeoGPS initiated"); // check command line inputs/options if (itsMgr->parseCommandLine (argc, argv, "<serdev>", 0, 0) == false) return(1); // let's configure our serial device: // gps->configureSerial(itsMgr->getExtraArg(0)); // LINFO("Using: %s", itsMgr->getExtraArg(0).c_str()); // activate manager and adapter itsAdapter->activate(); itsMgr->start(); return true; }
bool RobotBrainServiceService::start(int argc, char* argv[]) { char adapterStr[255]; LINFO("Creating Topic!"); //Create the topics // SimEventsUtils::createTopic(communicator(), "BinFinderMessageTopic"); //Create the adapter int port = RobotBrainObjects::RobotBrainPort; bool connected = false; LDEBUG("Opening Connection"); while(!connected) { try { LINFO("Trying Port:%d", port); sprintf(adapterStr, "default -p %i", port); itsAdapter = communicator()->createObjectAdapterWithEndpoints ("BinFinder", adapterStr); connected = true; } catch(Ice::SocketException) { port++; } } //Create the manager and its objects itsMgr = new ModelManager("BinFinderService"); LINFO("Starting BinFinder"); nub::ref<BinFinder> ret (new BinFinder(*itsMgr, "BinFinder1", "BinFinder2")); LINFO("BinFinder Created"); itsMgr->addSubComponent(ret); LINFO("BinFinder Added As Sub Component"); ret->init(communicator(), itsAdapter); LINFO("BinFinder Inited"); itsMgr->parseCommandLine((const int)argc, (const char**)argv, "", 0, 0); itsAdapter->activate(); itsMgr->start(); return true; }
// ###################################################################### bool RobotBrainServiceService::start(int argc, char* argv[]) { MYLOGVERB = LOG_INFO; char adapterStr[255]; //Create the adapter int port = RobotBrainObjects::RobotBrainPort; bool connected = false; // try to connect to ports until successful LDEBUG("Opening Connection"); while(!connected) { try { LINFO("Trying Port:%d", port); sprintf(adapterStr, "default -p %i", port); itsAdapter = communicator()->createObjectAdapterWithEndpoints ("RG_Lane", adapterStr); connected = true; } catch(Ice::SocketException) { port++; } } //Create the manager and its objects itsMgr = new ModelManager("RG_LaneService"); LINFO("Starting RG_Lane System"); nub::ref<RG_Lane> nav(new RG_Lane(*itsMgr, "RG_Lane", "RG_Lane")); LINFO("RG_Lane created"); itsMgr->addSubComponent(nav); LINFO("RG_Lane Added As a subcomponent"); nav->init(communicator(), itsAdapter); LINFO("RG_Lane initiated"); // check command line inputs/options itsMgr->parseCommandLine(argc, argv, "", 0, 0); // activate manager and adapter itsAdapter->activate(); itsMgr->start(); return true; }
bool RobotBrainServiceService::start(int argc, char* argv[]) { char adapterStr[255]; LINFO("Starting XBox Controller..."); //Create the topics // SimEventsUtils::createTopic(communicator(), "XBox360RemoteControlMessageTopic"); //Create the adapter int port = RobotBrainObjects::RobotBrainPort; bool connected = false; while(!connected) { try { LINFO("Trying Port:%d", port); sprintf(adapterStr, "default -p %i", port); itsAdapter = communicator()->createObjectAdapterWithEndpoints("XBox360RemoteControl", adapterStr); connected = true; } catch(Ice::SocketException) { port++; } } //Create the manager and its objects itsMgr = new ModelManager("XBox360RemoteControlService"); LINFO("Starting XBox360RemoteControl"); nub::ref<XBox360RemoteControlI> ret(new XBox360RemoteControlI(0, *itsMgr, "XBox360RemoteControl1", "XBox360RemoteControl2")); LINFO("XBox360RemoteControl Created"); itsMgr->addSubComponent(ret); LINFO("XBox360RemoteControl Added As Sub Component"); ret->init(communicator(), itsAdapter); LINFO("XBox360RemoteControl Inited"); itsMgr->parseCommandLine((const int)argc, (const char**)argv, "", 0, 0); itsAdapter->activate(); itsMgr->start(); return true; }
int main(int argc, const char **argv) { // Instantiate a ModelManager: ModelManager *manager = new ModelManager("Test wiimote"); nub::soft_ref<OutputFrameSeries> ofs(new OutputFrameSeries(*manager)); manager->addSubComponent(ofs); //Create the GUI nub::soft_ref<GeneralGUI> pwiiGUI(new GeneralGUI(*manager, "PWiiGUI", "PWiiGUI", Dims(700,512))); manager->addSubComponent(pwiiGUI); //Create the PWiiBot Controller nub::soft_ref<PWiiController> controller(new PWiiController(*manager)); manager->addSubComponent(controller); // Parse command-line: if (manager->parseCommandLine(argc, argv, "", 0, 0) == false) return(1); manager->exportOptions(MC_RECURSE); manager->start(); sleep(1); setupGUI(pwiiGUI, ofs, controller); while(1) { } // sleep(1); #ifdef HAVE_LIBWIIMOTE /* wiimote_t wiimote = WIIMOTE_INIT; //wiimote_report_t report = WIIMOTE_REPORT_INIT; LINFO("Press buttons 1 and 2 on the wiimote now to connect."); int nmotes = wiimote_discover(&wiimote, 1); if (nmotes == 0) LFATAL("no wiimotes were found"); LINFO("found: %s\n", wiimote.link.r_addr); if (wiimote_connect(&wiimote, wiimote.link.r_addr) < 0) { LFATAL("Unable to connect to wiimote"); Raster::waitForKey(); } */ /* Activate the first led on the wiimote. It will take effect on the next call to wiimote_update. */ /* wiimote.led.one = 1; // let's get all our ModelComponent instances started: LINFO("Open "); LINFO("Status %i", wiimote_is_open(&wiimote)); int speed = 100; int motor1_dir = 0; int motor1_vel = 0; int motor2_dir = 0; int motor2_vel = 0; Point2D<int> loc(128,128); */ // while(wiimote_is_open(&wiimote)) // { /* The wiimote_update function is used to synchronize the wiimote object with the real wiimote. It should be called as often as possible in order to minimize latency. */ /* if (wiimote_update(&wiimote) < 0) { wiimote_disconnect(&wiimote); break; }*/ /* The wiimote object has member 'keys' which keep track of the current key state. */ /* if (wiimote.keys.home) { //press home to exit wiimote_write_byte(&wiimote, 0x04a40001, motor1_dir); wiimote_write_byte(&wiimote, 0x04a40002, 0); wiimote_write_byte(&wiimote, 0x04a40003, motor2_dir); wiimote_write_byte(&wiimote, 0x04a40004, 0); LINFO("Shutting Down Motors and Gracefully Disconnecting..."); wiimote_disconnect(&wiimote); LINFO("Disconnected, Goodbye!"); } */ /* Activate the accelerometer when the 'A' key is pressed. */ //if (wiimote.keys.a) { // wiimote.mode.acc = 1; //} //else { // wiimote.mode.acc = 0; //} // Image<PixRGB<byte> > img(255,255,ZEROS); // drawLine(img, Point2D<int>(128, 128), Point2D<int>(128+(int)(wiimote.force.x*400), 128), PixRGB<byte>(255,0,0),3); // drawLine(img, Point2D<int>(128, 128), Point2D<int>(128, 128+(int)(wiimote.force.y*400)), PixRGB<byte>(0,255,0),3); // drawLine(img, Point2D<int>(128, 128), Point2D<int>(128+(int)(wiimote.force.z*400), 128), PixRGB<byte>(0,0,255),3); // ofs->writeRGB(img, "Output", FrameInfo("output", SRC_POS)); /* int key = getKey(ofs); if (key != -1) { switch(key) { case 10: //l speed += 10; break; case 24: speed -= 10; break; case KEY_UP: motor1_dir = 2; motor2_dir = 2; break; case KEY_DOWN: motor1_dir = 1; motor2_dir = 1; break; case KEY_LEFT: motor1_dir = 2; motor2_dir = 1; break; case KEY_RIGHT: motor1_dir = 1; motor2_dir = 2; break; case 65: //space motor1_dir = 4; motor1_vel = 0; motor2_dir = 4; motor2_vel = 0; break; } LINFO("Key: %d -- Sending Motor Command...", key); //send the data to the wiimote wiimote_write_byte(&wiimote, 0x04a40001, motor1_dir); wiimote_write_byte(&wiimote, 0x04a40002, speed); wiimote_write_byte(&wiimote, 0x04a40003, motor2_dir); wiimote_write_byte(&wiimote, 0x04a40004, speed); }*/ /* LINFO("KEYS %04x one=%d two=%d a=%d b=%d <=%d >=%d ^=%d v=%d h=%d +=%d -=%d\n", wiimote.keys.bits, wiimote.keys.one, wiimote.keys.two, wiimote.keys.a, wiimote.keys.b, wiimote.keys.left, wiimote.keys.right, wiimote.keys.up, wiimote.keys.down, wiimote.keys.home, wiimote.keys.plus, wiimote.keys.minus); LINFO("TILT x=%.3f y=%.3f z=%.3f\n", wiimote.tilt.x, wiimote.tilt.y, wiimote.tilt.z); LINFO("FORCE x=%.3f y=%.3f z=%.3f (sum=%.3f)\n", wiimote.force.x, wiimote.force.y, wiimote.force.z, sqrt(wiimote.force.x*wiimote.force.x+wiimote.force.y*wiimote.force.y+wiimote.force.z*wiimote.force.z));*/ // } // stop all our ModelComponents manager->stop(); #else LFATAL("Need the libwiimote"); #endif // all done! return 0; }
int main(const int argc, const char **argv) { MYLOGVERB = LOG_INFO; ModelManager *mgr = new ModelManager("Test ObjRec"); nub::ref<OutputFrameSeries> ofs(new OutputFrameSeries(*mgr)); mgr->addSubComponent(ofs); nub::ref<InputFrameSeries> ifs(new InputFrameSeries(*mgr)); mgr->addSubComponent(ifs); nub::ref<EnvSegmenterCannyContour> seg(new EnvSegmenterCannyContour(*mgr)); mgr->addSubComponent(seg); mgr->exportOptions(MC_RECURSE); if (mgr->parseCommandLine( (const int)argc, (const char**)argv, "", 0, 0) == false) return 1; mgr->start(); seg->setModelParamVal("CannyMinCos", 1.0); seg->setModelParamVal("CannyMaxArea", 6000); seg->setModelParamVal("CannyMaxArea", 12000); itsObjectDB.loadFrom("cards.vdb"); while(1) { Image< PixRGB<byte> > inputImg; const FrameState is = ifs->updateNext(); if (is == FRAME_COMPLETE) break; //grab the images GenericFrame input = ifs->readFrame(); if (!input.initialized()) break; inputImg = input.asRgb(); Image<PixRGB<byte> > out; const Rectangle cardbox = seg->getFoa(inputImg, Point2D<int>(), NULL, &out); ofs->writeRGB(out, "input", FrameInfo("input", SRC_POS)); if (cardbox.isValid()) { Image<PixRGB<byte> > card = crop(inputImg, cardbox.getOverlap(inputImg.getBounds())); std::string cardName = recCard(card); if (cardName.length() == 0) { LINFO("Enter name for card:"); std::getline(std::cin, cardName, '\n'); if (cardName.length() > 0) trainCard(card, cardName); } writeText(card, Point2D<int>(0,0), cardName.c_str(), PixRGB<byte>(255), PixRGB<byte>(127)); ofs->writeRGB(card, "card", FrameInfo("card", SRC_POS)); } ofs->updateNext(); } mgr->stop(); return 0; }