12 #include <cost_map_msgs/GetCostMap.h> 13 #include <nav_msgs/OccupancyGrid.h> 26 int main(
int argc,
char **argv) {
30 ecl::CmdLine cmd(
"Relays service provided cost maps to an occupancy grid publisher.");
31 ecl::ValueArg<float> lengthArg(
"l",
"length",
"Length of a side of the costmap subwindow.",
false, 2,
"float", cmd);
35 cmd.
parse(argc, argv);
42 bool persistent =
true, latched =
true;
43 std::cout <<
"Looking up service: " << serviceNameArg.
getValue() << std::endl;
49 ros::Publisher occupancy_grid_publisher = nodehandle.
advertise<nav_msgs::OccupancyGrid>(
"occupancy_grid", 5, latched);
54 cost_map_msgs::GetCostMap srv;
55 srv.request.length_x = lengthArg.
getValue();
56 srv.request.length_y = lengthArg.
getValue();
57 std::string layer_name = layerNameArg.
getValue();
60 if (!get_cost_map.
call(srv))
66 nav_msgs::OccupancyGrid occupancy_grid_msg;
73 occupancy_grid_publisher.
publish(occupancy_grid_msg);
ServiceClient serviceClient(const std::string &service_name, bool persistent=false, const M_string &header_values=M_string())
void publish(const boost::shared_ptr< M > &message) const
int main(int argc, char **argv)
std::string resolveName(const std::string &name, bool remap=true) const
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
bool call(MReq &req, MRes &res)
bool waitForExistence(ros::Duration timeout=ros::Duration(-1))
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
void toOccupancyGrid(const cost_map::CostMap &cost_map, const std::string &layer, nav_msgs::OccupancyGrid &msg)
void parse(int argc, char **argv)
const std::vector< std::string > & getLayers() const
#define ROS_ERROR_STREAM(args)
ROSCPP_DECL void spinOnce()
bool fromMessage(const cost_map_msgs::CostMap &message, cost_map::CostMap &cost_map)