Exemple #1
0
int main(int argc, char **argv) {
  boost::mpi::environment env(argc, argv);
  std::shared_ptr<boost::mpi::communicator> world(new
                                                  boost::mpi::communicator());

  string config_file;

  if (IsMaster(world)) {
    ros::init(argc, argv, "real_test");
    ros::NodeHandle nh("~");
    nh.param("config_file", config_file, std::string(""));
  }

  ObjectRecognizer object_recognizer(world);

  // All processes should wait until master has loaded params.
  world->barrier();
  broadcast(*world, config_file, kMasterRank);

  ConfigParser parser;
  parser.Parse(config_file);

  RecognitionInput input;
  input.x_min = parser.min_x;
  input.x_max = parser.max_x;
  input.y_min = parser.min_y;
  input.y_max = parser.max_y;
  input.table_height = parser.table_height;
  input.camera_pose = parser.camera_pose;
  input.model_names = parser.ConvertModelNamesInFileToIDs(
                        object_recognizer.GetModelBank());

  boost::filesystem::path config_file_path(config_file);
  input.heuristics_dir = ros::package::getPath("sbpl_perception") +
                         "/heuristics/" + config_file_path.stem().string();

  // Objects for storing the point clouds.
  pcl::PointCloud<PointT>::Ptr cloud_in(new PointCloud);

  // Read the input PCD file from disk.
  if (pcl::io::loadPCDFile<PointT>(parser.pcd_file_path.c_str(),
                                   *cloud_in) != 0) {
    cerr << "Could not find input PCD file!" << endl;
    return -1;
  }

  input.cloud = cloud_in;

  vector<ContPose> detected_poses;
  object_recognizer.LocalizeObjects(input, &detected_poses);
  return 0;
}