robot_description.cpp
Go to the documentation of this file.
1 /*
2  * Copyright 2015 Aldebaran
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16 */
17 
18 /*
19 * LOCAL includes
20 */
21 #include "robot_description.hpp"
22 #include "../helpers/filesystem_helpers.hpp"
23 
24 namespace naoqi{
25 
26 namespace tools{
27 
28 std::string getRobotDescription( const robot::Robot& robot){
29  std::string urdf_path;
30  static std::string robot_desc;
31  if(!robot_desc.empty())
32  return robot_desc;
33 
34  if ( robot == robot::PEPPER)
35  {
36  urdf_path = helpers::filesystem::getURDF("pepper.urdf");
37  }
38  else if ( robot == robot::NAO )
39  {
40  urdf_path = helpers::filesystem::getURDF("nao.urdf");
41  }
42  else if ( robot == robot::ROMEO )
43  {
44  urdf_path = helpers::filesystem::getURDF("romeo.urdf");
45  }
46  else
47  {
48  std::cerr << " could not load urdf file from disk " << std::endl;
49  return std::string();
50  }
51 
52  std::ifstream stream( (urdf_path).c_str() );
53  if (!stream)
54  {
55  std::cerr << "failed to load robot description in joint_state_publisher: " << urdf_path << std::endl;
56  return std::string();
57  }
58  robot_desc = std::string( (std::istreambuf_iterator<char>(stream)), std::istreambuf_iterator<char>());
59  return robot_desc;
60 }
61 
62 } // tools
63 
64 } // naoqi
std::string & getURDF(std::string filename)
std::string getRobotDescription(const robot::Robot &robot)


naoqi_driver
Author(s): Karsten Knese
autogenerated on Sat Feb 15 2020 03:24:26