sr_controller.hpp
Go to the documentation of this file.
1 
27 #ifndef _SRH_CONTROLLER_HPP_
28 #define _SRH_CONTROLLER_HPP_
29 
30 #include <ros/node_handle.h>
31 
33 #include <ros_ethercat_model/robot_state_interface.hpp>
34 #include <control_toolbox/pid.h>
35 #include <boost/scoped_ptr.hpp>
36 #include <boost/thread/condition.hpp>
38 #include <std_msgs/Float64.h>
39 #include <std_srvs/Empty.h>
40 #include <control_msgs/JointControllerState.h>
41 
42 #include <utility>
43 #include <string>
44 
45 #include <sr_robot_msgs/SetPidGains.h>
46 
48 
50 
51 
52 namespace controller
53 {
54 class SrController :
55  public controller_interface::Controller<ros_ethercat_model::RobotStateInterface>
56 {
57 public:
58  SrController();
59 
60  virtual ~SrController();
61 
62  virtual bool init(ros_ethercat_model::RobotStateInterface *robot, ros::NodeHandle &n) = 0;
63 
64  virtual void starting(const ros::Time &time)
65  {
66  };
67 
71  virtual void update(const ros::Time &time, const ros::Duration &period) = 0;
72 
73  virtual bool resetGains(std_srvs::Empty::Request &req, std_srvs::Empty::Response &resp)
74  {
75  return true;
76  };
77 
78  virtual void getGains(double &p, double &i, double &d, double &i_max, double &i_min)
79  {
80  };
81 
82  std::string getJointName();
83 
84  ros_ethercat_model::JointState *joint_state_;
86  ros_ethercat_model::JointState *joint_state_2;
88  bool has_j2;
90  double command_;
92 protected:
93  // true if this is joint 0
94  bool is_joint_0();
95 
96  // set joint_state_ and joint_state_2
97  void get_joints_states_1_2();
98 
100  void after_init();
101 
112  double clamp_command(double cmd, double min_cmd, double max_cmd);
113 
122  virtual double clamp_command(double cmd);
123 
131  void get_min_max(urdf::Model model, std::string joint_name);
132 
134  double min_, max_;
139 
142  ros_ethercat_model::RobotState *robot_;
146  std::string joint_name_;
147 
148  boost::scoped_ptr<realtime_tools::RealtimePublisher
149  <control_msgs::JointControllerState> > controller_state_publisher_;
150 
151  boost::scoped_ptr<sr_friction_compensation::SrFrictionCompensator> friction_compensator;
152 
154  virtual void setCommandCB(const std_msgs::Float64ConstPtr &msg)
155  {
156  }
157 
161 
166 
169 
170  // The max force factor is a number between 0.0 and 1.0 that will multiply the max_force_demand
171  // it is initialized to 1.0 and can be updated via a topic.
172  // This is intended to be used e.g. as part of a hand self protection mechanism, where max_force is reduced
173  // in certain cases
176 
182  void maxForceFactorCB(const std_msgs::Float64ConstPtr &msg);
183 };
184 } // namespace controller
185 
186 /* For the emacs weenies in the crowd.
187 Local Variables:
188  c-basic-offset: 2
189 End:
190 */
191 
192 
193 #endif
void get_min_max(urdf::Model model, std::string joint_name)
ros_ethercat_model::JointState * joint_state_
ros::Subscriber sub_max_force_factor_
double eff_min_
Min and max range of the effort, used to clamp the command.
virtual void getGains(double &p, double &i, double &d, double &i_max, double &i_min)
boost::scoped_ptr< realtime_tools::RealtimePublisher< control_msgs::JointControllerState > > controller_state_publisher_
virtual bool resetGains(std_srvs::Empty::Request &req, std_srvs::Empty::Response &resp)
virtual bool init(ros_ethercat_model::RobotStateInterface *robot, ros::NodeHandle &n)=0
ros_ethercat_model::JointState * joint_state_2
boost::scoped_ptr< sr_friction_compensation::SrFrictionCompensator > friction_compensator
void maxForceFactorCB(const std_msgs::Float64ConstPtr &msg)
double clamp_command(double cmd, double min_cmd, double max_cmd)
ros::Subscriber sub_command_
robot
ros_ethercat_model::RobotState * robot_
Compensate the tendon friction by adding a given value depending on the sign of the force demand...
int friction_deadband
the deadband for the friction compensation algorithm
virtual void starting(const ros::Time &time)
double min_
Min and max range of the joint, used to clamp the command.
double vel_min_
Min and max range of the velocity, used to clamp the command.
double max_force_demand
clamps the force demand to this value
ros::ServiceServer serve_set_gains_
virtual void setCommandCB(const std_msgs::Float64ConstPtr &msg)
set the command from a topic
virtual void update(const ros::Time &time, const ros::Duration &period)=0
Issues commands to the joint. Should be called at regular intervals.
sr_deadband::HysteresisDeadband< double > hysteresis_deadband
We&#39;re using an hysteresis deadband.
void after_init()
call this function at the end of the init function in the inheriting classes.
ros::ServiceServer serve_reset_gains_


sr_mechanism_controllers
Author(s): Ugo Cupcic
autogenerated on Tue Oct 13 2020 03:55:58