test
test_joint_names.cpp
Go to the documentation of this file.
1
/*
2
* Software License Agreement (BSD License)
3
*
4
* Copyright (c) 2013, Southwest Research Institute
5
* All rights reserved.
6
*
7
* Redistribution and use in source and binary forms, with or without
8
* modification, are permitted provided that the following conditions are met:
9
*
10
* * Redistributions of source code must retain the above copyright
11
* notice, this list of conditions and the following disclaimer.
12
* * Redistributions in binary form must reproduce the above copyright
13
* notice, this list of conditions and the following disclaimer in the
14
* documentation and/or other materials provided with the distribution.
15
* * Neither the name of the Southwest Research Institute, nor the names
16
* of its contributors may be used to endorse or promote products derived
17
* from this software without specific prior written permission.
18
*
19
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
23
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29
* POSSIBILITY OF SUCH DAMAGE.
30
*/
31
32
#include "
industrial_utils/utils.h
"
33
#include "
ros/ros.h
"
34
35
using namespace
industrial_utils
;
36
37
#define ROS_ERROR_EXIT(...) do {ROS_ERROR(__VA_ARGS__); exit(-1); } while (0)
38
39
// Quick program to test joint-name extraction from URDF
40
int
main
(
int
argc,
char
**argv)
41
{
42
if
(argc != 2)
43
ROS_ERROR_EXIT
(
"Usage: test_joint_names my_robot.urdf"
);
44
45
urdf::Model
model;
46
if
(!model.
initFile
(argv[1]))
47
ROS_ERROR_EXIT
(
"Unable to open URDF file: %s"
, argv[1]);
48
49
std::vector<std::string> joint_names;
50
if
(!
findChainJointNames
(model.getRoot(),
true
, joint_names))
51
ROS_ERROR_EXIT
(
"Unable to read Joint Names from URDF"
);
52
53
printf(
"Joint names: "
);
54
std::ostringstream
s
;
55
std::copy(joint_names.begin(), joint_names.end(), std::ostream_iterator<std::string>(
s
,
", "
));
56
std::string out =
s
.str();
57
std::cout <<
"["
<< out.erase(out.size()-2) <<
"]"
<< std::endl;
58
59
return
1;
60
}
industrial_utils::findChainJointNames
bool findChainJointNames(const urdf::LinkConstSharedPtr &link, bool ignore_fixed, std::vector< std::string > &joint_names)
Definition:
utils.cpp:72
industrial_utils
Definition:
param_utils.h:40
s
XmlRpcServer s
ros.h
main
int main(int argc, char **argv)
Definition:
test_joint_names.cpp:40
urdf::Model
utils.h
urdf::Model::initFile
URDF_EXPORT bool initFile(const std::string &filename)
ROS_ERROR_EXIT
#define ROS_ERROR_EXIT(...)
Definition:
test_joint_names.cpp:37
industrial_utils
Author(s): Shaun Edwards
autogenerated on Wed Mar 2 2022 00:24:51