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
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041 #ifndef _GAZEBO_ROS_CONTROL___DEFAULT_ROBOT_HW_SIM_H_
00042 #define _GAZEBO_ROS_CONTROL___DEFAULT_ROBOT_HW_SIM_H_
00043
00044
00045 #include <control_toolbox/pid.h>
00046 #include <hardware_interface/joint_command_interface.h>
00047 #include <hardware_interface/robot_hw.h>
00048 #include <joint_limits_interface/joint_limits.h>
00049 #include <joint_limits_interface/joint_limits_interface.h>
00050 #include <joint_limits_interface/joint_limits_rosparam.h>
00051 #include <joint_limits_interface/joint_limits_urdf.h>
00052
00053
00054 #include <gazebo/common/common.hh>
00055 #include <gazebo/physics/physics.hh>
00056 #include <gazebo/gazebo.hh>
00057
00058
00059 #include <ros/ros.h>
00060 #include <angles/angles.h>
00061 #include <pluginlib/class_list_macros.h>
00062
00063
00064 #include <gazebo_ros_control/robot_hw_sim.h>
00065
00066
00067 #include <urdf/model.h>
00068
00069
00070
00071 namespace gazebo_ros_control
00072 {
00073
00074 class DefaultRobotHWSim : public gazebo_ros_control::RobotHWSim
00075 {
00076 public:
00077
00078 virtual bool initSim(
00079 const std::string& robot_namespace,
00080 ros::NodeHandle model_nh,
00081 gazebo::physics::ModelPtr parent_model,
00082 const urdf::Model *const urdf_model,
00083 std::vector<transmission_interface::TransmissionInfo> transmissions);
00084
00085 virtual void readSim(ros::Time time, ros::Duration period);
00086
00087 virtual void writeSim(ros::Time time, ros::Duration period);
00088
00089 virtual void eStopActive(const bool active);
00090
00091 protected:
00092
00093 enum ControlMethod {EFFORT, POSITION, POSITION_PID, VELOCITY, VELOCITY_PID};
00094
00095
00096
00097
00098 void registerJointLimits(const std::string& joint_name,
00099 const hardware_interface::JointHandle& joint_handle,
00100 const ControlMethod ctrl_method,
00101 const ros::NodeHandle& joint_limit_nh,
00102 const urdf::Model *const urdf_model,
00103 int *const joint_type, double *const lower_limit,
00104 double *const upper_limit, double *const effort_limit);
00105
00106 unsigned int n_dof_;
00107
00108 hardware_interface::JointStateInterface js_interface_;
00109 hardware_interface::EffortJointInterface ej_interface_;
00110 hardware_interface::PositionJointInterface pj_interface_;
00111 hardware_interface::VelocityJointInterface vj_interface_;
00112
00113 joint_limits_interface::EffortJointSaturationInterface ej_sat_interface_;
00114 joint_limits_interface::EffortJointSoftLimitsInterface ej_limits_interface_;
00115 joint_limits_interface::PositionJointSaturationInterface pj_sat_interface_;
00116 joint_limits_interface::PositionJointSoftLimitsInterface pj_limits_interface_;
00117 joint_limits_interface::VelocityJointSaturationInterface vj_sat_interface_;
00118 joint_limits_interface::VelocityJointSoftLimitsInterface vj_limits_interface_;
00119
00120 std::vector<std::string> joint_names_;
00121 std::vector<int> joint_types_;
00122 std::vector<double> joint_lower_limits_;
00123 std::vector<double> joint_upper_limits_;
00124 std::vector<double> joint_effort_limits_;
00125 std::vector<ControlMethod> joint_control_methods_;
00126 std::vector<control_toolbox::Pid> pid_controllers_;
00127 std::vector<double> joint_position_;
00128 std::vector<double> joint_velocity_;
00129 std::vector<double> joint_effort_;
00130 std::vector<double> joint_effort_command_;
00131 std::vector<double> joint_position_command_;
00132 std::vector<double> last_joint_position_command_;
00133 std::vector<double> joint_velocity_command_;
00134
00135 std::vector<gazebo::physics::JointPtr> sim_joints_;
00136
00137
00138 bool e_stop_active_, last_e_stop_active_;
00139 };
00140
00141 typedef boost::shared_ptr<DefaultRobotHWSim> DefaultRobotHWSimPtr;
00142
00143 }
00144
00145 #endif // #ifndef __GAZEBO_ROS_CONTROL_PLUGIN_DEFAULT_ROBOT_HW_SIM_H_