armadillo2_sim_interface.h
Go to the documentation of this file.
00001 //
00002 // Created by tom on 09/04/16.
00003 //
00004 
00005 #ifndef ARMADILLO2_HARDWARE_INTERFACE_ROBOT_SIM_INTERFACE_H
00006 #define ARMADILLO2_HARDWARE_INTERFACE_ROBOT_SIM_INTERFACE_H
00007 
00008 // ros_control
00009 #include <control_toolbox/pid.h>
00010 #include <hardware_interface/joint_command_interface.h>
00011 #include <hardware_interface/posvelacc_command_interface.h>
00012 #include <hardware_interface/robot_hw.h>
00013 #include <joint_limits_interface/joint_limits.h>
00014 #include <joint_limits_interface/joint_limits_interface.h>
00015 #include <joint_limits_interface/joint_limits_rosparam.h>
00016 #include <joint_limits_interface/joint_limits_urdf.h>
00017 
00018 // Gazebo
00019 #include <gazebo/common/common.hh>
00020 #include <gazebo/physics/physics.hh>
00021 #include <gazebo/gazebo.hh>
00022 
00023 // ROS
00024 #include <ros/ros.h>
00025 #include <angles/angles.h>
00026 #include <pluginlib/class_list_macros.h>
00027 
00028 // gazebo_ros_control
00029 #include <gazebo_ros_control/robot_hw_sim.h>
00030 
00031 // URDF
00032 #include <urdf/model.h>
00033 
00034 
00035 namespace gazebo_ros_control {
00036 
00037     class Armadillo2RobotHWSim : public gazebo_ros_control::RobotHWSim
00038     {
00039     public:
00040 
00041         virtual bool initSim(
00042                 const std::string& robot_namespace,
00043                 ros::NodeHandle model_nh,
00044                 gazebo::physics::ModelPtr parent_model,
00045                 const urdf::Model *const urdf_model,
00046                 std::vector<transmission_interface::TransmissionInfo> transmissions);
00047 
00048         virtual void readSim(ros::Time time, ros::Duration period);
00049 
00050         virtual void writeSim(ros::Time time, ros::Duration period);
00051 
00052         virtual void eStopActive(const bool active);
00053 
00054     protected:
00055         // Methods used to control a joint.
00056         enum ControlMethod {EFFORT, POSITION, POSITION_PID, VELOCITY, VELOCITY_PID, POS_VEL};
00057 
00058         // Register the limits of the joint specified by joint_name and joint_handle. The limits are
00059         // retrieved from joint_limit_nh. If urdf_model is not NULL, limits are retrieved from it also.
00060         // Return the joint's type, lower position limit, upper position limit, and effort limit.
00061         void registerJointLimits(const std::string& joint_name,
00062                                  const hardware_interface::JointHandle& joint_handle,
00063                                  const ControlMethod ctrl_method,
00064                                  const ros::NodeHandle& joint_limit_nh,
00065                                  const urdf::Model *const urdf_model,
00066                                  int *const joint_type, double *const lower_limit,
00067                                  double *const upper_limit, double *const effort_limit);
00068 
00069         void registerJointLimits(const std::string& joint_name,
00070                                  const hardware_interface::PosVelJointHandle& joint_handle,
00071                                  const ControlMethod ctrl_method,
00072                                  const ros::NodeHandle& joint_limit_nh,
00073                                  const urdf::Model *const urdf_model,
00074                                  int *const joint_type, double *const lower_limit,
00075                                  double *const upper_limit, double *const effort_limit);
00076 
00077         unsigned int n_dof_;
00078 
00079         hardware_interface::JointStateInterface    js_interface_;
00080         hardware_interface::EffortJointInterface   ej_interface_;
00081         hardware_interface::PositionJointInterface pj_interface_;
00082         hardware_interface::VelocityJointInterface vj_interface_;
00083         hardware_interface::PosVelJointInterface pvj_interface_;
00084 
00085         joint_limits_interface::EffortJointSaturationInterface   ej_sat_interface_;
00086         joint_limits_interface::EffortJointSoftLimitsInterface   ej_limits_interface_;
00087         joint_limits_interface::PositionJointSaturationInterface pj_sat_interface_;
00088         joint_limits_interface::PositionJointSoftLimitsInterface pj_limits_interface_;
00089         joint_limits_interface::VelocityJointSaturationInterface vj_sat_interface_;
00090         joint_limits_interface::VelocityJointSoftLimitsInterface vj_limits_interface_;
00091 
00092 
00093         std::vector<std::string> joint_names_;
00094         std::vector<int> joint_types_;
00095         std::vector<double> joint_lower_limits_;
00096         std::vector<double> joint_upper_limits_;
00097         std::vector<double> joint_effort_limits_;
00098         std::vector<ControlMethod> joint_control_methods_;
00099         std::vector<control_toolbox::Pid> pid_controllers_;
00100         std::vector<double> joint_position_;
00101         std::vector<double> joint_velocity_;
00102         std::vector<double> joint_effort_;
00103         std::vector<double> joint_effort_command_;
00104         std::vector<double> joint_position_command_;
00105         std::vector<double> last_joint_position_command_;
00106         std::vector<double> joint_velocity_command_;
00107 
00108         std::vector<gazebo::physics::JointPtr> sim_joints_;
00109 
00110         // e_stop_active_ is true if the emergency stop is active.
00111         bool e_stop_active_, last_e_stop_active_;
00112     };
00113 
00114     typedef boost::shared_ptr<Armadillo2RobotHWSim> DefaultRobotHWSimPtr;
00115 }
00116 
00117 
00118 #endif //ROBOTICAN_HARDWARE_INTERFACE_ROBOT_SIM_INTERFACE_H
00119 


robotican_hardware_interface
Author(s):
autogenerated on Fri Oct 27 2017 03:02:48