36 #include <std_msgs/Float64.h> 46 SrhJointVelocityController::SrhJointVelocityController()
47 : velocity_deadband(0.015)
55 std::string robot_state_name;
56 node_.
param<std::string>(
"robot_state_name", robot_state_name,
"unique_robot_hw");
60 robot_ = robot->getHandle(robot_state_name).getState();
64 ROS_ERROR_STREAM(
"Could not find robot state: " << robot_state_name <<
" Not loading the controller. " <<
96 ROS_ERROR(
"SrhVelocityController could not find the first joint relevant to \"%s\"\n",
joint_name_.c_str());
101 ROS_ERROR(
"SrhVelocityController could not find the second joint relevant to \"%s\"\n",
joint_name_.c_str());
155 sr_robot_msgs::SetPidGains::Response &resp)
225 double error_velocity = 0.0;
226 double commanded_effort = 0.0;
241 error_velocity = 0.0;
254 commanded_effort = max(commanded_effort, -(
max_force_demand * max_force_factor_));
261 static_cast<int>(commanded_effort),
268 static_cast<int>(commanded_effort),
void get_min_max(urdf::Model model, std::string joint_name)
virtual const char * what() const
ros_ethercat_model::JointState * joint_state_
virtual void update(const ros::Time &time, const ros::Duration &period)
Issues commands to the joint. Should be called at regular intervals.
bool setGains(sr_robot_msgs::SetPidGains::Request &req, sr_robot_msgs::SetPidGains::Response &resp)
double clamp_command(double cmd)
clamp the command to velocity limits
boost::scoped_ptr< realtime_tools::RealtimePublisher< control_msgs::JointControllerState > > controller_state_publisher_
bool init(ros_ethercat_model::RobotStateInterface *robot, ros::NodeHandle &n)
virtual bool resetGains(std_srvs::Empty::Request &req, std_srvs::Empty::Response &resp)
double velocity_deadband
the velocity deadband value used in the hysteresis_deadband
void setCommandCB(const std_msgs::Float64ConstPtr &msg)
set the velocity target from a topic
ServiceServer advertiseService(const std::string &service, bool(T::*srv_func)(MReq &, MRes &), T *obj)
ros_ethercat_model::JointState * joint_state_2
boost::scoped_ptr< sr_friction_compensation::SrFrictionCompensator > friction_compensator
virtual void getGains(double &p, double &i, double &d, double &i_max, double &i_min)
double clamp_command(double cmd, double min_cmd, double max_cmd)
ros_ethercat_model::RobotState * robot_
Follows a position target. The position demand is converted into a force demand by a PID loop...
int friction_deadband
the deadband for the friction compensation algorithm
bool param(const std::string ¶m_name, T ¶m_val, const T &default_val) const
const std::string & getNamespace() const
virtual void starting(const ros::Time &time)
bool is_in_deadband(T demand, T error, T deadband, double deadband_multiplicator=5.0, unsigned int nb_errors_for_avg=50)
void read_parameters()
read all the controller settings from the parameter server
#define ROS_WARN_STREAM(args)
double vel_min_
Min and max range of the velocity, used to clamp the command.
#define ROS_DEBUG_STREAM(args)
double max_force_demand
clamps the force demand to this value
void get_joints_states_1_2()
boost::scoped_ptr< control_toolbox::Pid > pid_controller_velocity_
Internal PID controller for the velocity loop.
sr_deadband::HysteresisDeadband< double > hysteresis_deadband
We're using an hysteresis deadband.
bool getParam(const std::string &key, std::string &s) const
ros::ServiceServer serve_set_gains_
#define ROS_ERROR_STREAM(args)
#define PLUGINLIB_EXPORT_CLASS(class_type, base_class_type)
void setParam(const std::string &key, const XmlRpc::XmlRpcValue &v) const
void after_init()
call this function at the end of the init function in the inheriting classes.
ros::ServiceServer serve_reset_gains_