o3d3xx_config_node.cpp
Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2014 Love Park Robotics, LLC
00003  *
00004  * Licensed under the Apache License, Version 2.0 (the "License");
00005  * you may not use this file except in compliance with the License.
00006  * You may obtain a copy of the License at
00007  *
00008  * http://www.apache.org/licenses/LICENSE-2.0
00009  *
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distribted on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
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 }


o3d3xx
Author(s): Tom Panzarella
autogenerated on Thu Jun 6 2019 18:17:40