Beispiel #1
0
int main(int argc, char** argv) {
	cfg.path("../../setup");
	cfg.args("detector.webcam.provider.", argv);
	if (argc == 1) cfg.load("config.csv");
	bool verbose = cfg.flag("detector.webcam.provider.verbose", true);
	if (verbose) cfg.show();
		
	int indexR = (int)cfg.num("detector.webcam.provider.indexR");
	int indexL = (int)cfg.num("detector.webcam.provider.indexL");
	int sleep_time = (int)cfg.num("detector.webcam.provider.sleep_time");
	std::string addressf = cfg.str("detector.webcam.provider.f_ip").c_str();
	std::string addressc = cfg.str("detector.webcam.provider.c_ip").c_str();
	std::string port = cfg.str("detector.webcam.provider.port").c_str();

	signal(SIGINT, quitproc);
	signal(SIGTERM, quitproc);
	signal(SIGQUIT, quitproc);

	webcamProvider p(indexR, indexL, sleep_time, verbose, argv[0], addressf.c_str(), addressc.c_str(), port);
	ghost = &p;	
	if(p.init()) {
		//p.rotate();
		p.provide();
		
	}

	return 0;
}
Beispiel #2
0
  ProxyServoListener()
  {
    subscribers.push_back(cfg.str("servos.subscribe"));
    publish=cfg.str("proxyservos.publish");

    std::set < std::string > names = cfg.servoNames();
    for (std::set < std::string > :: iterator i = names.begin(); i != names.end(); ++i) {
      int id = atoi(cfg.servo(*i,"id").c_str());
      ZMQProxyServo &servo=servos[id];
      servo.id(id);
      servo.tempRate(cfg.num("proxyservos.temprate"));
      servo.angleRate(cfg.num("proxyservos.anglerate"));
    }
    start();
  }
Beispiel #3
0
int main(int argc, char** argv)
{
  pid_t leapd_pid;

  if ((leapd_pid=fork()) == 0) {
    execl("/usr/bin/leapd","leapd",0);
  }

  cfg.path("../../setup");
  cfg.args("leap.provider.", argv);
  if (argc == 1) cfg.load("config.csv");
  verbose = cfg.flag("leap.provider.verbose", false);
  if (verbose) cfg.show();
  
  decay_time = cfg.num("leap.provider.decay_time");
  
  int hwm = 1;
  int retries = 5;
  int linger = 25;
  int rc = 0;
  bool connected = false;
  
  MyListener listener;
  Controller controller(listener);	
  
  zmq_context = zmq_ctx_new ();
  zmq_pub = zmq_socket(zmq_context,ZMQ_PUB);

  while(!connected && retries--) {
	  if(zmq_setsockopt(zmq_pub, ZMQ_SNDHWM, &hwm, sizeof(hwm)) == 0) {
	  	if(zmq_setsockopt(zmq_pub, ZMQ_LINGER, &linger, sizeof(linger)) == 0) {
	  		if(zmq_bind(zmq_pub, cfg.str("leap.provider.publish").c_str()) == 0) {
				connected = true;
			}

		}		
	  }
	  if (retries <= 0) {
	    int en=zmq_errno();
	    std::cout << "TCP Error Number " << en << " " << zmq_strerror(en) << std::endl;
	    die = true;
	  }
	  std::this_thread::sleep_for(std::chrono::milliseconds(200));
  }
  signal(SIGINT, quitproc);
  signal(SIGTERM, quitproc);
  signal(SIGQUIT, quitproc);

  while(!die) {
    std::this_thread::sleep_for(std::chrono::milliseconds(500));
  }

  controller.removeListener(listener);
  zmq_close(zmq_pub);
  zmq_ctx_destroy(zmq_context);

  kill(leapd_pid,SIGINT);
  waitpid(leapd_pid,0,0);

  std::cout << "--done!" << std::endl;

  return 0;
}