robot.hpp
Go to the documentation of this file.
1 /*
2  * Copyright 2016 SoftBank Robotics Europe
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 NAOQI_DCM_DRIVER_H
19 #define NAOQI_DCM_DRIVER_H
20 
21 // Boost Headers
22 #include <boost/shared_ptr.hpp>
23 
24 // NAOqi Headers
25 #include <qi/session.hpp>
26 #include <qi/anyobject.hpp>
27 #include <qi/os.hpp>
28 #include <qi/anyvalue.hpp>
29 
30 // ROS Headers
31 #include <ros/ros.h>
32 
33 #include <geometry_msgs/Twist.h>
34 #include <sensor_msgs/Imu.h>
35 #include <sensor_msgs/Range.h>
36 #include <sensor_msgs/JointState.h>
37 #include <std_msgs/Float32.h>
38 
40 #include <tf/transform_listener.h>
41 #include <tf/transform_datatypes.h>
42 
46 
48 
51 #include "naoqi_dcm_driver/dcm.hpp"
53 
54 template<typename T, size_t N>
55 T * end(T (&ra)[N]) {
56  return ra + N;
57 }
58 
60 {
61 public:
66  Robot(qi::SessionPtr session);
67 
69  ~Robot();
70 
72  void stopService();
73 
75  bool isConnected();
76 
78  bool connect();
79 
81  void run();
82 
83 private:
85  bool initializeControllers(const std::vector <std::string> &joints_names);
86 
88  void subscribe();
89 
91  bool loadParams();
92 
94  void controllerLoop();
95 
97  void commandVelocity(const geometry_msgs::TwistConstPtr &msg);
98 
100  void publishBaseFootprint(const ros::Time &ts);
101 
103  std::vector <bool> checkJoints();
104 
106  void readJoints();
107 
109  void publishJointStateFromAlMotion();
110 
112  void writeJoints();
113 
115  bool setStiffness(const float &stiffness);
116 
118  void ignoreMimicJoints(std::vector <std::string> *joints);
119 
121  boost::scoped_ptr <ros::NodeHandle> nhPtr_;
122 
124  boost::shared_ptr <Diagnostics> diagnostics_;
125 
128 
131 
134 
136  ros::Subscriber cmd_moveto_sub_;
137 
139  tf::TransformBroadcaster base_footprint_broadcaster_;
140 
142  tf::TransformListener base_footprint_listener_;
143 
145  ros::Publisher stiffness_pub_;
146 
148  ros::Publisher diag_pub_;
149 
151  ros::Publisher joint_states_pub_;
152 
154  std_msgs::Float32 stiffness_;
155 
157  sensor_msgs::JointState joint_states_topic_;
158 
161 
163  std::string session_name_;
164 
166  bool is_connected_;
167 
169  std::string body_type_;
170 
172  std::string prefix_;
173 
175  std::string odom_frame_;
176 
178  int topic_queue_;
179 
181  double high_freq_;
182 
184  double controller_freq_;
185 
187  double joint_precision_;
188 
190  qi::SessionPtr _session;
191 
193  std::vector <std::string> motor_groups_;
194 
196  hardware_interface::JointStateInterface jnt_state_interface_;
197 
200 
202  std::vector <std::string> qi_joints_;
203 
205  std::vector <double> qi_commands_;
206 
208  std::vector <std::string> hw_joints_;
209 
211  std::vector <bool> hw_enabled_;
212 
214  std::vector <double> hw_commands_;
215 
217  std::vector <double> hw_angles_;
218 
220  std::vector <double> hw_velocities_;
221 
223  std::vector <double> hw_efforts_;
224 
226  bool use_dcm_;
227 
229  float stiffness_value_;
230 };
231 
232 #endif // NAOQI_DCM_DRIVER_H
msg
Definition: robot.hpp:59
T * end(T(&ra)[N])
Definition: robot.hpp:55


naoqi_dcm_driver
Author(s): Konstantinos Chatzilygeroudis , Mikael Arguedas , Karsten Knese , Natalia Lyubova
autogenerated on Thu Jul 25 2019 03:49:27