Go to the documentation of this file.00001 #ifndef __YUMI_HW_H
00002 #define __YUMI_HW_H
00003
00004
00005 #include <boost/scoped_ptr.hpp>
00006
00007
00008 #include <std_msgs/Duration.h>
00009 #include <urdf/model.h>
00010
00011
00012 #include <hardware_interface/robot_hw.h>
00013 #include <hardware_interface/joint_state_interface.h>
00014 #include <hardware_interface/joint_command_interface.h>
00015 #include <transmission_interface/transmission_info.h>
00016 #include <transmission_interface/transmission_parser.h>
00017 #include <joint_limits_interface/joint_limits.h>
00018 #include <joint_limits_interface/joint_limits_interface.h>
00019 #include <joint_limits_interface/joint_limits_rosparam.h>
00020 #include <joint_limits_interface/joint_limits_urdf.h>
00021 #include <control_toolbox/filters.h>
00022
00023
00024 #include <kdl/kdl.hpp>
00025 #include <kdl/tree.hpp>
00026 #include <kdl/chain.hpp>
00027 #include <kdl/chaindynparam.hpp>
00028 #include <kdl_parser/kdl_parser.hpp>
00029
00034 class YumiHW : public hardware_interface::RobotHW
00035 {
00036 public:
00037
00038 YumiHW()
00039 {
00040 n_joints_=14;
00041 }
00042 virtual ~YumiHW() {}
00043
00044 void create(std::string name, std::string urdf_string);
00045
00046
00047 std::string robot_namespace_;
00048
00049
00050 std::string urdf_string_;
00051 urdf::Model urdf_model_;
00052
00053
00054
00055
00056
00057 enum ControlStrategy {JOINT_POSITION = 10, JOINT_VELOCITY = 15};
00058 virtual bool canSwitch(const std::list<hardware_interface::ControllerInfo> &start_list, const std::list<hardware_interface::ControllerInfo> &stop_list) const;
00059 virtual void doSwitch(const std::list<hardware_interface::ControllerInfo> &start_list, const std::list<hardware_interface::ControllerInfo> &stop_list);
00060
00061
00062 virtual bool init() = 0;
00063 virtual void read(ros::Time time, ros::Duration period) = 0;
00064 virtual void write(ros::Time time, ros::Duration period) = 0;
00065
00066
00067 void setControlStrategy( ControlStrategy strategy){current_strategy_ = strategy;};
00068 ControlStrategy getControlStrategy(){ return current_strategy_;};
00069
00070
00071 hardware_interface::JointStateInterface state_interface_;
00072
00073 hardware_interface::PositionJointInterface position_interface_;
00074 hardware_interface::VelocityJointInterface velocity_interface_;
00075
00076 ControlStrategy current_strategy_;
00077
00078
00079
00080
00081 joint_limits_interface::VelocityJointSaturationInterface vj_sat_interface_;
00082 joint_limits_interface::VelocityJointSoftLimitsInterface vj_limits_interface_;
00083 joint_limits_interface::PositionJointSaturationInterface pj_sat_interface_;
00084 joint_limits_interface::PositionJointSoftLimitsInterface pj_limits_interface_;
00085
00086
00087 void enforceLimits(ros::Duration period);
00088
00089
00090 int n_joints_;
00091 std::vector<std::string> joint_names_;
00092
00093
00094 std::vector<double>
00095 joint_lower_limits_,
00096 joint_upper_limits_;
00097
00098
00099 std::vector<double>
00100 joint_position_,
00101 joint_position_prev_,
00102 joint_velocity_,
00103 joint_effort_,
00104 joint_position_command_,
00105 joint_velocity_command_;
00106
00107
00108 void reset();
00109
00110
00111 std::vector<transmission_interface::TransmissionInfo> transmissions_;
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122 private:
00123
00124
00125 bool parseTransmissionsFromURDF(const std::string& urdf_string);
00126
00127
00128 void registerInterfaces(const urdf::Model *const urdf_model,
00129 std::vector<transmission_interface::TransmissionInfo> transmissions);
00130
00131
00132
00133
00134
00135 void registerJointLimits(const std::string& joint_name,
00136 const hardware_interface::JointHandle& joint_handle_position,
00137 const hardware_interface::JointHandle& joint_handle_velocity,
00138 const urdf::Model *const urdf_model,
00139 double *const lower_limit, double *const upper_limit);
00140
00141 };
00142
00143
00144
00145 #endif