main.cpp
Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2011, C. Dornhege, University of Freiburg
00003  * All rights reserved.
00004  * 
00005  * Redistribution and use in source and binary forms, with or without
00006  * modification, are permitted provided that the following conditions are met:
00007  *
00008  *  * Redistributions of source code must retain the above copyright notice, this
00009  *    list of conditions and the following disclaimer.  
00010  *  * Redistributions in binary form must reproduce the above copyright notice, 
00011  *    this list of conditions and the following disclaimer in the documentation 
00012  *    and/or other materials provided with the distribution.  
00013  *  * Neither the name of the University of Freiburg nor the names
00014  *    of its contributors may be used to endorse or promote products derived from
00015  *    this software without specific prior written permission.
00016  * 
00017  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
00018  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
00019  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00020  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
00021  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00022  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
00023  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00024  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
00025  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00026  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00027  */
00028 
00029 #include <ros/ros.h>
00030 #include <QApplication>
00031 #include <string>
00032 #include <stdio.h>
00033 #include <stdlib.h>
00034 #include "MainWindow.h"
00035 #include "rxparamedit/xmlRpcModel.h"
00036 
00037 void usage(char* pname)
00038 {
00039    printf("Usage: %s [parameter root] (default: /)\n", pname);
00040    exit(1);
00041 }
00042 
00043 int main(int argc, char** argv)
00044 {
00045    ros::init(argc, argv, "rxparamedit");
00046 
00047    std::string paramRoot = "/";
00048    if(argc > 1) {
00049       if(argc > 2)                           // only 1 param
00050          usage(argv[0]);
00051       paramRoot = argv[1];
00052    }
00053 
00054    ros::NodeHandle nh;
00055 
00056    std::string err;
00057    if(!ros::names::validate(paramRoot, err)) {
00058       ROS_FATAL("Invalid name: %s - Error: %s", paramRoot.c_str(), err.c_str());
00059       usage(argv[0]);
00060    }
00061    if(paramRoot.empty()) {
00062       ROS_FATAL("Empty param root.");
00063       usage(argv[0]);
00064    }
00065 
00066    XmlRpc::XmlRpcValue xmlrpc;
00067    if(!nh.getParam(paramRoot, xmlrpc)) {
00068       ROS_FATAL("Could not get parameters at: \"%s\"", paramRoot.c_str());
00069       return 1;
00070    }
00071    if(xmlrpc.getType() != XmlRpc::XmlRpcValue::TypeStruct) {
00072       ROS_FATAL("Requested param root has non struct type. Can only handle dictionaries, not single parameters.");
00073       usage(argv[0]);
00074    }
00075    ROS_DEBUG("Retrieved parameters from: \"%s\"", paramRoot.c_str());
00076 
00077    QApplication app(argc, argv);
00078    MainWindow gui(xmlrpc, paramRoot, &nh);
00079 
00080    gui.show();
00081 
00082    ros::WallRate loop(20.0);
00083    while(ros::ok() && gui.isVisible()) {
00084       ros::spinOnce();
00085 
00086       app.processEvents();
00087 
00088       loop.sleep();
00089    }
00090 
00091    return 0;
00092 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Properties Friends Defines


rxparamedit
Author(s): Christian Dornhege
autogenerated on Wed Dec 26 2012 15:33:39