37 #include <std_msgs/Float64.h> 44 SrhJointMuscleValveController::SrhJointMuscleValveController()
45 : cmd_valve_muscle_min_(-4),
46 cmd_valve_muscle_max_(4)
54 std::string robot_state_name;
55 node_.
param<std::string>(
"robot_state_name", robot_state_name,
"unique_robot_hw");
59 robot_ = robot->getHandle(robot_state_name).getState();
63 ROS_ERROR_STREAM(
"Could not find robot state: " << robot_state_name <<
" Not loading the controller. " <<
90 ROS_ERROR(
"SrhJointMuscleValveController could not find the first joint relevant to \"%s\"\n",
96 ROS_ERROR(
"SrhJointMuscleValveController could not find the second joint relevant to \"%s\"\n",
106 ROS_ERROR(
"SrhJointMuscleValveController could not find joint named \"%s\"\n",
joint_name_.c_str());
122 sr_robot_msgs::JointMuscleValveControllerCommand>(
"command", 1,
182 double pressure_0_tmp = fmod(
joint_state_->effort_, 0x10000);
183 double pressure_1_tmp = (fmod(
joint_state_->effort_, 0x100000000) - pressure_0_tmp) / 0x10000;
184 uint16_t pressure_0 =
static_cast<uint16_t
> (pressure_0_tmp + 0.5);
185 uint16_t pressure_1 =
static_cast<uint16_t
> (pressure_1_tmp + 0.5);
208 for (i = 0; i < 2; ++i)
251 uint16_t valve_tmp[2];
252 for (i = 0; i < 2; ++i)
266 valve_tmp[i] = -valve[i] + 8;
270 valve_tmp[i] = valve[i];
277 joint_state_->commanded_effort_ =
static_cast<double> (valve_tmp[0]) + static_cast<double> (valve_tmp[1] << 4);
virtual const char * what() const
ros_ethercat_model::JointState * joint_state_
virtual bool resetGains(std_srvs::Empty::Request &req, std_srvs::Empty::Response &resp)
Subscriber subscribe(const std::string &topic, uint32_t queue_size, void(T::*fp)(M), T *obj, const TransportHints &transport_hints=TransportHints())
int8_t cmd_valve_muscle_[2]
int8_t clamp_command(int8_t cmd)
enforce that the value of the received command is in the allowed range
int8_t cmd_valve_muscle_min_
virtual void getGains(double &p, double &i, double &d, double &i_max, double &i_min)
void read_parameters()
read all the controller settings from the parameter server
ServiceServer advertiseService(const std::string &service, bool(T::*srv_func)(MReq &, MRes &), T *obj)
ros_ethercat_model::JointState * joint_state_2
Compute an effort demand from the effort error. As the effort PID loop is running on the motor boards...
boost::scoped_ptr< sr_friction_compensation::SrFrictionCompensator > friction_compensator
ros_ethercat_model::RobotState * robot_
unsigned int current_duration_ms_[2]
bool param(const std::string ¶m_name, T ¶m_val, const T &default_val) const
const std::string & getNamespace() const
boost::shared_ptr< realtime_tools::RealtimePublisher< sr_robot_msgs::JointMuscleValveControllerState > > controller_state_publisher_
std::string getJointName()
#define ROS_WARN_STREAM(args)
#define ROS_DEBUG_STREAM(args)
virtual void starting(const ros::Time &time)
unsigned int cmd_duration_ms_[2]
void setCommandCB(const sr_robot_msgs::JointMuscleValveControllerCommandConstPtr &msg)
int8_t cmd_valve_muscle_max_
void get_joints_states_1_2()
bool getParam(const std::string &key, std::string &s) const
bool init(ros_ethercat_model::RobotStateInterface *robot, ros::NodeHandle &n)
#define ROS_ERROR_STREAM(args)
#define PLUGINLIB_EXPORT_CLASS(class_type, base_class_type)
ros::ServiceServer serve_reset_gains_
virtual void update(const ros::Time &time, const ros::Duration &period)
Issues commands to the joint. Should be called at regular intervals.
ros::Subscriber sub_command_