コード例 #1
0
/**
 * Putting it all together.
 *
 * @param  argc
 * @param  argv
 * @return
 */
int main(int argc, char* argv[]) {
  // Default options.
  icu::UnicodeString database = "dummy1";
  bool loop = false;
  bool echo = false;
  int rate = 1000;

  // Parse command line arguments.
  for (int i = 0; i < argc; i++) {
    if (0 == std::strcmp(argv[i], "-loop")) {
      loop = true;
    } else if (0 == std::strcmp(argv[i], "-echo")) {
      echo = true;
    } else if (0 == std::strncmp(argv[i], "-rate=", 6)) {
      rate = utils::toInt(std::string(argv[i]).substr(6));
    } else if (0 == std::strncmp(argv[i], "-database=", 10)) {
      database = utils::toUS(std::string(argv[i]).substr(10));
    }
  }

  // Initalize and run annotators
  AnnotationGateway gateway = AnnotationGateway();
  gateway.setParameter("Database", database);
  gateway.run();

  // Get required iterators.
  uima::Feature jnFtr = gateway.getFeature("JointState", "jointNames");
  uima::ANIterator jsIter = gateway.getANIterator("JointState");
  std::vector<std::string> jointNames;
  jointNames = utils::toVector(jsIter.get().getStringArrayFSValue(jnFtr));

  // Let user choose which joints to display.
  std::pair< std::vector<int>, std::vector<std::string> > selected;
  selected = chooseJoints(jointNames);

  std::string plot = choosePlot(selected.first.size());
  coutlinesep();

  // Initialize ros.
  ros::init(argc, argv, "rta_plotting");
  ros::NodeHandle node;

  // Fire off the topic!
  Topics topics = Topics(node, gateway, selected, rate, loop, echo);
  topics.plot(plot);

  return 0;
}