35 #include <std_msgs/Float64.h> 36 #include <control_msgs/JointControllerState.h> 37 #include <sr_robot_msgs/JointControllerState.h> 45 "This interface is deprecated, you should probably use " 46 "the interface provided by the etherCAT driver directly.");
64 tmpDataZero.
max = 180.0;
67 std::string full_topic =
"";
234 std::string joint_prefix;
235 n_tilde.
param(
"joint_prefix", joint_prefix, std::string(
""));
238 std::string controller_suffix =
"position_controller";
240 std::string searched_param;
242 n_tilde.
param(searched_param, controller_suffix, std::string(
"position_controller"));
244 std::string topic_prefix =
"/sh_";
245 std::string topic_suffix =
"_" + controller_suffix +
"/command";
246 std::string full_topic = topic_prefix + joint_prefix + joint_name + topic_suffix;
257 JointsMap::iterator iter =
joints_map.find(joint_name);
258 std_msgs::Float64 target_msg;
263 ROS_DEBUG(
"Joint %s not found", joint_name.c_str());
272 if (target < tmpData.
min)
274 target = tmpData.
min;
276 if (target > tmpData.
max)
278 target = tmpData.
max;
301 JointsMap::iterator iter =
joints_map.find(joint_name);
312 ROS_ERROR(
"Joint %s not found.", joint_name.c_str());
325 "The set Controller function is not implemented in the EtherCAT compatibility wrapper, " 326 "please use the provided services directly.");
334 "The get Controller function is not implemented in the EtherCAT compatibility wrapper, " 335 "please use the provided services directly.");
341 ROS_WARN(
"The set config function is not implemented.");
347 ROS_WARN(
"The get config function is not implemented.");
352 std::vector<DiagnosticData> returnVect;
363 bool fj0flag =
false;
364 double fj0pos, fj0vel, fj0eff;
366 for (
unsigned int index = 0; index < msg->name.size(); ++index)
368 std::string joint_name = msg->name[index];
369 JointsMap::iterator iter =
joints_map.find(joint_name);
379 if (joint_name.find(
"FJ1") != std::string::npos)
382 if (fj0flag && joint_name[0] == fj0char[0])
384 std::string j0name = fj0char +
"FJ0";
385 JointsMap::iterator myiter =
joints_map.find(j0name);
395 tmpDatazero.
velocity = fj0vel + msg->effort[index];
396 tmpDatazero.
force = fj0eff + msg->velocity[index];
409 fj0eff = msg->effort[index];
410 fj0vel = msg->velocity[index];
411 fj0char.push_back(joint_name[0]);
415 else if (joint_name.find(
"FJ2") != std::string::npos)
418 if (fj0flag && joint_name[0] == fj0char[0])
420 std::string j0name = fj0char +
"FJ0";
421 JointsMap::iterator myiter =
joints_map.find(j0name);
431 tmpDatazero.
force = fj0vel + msg->effort[index];
432 tmpDatazero.
velocity = fj0eff + msg->velocity[index];
445 fj0eff = msg->effort[index];
446 fj0vel = msg->velocity[index];
447 fj0char.push_back(joint_name[0]);
454 tmpData.
force = msg->effort[index];
455 tmpData.
velocity = msg->velocity[index];
virtual JointData getJointData(std::string joint_name)
std::vector< ros::Publisher > etherCAT_publishers
virtual ~EtherCATCompatibilityHand()
Subscriber subscribe(const std::string &topic, uint32_t queue_size, void(T::*fp)(M), T *obj, const TransportHints &transport_hints=TransportHints())
std::map< std::string, JointData > JointsMap
static double to_degrees(double rad)
static double to_rad(double degrees)
EtherCATCompatibilityHand()
std::string findControllerTopicName(std::string joint_name)
bool searchParam(const std::string &key, std::string &result) const
bool param(const std::string ¶m_name, T ¶m_val, const T &default_val) const
JointsMap joints_map
A mapping between the joint names and the information regarding those joints.
virtual std::vector< DiagnosticData > getDiagnostics()
virtual JointControllerData getContrl(std::string ctrlr_name)
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
This compatibility interface is a wrapper around the new etherCAT Hand ROS driver. It is used to present the same interface as the CAN hand.
This is a parent class for the different types of Shadowhand we can have. It makes it possible to swa...
virtual int16_t sendupdate(std::string joint_name, double target)
virtual JointsMap getAllJointsData()
boost::mutex joints_map_mutex
virtual void getConfig(std::string joint_name)
void joint_states_callback(const sensor_msgs::JointStateConstPtr &msg)
virtual int16_t setContrl(std::string contrlr_name, JointControllerData ctrlr_data)
virtual int16_t setConfig(std::vector< std::string > myConfig)
ros::Subscriber joint_state_subscriber