32 #include <boost/foreach.hpp> 33 #include <boost/algorithm/string.hpp> 35 #include <sr_utilities/sr_math_utils.hpp> 43 using std::ostringstream;
44 using sr_actuator::SrMuscleActuator;
53 using boost::static_pointer_cast;
58 template<
class StatusType,
class CommandType>
61 template<
class StatusType,
class CommandType>
64 "muscle_data_pressure",
65 "muscle_data_can_stats",
66 "muscle_data_slow_misc" 69 template<
class StatusType,
class CommandType>
77 template<
class StatusType,
class CommandType>
80 string device_id,
string joint_prefix) :
81 SrMuscleRobotLib<StatusType, CommandType>(hw, nh, nhtilde, device_id, joint_prefix)
82 #ifdef DEBUG_PUBLISHER
96 for (
unsigned int i = 0; i < this->muscle_update_rate_configs_vector.size(); ++i)
101 if (this->muscle_update_rate_configs_vector[i].when_to_update == -2)
112 ss <<
"reset_muscle_driver_" << i;
116 std_srvs::Empty::Response>(ss.str().c_str(),
128 vector<string> joint_names_tmp;
130 vector<JointToSensor> joints_to_sensors;
137 joint_names_tmp.push_back(
string(joint_names[i]));
139 joints_to_sensors.push_back(tmp_jts);
141 initialize(joint_names_tmp, joint_to_muscle_map, joint_to_sensor_vect);
144 template<
class StatusType,
class CommandType>
146 vector<int> actuator_ids,
147 vector<JointToSensor> joint_to_sensors)
149 ROS_ERROR(
"This version of SrMuscleHandLib<StatusType, CommandType>::initialize should not be used");
152 template<
class StatusType,
class CommandType>
154 vector<JointToMuscle> actuator_ids,
155 vector<JointToSensor> joint_to_sensors)
157 for (
unsigned int index = 0; index < joint_names.size(); ++index)
166 if (actuator_ids[index].muscle_driver_id[0] != -1)
171 muscle_wrapper->muscle_driver_id[0] = actuator_ids[index].muscle_driver_id[0];
172 muscle_wrapper->muscle_driver_id[1] = actuator_ids[index].muscle_driver_id[1];
173 muscle_wrapper->muscle_id[0] = actuator_ids[index].muscle_id[0];
174 muscle_wrapper->muscle_id[1] = actuator_ids[index].muscle_id[1];
175 muscle_wrapper->actuator =
static_cast<SrMuscleActuator *
> (this->
hw_->getActuator(
188 template<
class StatusType,
class CommandType>
190 std_srvs::Empty::Response &response,
191 int muscle_driver_index)
200 template<
class StatusType,
class CommandType>
203 vector<JointToMuscle> muscle_map;
204 string param_name =
"joint_to_muscle_mapping";
210 for (int32_t i = 0; i < mapping.
size(); ++i)
225 joint_to_muscle.
muscle_id[0] = mapping[i][0][1];
227 joint_to_muscle.
muscle_id[1] = mapping[i][1][1];
229 muscle_map.push_back(joint_to_muscle);
235 #ifdef DEBUG_PUBLISHER 236 template <
class StatusType,
class CommandType>
238 CommandType>::set_debug_data_to_publish(sr_robot_msgs::SetDebugData::Request& request,
239 sr_robot_msgs::SetDebugData::Response&
response)
242 if (request.publisher_index < this->nb_debug_publishers_const)
246 response.success =
false;
249 if (request.motor_data_type > 0)
254 response.success =
false;
258 if (!this->debug_mutex.timed_lock(boost::posix_time::microseconds(this->debug_mutex_lock_wait_time)))
260 response.success =
false;
266 this->debug_motor_indexes_and_data[request.publisher_index]->first = request.motor_index;
267 this->debug_motor_indexes_and_data[request.publisher_index]->second = request.motor_data_type;
268 this->debug_mutex.unlock();
272 response.success =
false;
276 response.success =
true;
std::vector< generic_updater::UpdateConfig > read_update_rate_configs(std::string base_param, int nb_data_defined, const char *human_readable_data_types[], const int32u data_types[])
JointToSensor joint_to_sensor
bool reset_muscle_driver_callback(std_srvs::Empty::Request &request, std_srvs::Empty::Response &response, int muscle_driver_index)
std::queue< int16_t, std::list< int16_t > > reset_muscle_driver_queue
std::vector< shadow_joints::MuscleDriver > muscle_drivers_vector_
std::vector< shadow_joints::Joint > joints_vector
The vector containing all the robot joints.
static const int32u muscle_data_types[]
ServiceServer advertiseService(ros::NodeHandle n, std::string name, boost::function< bool(const typename ActionSpec::_action_goal_type::_goal_type &, typename ActionSpec::_action_result_type::_result_type &result)> service_cb)
static const int nb_muscle_data
ros::NodeHandle nodehandle_
a ros nodehandle to be able to access resources out of the node namespace
std::string joint_prefix_
Prefix used to access the joints.
Type const & getType() const
std::map< unsigned int, unsigned int > from_muscle_driver_data_received_flags_
ros::NodeHandle nh_tilde
a ROS nodehandle (private naming, only inside the node namespace) to be able to advertise the Force P...
bool getParam(const std::string &key, std::string &s) const
virtual void initialize(std::vector< std::string > joint_names, std::vector< int > actuator_ids, std::vector< shadow_joints::JointToSensor > joint_to_sensors)
boost::shared_ptr< generic_updater::MuscleUpdater< CommandType > > muscle_updater_
boost::shared_ptr< SrActuatorWrapper > actuator_wrapper
#define ROS_INFO_STREAM(args)
ros_ethercat_model::RobotState * hw_
ros::ServiceServer reset_driver_service
std::vector< shadow_joints::JointToSensor > read_joint_to_sensor_mapping()
static const char * human_readable_muscle_data_types[]
SrMuscleHandLib(hardware_interface::HardwareInterface *hw, ros::NodeHandle nh, ros::NodeHandle nhtilde, std::string device_id, std::string joint_prefix)
std::vector< shadow_joints::JointToMuscle > read_joint_to_muscle_mapping()
std::vector< generic_updater::UpdateConfig > muscle_update_rate_configs_vector
#define NUM_MUSCLE_DRIVERS
const std::string response