load_image_bundle.cpp
Go to the documentation of this file.
1 
6 /*****************************************************************************
7 ** Includes
8 *****************************************************************************/
9 
11 #include <ecl/command_line.hpp>
12 #include <ecl/console.hpp>
13 #include <exception>
14 
15 #include <ros/init.h>
16 #include <ros/ros.h>
17 #include <string>
18 
19 #include "../../include/cost_map_ros/utilities.hpp"
20 
21 /*****************************************************************************
22 ** Main
23 *****************************************************************************/
24 
25 int main(int argc, char **argv) {
26  ecl::CmdLine cmd("Load an image bundle into a costmap and publish");
27  ecl::ValueArg<std::string> topicNameArg(
28  "t",
29  "topic_name",
30  "Where to publish [default: ~cost_map]",
31  false,
32  "cost_map",
33  "string");
35  "image_bundle_location",
36  "A yaml file with meta-data about the costmap to be built",
37  true,
38  "cost_map_ros/example",
39  "string (package/name OR yaml filename)");
40  cmd.add(topicNameArg);
41  cmd.add(imageBundleArg);
42  std::vector<std::string> myargs;
43  ros::removeROSArgs(argc, argv, myargs);
44  char** myargv = new char*[myargs.size()]; //array to emulate argv.
45  for(int i = 0, ie = myargs.size(); i < ie; ++i)
46  {
47  myargv[i] = const_cast<char*>(myargs[i].data());
48  }
49  cmd.parse(myargs.size(), myargv);
50 
51 
52  ros::init(argc, argv, "image_bundle");
53  try {
54  cost_map::LoadImageBundle loader(imageBundleArg.getValue(), topicNameArg.getValue());
55 // if ( broken_layer_probably_isnt_obstacle_costs ) {
56 // cost_map::Matrix data = loader.cost_map->get("obstacle_costs");
57 // for (int i = 0, number_of_rows = data.rows(), number_of_columns = data.cols(); i < number_of_rows; ++i) {
58 // for (int j = 0; j < number_of_columns; ++j) {
59 // std::cout << static_cast<int>(data(i,j)) << " ";
60 // }
61 // std::cout << std::endl;
62 // }
63 // }
64  ros::spin();
65  } catch (const std::exception& e) {
66  std::cout << ecl::red << "[ERROR] " << e.what() << ecl::reset << std::endl;
67  return EXIT_FAILURE;
68  }
69  return EXIT_SUCCESS;
70 }
string cmd
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
void add(Arg &a)
int main(int argc, char **argv)
Helper for loading and publishing image bundles.
ROSCPP_DECL void spin()
ROSCPP_DECL void removeROSArgs(int argc, const char *const *argv, V_string &args_out)
void parse(int argc, char **argv)


cost_map_ros
Author(s): Daniel Stonier
autogenerated on Mon Jun 10 2019 13:03:48