45 const std::vector<std::string>& joint_names = hw->
getNames();
48 ROS_DEBUG(
"Got joint %s", joint_names[i].c_str());
52 ROS_ERROR(
"Parameter 'publish_rate' not set");
110 if (!nh.
getParam(
"extra_joints", list))
112 ROS_DEBUG(
"No extra joints specification found.");
118 ROS_ERROR(
"Extra joints specification is not an array. Ignoring.");
122 for(std::size_t i = 0; i < list.
size(); ++i)
126 ROS_ERROR_STREAM(
"Extra joint specification is not a struct, but rather '" << list[i].getType() <<
131 if (!list[i].hasMember(
"name"))
137 const std::string name = list[i][
"name"];
138 if (std::find(msg.name.begin(), msg.name.end(), name) != msg.name.end())
140 ROS_WARN_STREAM(
"Joint state interface already contains specified extra joint '" << name <<
"'.");
144 const bool has_pos = list[i].
hasMember(
"position");
145 const bool has_vel = list[i].
hasMember(
"velocity");
146 const bool has_eff = list[i].
hasMember(
"effort");
149 if (has_pos && list[i][
"position"].getType() != typeDouble)
151 ROS_ERROR_STREAM(
"Extra joint '" << name <<
"' does not specify a valid default position. Ignoring.");
154 if (has_vel && list[i][
"velocity"].getType() != typeDouble)
156 ROS_ERROR_STREAM(
"Extra joint '" << name <<
"' does not specify a valid default velocity. Ignoring.");
159 if (has_eff && list[i][
"effort"].getType() != typeDouble)
161 ROS_ERROR_STREAM(
"Extra joint '" << name <<
"' does not specify a valid default effort. Ignoring.");
166 const double pos = has_pos ?
static_cast<double>(list[i][
"position"]) : 0.0;
167 const double vel = has_vel ?
static_cast<double>(list[i][
"velocity"]) : 0.0;
168 const double eff = has_eff ?
static_cast<double>(list[i][
"effort"]) : 0.0;
171 msg.name.push_back(name);
172 msg.position.push_back(pos);
173 msg.velocity.push_back(vel);
174 msg.effort.push_back(eff);
ros::Time last_publish_time_
virtual void update(const ros::Time &time, const ros::Duration &)
virtual bool init(hardware_interface::JointStateInterface *hw, ros::NodeHandle &root_nh, ros::NodeHandle &controller_nh)
Type const & getType() const
virtual void starting(const ros::Time &time)
unsigned int num_hw_joints_
Number of joints present in the JointStateInterface, excluding extra joints.
#define ROS_WARN_STREAM(args)
void addExtraJoints(const ros::NodeHandle &nh, sensor_msgs::JointState &msg)
JointStateHandle getHandle(const std::string &name)
bool hasMember(const std::string &name) const
bool getParam(const std::string &key, std::string &s) const
boost::shared_ptr< realtime_tools::RealtimePublisher< sensor_msgs::JointState > > realtime_pub_
std::vector< std::string > getNames() const
#define ROS_ERROR_STREAM(args)
std::vector< hardware_interface::JointStateHandle > joint_state_
#define PLUGINLIB_EXPORT_CLASS(class_type, base_class_type)
virtual void stopping(const ros::Time &)
Controller that publishes the state of all joints in a robot.