1 #ifndef __ROS_CONTROL_INTERFACE__ 2 #define __ROS_CONTROL_INTERFACE__ 21 template <
class Jo
intInterface>
51 std::vector<hardware_interface::JointHandle>
joints_;
56 template <
class Jo
intInterface>
62 JointInterface* hw =
new JointInterface();
64 dynamic_cast<hardware_interface::EffortJointInterface*>(hw))
69 dynamic_cast<hardware_interface::VelocityJointInterface*>(hw))
74 dynamic_cast<hardware_interface::PositionJointInterface*>(hw))
80 throw std::logic_error(
"UNKNOWN JOINT INTERFACE TYPE");
84 template <
class Jo
intInterface>
101 ROS_ERROR(
"Missing joint names parameter");
109 if (!urdf.
initParam(
"robot_description"))
115 for (
unsigned int i = 0; i <
n_joints_; i++)
121 joints_.push_back(hw->getHandle(name));
128 urdf::JointConstSharedPtr joint_urdf = urdf.getJoint(name);
131 ROS_ERROR(
"Could not find joint '%s' in urdf", name.c_str());
142 template <
class Jo
intInterface>
148 template <
class Jo
intInterface>
152 sensor_msgs::JointState curr_state,
command;
154 for (
unsigned int i = 0; i <
n_joints_; i++)
157 curr_state.position.push_back(
joints_[i].getPosition());
158 curr_state.velocity.push_back(
joints_[i].getVelocity());
159 curr_state.effort.push_back(
joints_[i].getEffort());
162 command =
controller_->updateControl(curr_state, period);
164 for (
unsigned int i = 0; i <
n_joints_; i++)
168 for (
unsigned int j = 0; j < command.name.size(); j++)
170 if (command.name[j] == name)
175 joints_[i].setCommand(command.effort[j]);
178 joints_[i].setCommand(command.velocity[j]);
181 joints_[i].setCommand(command.position[j]);
189 template <
class Jo
intInterface>
const char * what() const noexcept override
ROSLIB_DECL std::string command(const std::string &cmd)
bool getParam(const std::string &key, std::string &s) const
URDF_EXPORT bool initParam(const std::string ¶m)
const std::string & getNamespace() const
#define ROS_ERROR_STREAM(args)