Main Page
+
Classes
Class List
Class Hierarchy
+
Class Members
+
All
_
a
c
d
f
g
h
i
m
o
p
r
s
u
x
~
+
Functions
a
c
d
f
g
h
i
m
o
p
r
s
u
x
~
Variables
+
Files
File List
+
File Members
All
Functions
Macros
src
main.cpp
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2015, C. Dornhege, University of Freiburg
3
* All rights reserved.
4
*
5
* Redistribution and use in source and binary forms, with or without
6
* modification, are permitted provided that the following conditions are met:
7
*
8
* * Redistributions of source code must retain the above copyright notice, this
9
* list of conditions and the following disclaimer.
10
* * Redistributions in binary form must reproduce the above copyright notice,
11
* this list of conditions and the following disclaimer in the documentation
12
* and/or other materials provided with the distribution.
13
* * Neither the name of the University of Freiburg nor the names
14
* of its contributors may be used to endorse or promote products derived from
15
* this software without specific prior written permission.
16
*
17
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
21
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
23
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
24
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
25
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
*/
28
29
#include <
ros/ros.h
>
30
#include <QApplication>
31
#include <string>
32
#include <stdio.h>
33
#include <stdlib.h>
34
#include "
MainWindow.h
"
35
#include "
qt_paramedit/xmlRpcModel.h
"
36
37
void
usage
(
char
* pname)
38
{
39
printf(
"Usage: %s [parameter root] (default: /)\n"
, pname);
40
exit(1);
41
}
42
43
int
main
(
int
argc,
char
** argv)
44
{
45
ros::init
(argc, argv,
"qt_paramedit"
);
46
47
std::string paramRoot =
"/"
;
48
if
(argc > 1) {
49
if
(argc > 2)
// only 1 param
50
usage
(argv[0]);
51
paramRoot = argv[1];
52
}
53
54
ros::NodeHandle
nh;
55
56
std::string err;
57
if
(!
ros::names::validate
(paramRoot, err)) {
58
ROS_FATAL
(
"Invalid name: %s - Error: %s"
, paramRoot.c_str(), err.c_str());
59
usage
(argv[0]);
60
}
61
if
(paramRoot.empty()) {
62
ROS_FATAL
(
"Empty param root."
);
63
usage
(argv[0]);
64
}
65
66
XmlRpc::XmlRpcValue
xmlrpc;
67
if
(!nh.
getParam
(paramRoot, xmlrpc)) {
68
ROS_FATAL
(
"Could not get parameters at: \"%s\""
, paramRoot.c_str());
69
return
1;
70
}
71
if
(xmlrpc.
getType
() !=
XmlRpc::XmlRpcValue::TypeStruct
) {
72
ROS_FATAL
(
"Requested param root has non struct type. Can only handle dictionaries, not single parameters."
);
73
usage
(argv[0]);
74
}
75
ROS_DEBUG
(
"Retrieved parameters from: \"%s\""
, paramRoot.c_str());
76
77
QApplication app(argc, argv);
78
MainWindow
gui(xmlrpc, paramRoot, &nh);
79
80
gui.show();
81
82
ros::WallRate
loop(20.0);
83
while
(
ros::ok
() && gui.isVisible()) {
84
ros::spinOnce
();
85
86
app.processEvents();
87
88
loop.
sleep
();
89
}
90
91
return
0;
92
}
ROS_FATAL
#define ROS_FATAL(...)
ros::NodeHandle
XmlRpc::XmlRpcValue
main
int main(int argc, char **argv)
Definition:
main.cpp:43
ros::init
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
MainWindow.h
ros::names::validate
ROSCPP_DECL bool validate(const std::string &name, std::string &error)
ros::WallRate
XmlRpc::XmlRpcValue::getType
Type const & getType() const
xmlRpcModel.h
ros::NodeHandle::getParam
bool getParam(const std::string &key, std::string &s) const
ros::ok
ROSCPP_DECL bool ok()
ros.h
usage
void usage(char *pname)
Definition:
main.cpp:37
ros::spinOnce
ROSCPP_DECL void spinOnce()
ros::WallRate::sleep
bool sleep()
MainWindow
Definition:
MainWindow.h:35
XmlRpc::XmlRpcValue::TypeStruct
TypeStruct
ROS_DEBUG
#define ROS_DEBUG(...)
qt_paramedit
Author(s): Christian Dornhege
autogenerated on Mon Feb 28 2022 23:37:51