naoqidriver
converter_base.hpp
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 #ifndef BASE_CONVERTER_HPP
19 #define BASE_CONVERTER_HPP
20 
21 /*
22 * LOCAL includes
23 */
24 #include <naoqi_driver/tools.hpp>
25 #include "../helpers/driver_helpers.hpp"
26 
27 /*
28 * ALDEBARAN includes
29 */
30 #include <qi/session.hpp>
31 #include <qi/anyobject.hpp>
32 
33 namespace naoqi
34 {
35 namespace converter
36 {
37 
38 // CRTP
39 template<class T>
41 {
42 
43 public:
44  BaseConverter( const std::string& name, float frequency, qi::SessionPtr session ):
45  name_( name ),
46  frequency_( frequency ),
47  robot_( helpers::driver::getRobot(session) ),
48  session_(session),
49  record_enabled_(false)
50  {}
51 
52  virtual ~BaseConverter() {}
53 
54  inline std::string name() const
55  {
56  return name_;
57  }
58 
59  inline float frequency() const
60  {
61  return frequency_;
62  }
63 
66  /*
67  inline Robot robot() const
68  {
69  if (robot_ != UNIDENTIFIED)
70  return robot_;
71 
72  qi::AnyObject p_memory = session_->service("ALMemory");
73  std::string robot;
74  try{
75  robot = p_memory.call<qi::AnyValue>("getData", "RobotConfig/Body/Type" ).toString();
76  }
77  catch(std::runtime_error& e)
78  {
79  return UNIDENTIFIED;
80  }
81 
82  std::transform(robot.begin(), robot.end(), robot.begin(), ::tolower);
83  std::cout << "found robot variable " << robot << std::endl;
84  if (std::string(robot) == "nao")
85  {
86  robot_ = NAO;
87  return robot_;
88  }
89  else if (std::string(robot) == "pepper" || std::string(robot) == "juliette")
90  {
91  robot_ = PEPPER;
92  return robot_;
93  }
94  else
95  {
96  robot_ = UNIDENTIFIED;
97  return robot_;
98  }
99  }*/
100 
101 protected:
102  std::string name_;
103 
105  float frequency_;
108 
110  qi::SessionPtr session_;
111 
114 }; // class
115 
116 } // converter
117 } // naoqi
118 
119 #endif
std::string name() const
Definition: converter_base.hpp:54
float frequency() const
Definition: converter_base.hpp:59
bool record_enabled_
Definition: converter_base.hpp:113
BaseConverter(const std::string &name, float frequency, qi::SessionPtr session)
Definition: converter_base.hpp:44
std::string name_
Definition: converter_base.hpp:102
Definition: audio.cpp:29
Robot
Definition: tools.hpp:37
const robot::Robot & robot_
Definition: converter_base.hpp:107
float frequency_
Definition: converter_base.hpp:105
Definition: converter_base.hpp:40
virtual ~BaseConverter()
Definition: converter_base.hpp:52
qi::SessionPtr session_
Definition: converter_base.hpp:110
const robot::Robot & getRobot(const qi::SessionPtr &session)
Definition: driver_helpers.cpp:54