Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #include <fstream>
00018 #include <iostream>
00019 #include <sstream>
00020 #include <string>
00021 #include <ros/ros.h>
00022 #include "o3d3xx/Config.h"
00023
00024 int main(int argc, char **argv)
00025 {
00026 std::string infile;
00027 std::string json;
00028
00029 ros::init(argc, argv, "o3d3xx_config");
00030
00031 ros::NodeHandle nh("~");
00032 nh.param("infile", infile, std::string("-"));
00033
00034 if (infile == "-")
00035 {
00036 std::string line;
00037 std::ostringstream buff;
00038 while (std::getline(std::cin, line))
00039 {
00040 buff << line << std::endl;
00041 }
00042
00043 json.assign(buff.str());
00044 }
00045 else
00046 {
00047 std::ifstream ifs(infile, std::ios::in);
00048 if (! ifs)
00049 {
00050 ROS_ERROR("Failed to open file: %s", infile.c_str());
00051 return -1;
00052 }
00053
00054 json.assign((std::istreambuf_iterator<char>(ifs)),
00055 (std::istreambuf_iterator<char>()));
00056 }
00057
00058 ros::ServiceClient client = nh.serviceClient<o3d3xx::Config>("/Config");
00059
00060 o3d3xx::Config srv;
00061 srv.request.json = json;
00062
00063 if (client.call(srv))
00064 {
00065 ROS_INFO("status=%d", srv.response.status);
00066 ROS_INFO("msg=%s", srv.response.msg.c_str());
00067 }
00068 else
00069 {
00070 ROS_ERROR("Failed to call `Config' service!");
00071 return 1;
00072 }
00073
00074 return 0;
00075 }