Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef NAOQI_DCM_DRIVER_H
00019 #define NAOQI_DCM_DRIVER_H
00020
00021
00022 #include <boost/shared_ptr.hpp>
00023
00024
00025 #include <qi/session.hpp>
00026 #include <qi/anyobject.hpp>
00027 #include <qi/os.hpp>
00028 #include <qi/anyvalue.hpp>
00029
00030
00031 #include <ros/ros.h>
00032
00033 #include <geometry_msgs/Twist.h>
00034 #include <sensor_msgs/Imu.h>
00035 #include <sensor_msgs/Range.h>
00036 #include <sensor_msgs/JointState.h>
00037 #include <std_msgs/Float32.h>
00038
00039 #include <tf/transform_broadcaster.h>
00040 #include <tf/transform_listener.h>
00041 #include <tf/transform_datatypes.h>
00042
00043 #include <hardware_interface/joint_command_interface.h>
00044 #include <hardware_interface/joint_state_interface.h>
00045 #include <hardware_interface/robot_hw.h>
00046
00047 #include <controller_manager/controller_manager.h>
00048
00049 #include "naoqi_dcm_driver/diagnostics.hpp"
00050 #include "naoqi_dcm_driver/memory.hpp"
00051 #include "naoqi_dcm_driver/dcm.hpp"
00052 #include "naoqi_dcm_driver/motion.hpp"
00053
00054 template<typename T, size_t N>
00055 T * end(T (&ra)[N]) {
00056 return ra + N;
00057 }
00058
00059 class Robot : public hardware_interface::RobotHW
00060 {
00061 public:
00066 Robot(qi::SessionPtr session);
00067
00069 ~Robot();
00070
00072 void stopService();
00073
00075 bool isConnected();
00076
00078 bool connect();
00079
00081 void run();
00082
00083 private:
00085 bool initializeControllers(const std::vector <std::string> &joints_names);
00086
00088 void subscribe();
00089
00091 bool loadParams();
00092
00094 void controllerLoop();
00095
00097 void commandVelocity(const geometry_msgs::TwistConstPtr &msg);
00098
00100 void publishBaseFootprint(const ros::Time &ts);
00101
00103 std::vector <bool> checkJoints();
00104
00106 void readJoints();
00107
00109 void publishJointStateFromAlMotion();
00110
00112 void writeJoints();
00113
00115 bool setStiffness(const float &stiffness);
00116
00118 void ignoreMimicJoints(std::vector <std::string> *joints);
00119
00121 boost::scoped_ptr <ros::NodeHandle> nhPtr_;
00122
00124 boost::shared_ptr <Diagnostics> diagnostics_;
00125
00127 boost::shared_ptr <Memory> memory_;
00128
00130 boost::shared_ptr <DCM> dcm_;
00131
00133 boost::shared_ptr <Motion> motion_;
00134
00136 ros::Subscriber cmd_moveto_sub_;
00137
00139 tf::TransformBroadcaster base_footprint_broadcaster_;
00140
00142 tf::TransformListener base_footprint_listener_;
00143
00145 ros::Publisher stiffness_pub_;
00146
00148 ros::Publisher diag_pub_;
00149
00151 ros::Publisher joint_states_pub_;
00152
00154 std_msgs::Float32 stiffness_;
00155
00157 sensor_msgs::JointState joint_states_topic_;
00158
00160 controller_manager::ControllerManager* manager_;
00161
00163 std::string session_name_;
00164
00166 bool is_connected_;
00167
00169 std::string body_type_;
00170
00172 std::string prefix_;
00173
00175 std::string odom_frame_;
00176
00178 int topic_queue_;
00179
00181 double high_freq_;
00182
00184 double controller_freq_;
00185
00187 double joint_precision_;
00188
00190 qi::SessionPtr _session;
00191
00193 std::vector <std::string> motor_groups_;
00194
00196 hardware_interface::JointStateInterface jnt_state_interface_;
00197
00199 hardware_interface::PositionJointInterface jnt_pos_interface_;
00200
00202 std::vector <std::string> qi_joints_;
00203
00205 std::vector <double> qi_commands_;
00206
00208 std::vector <std::string> hw_joints_;
00209
00211 std::vector <bool> hw_enabled_;
00212
00214 std::vector <double> hw_commands_;
00215
00217 std::vector <double> hw_angles_;
00218
00220 std::vector <double> hw_velocities_;
00221
00223 std::vector <double> hw_efforts_;
00224
00226 bool use_dcm_;
00227
00229 float stiffness_value_;
00230 };
00231
00232 #endif // NAOQI_DCM_DRIVER_H