55 ROS_ERROR(
"Mechanism Model received an invalid hardware interface");
61 ROS_ERROR(
"Mechanism Model failed to parse the URDF xml into a robot model");
67 "pr2_mechanism_model",
"pr2_mechanism_model::Transmission"));
70 TiXmlElement *xit = NULL;
71 for (xit = root->FirstChildElement(
"transmission"); xit;
72 xit = xit->NextSiblingElement(
"transmission"))
74 std::string type(xit->Attribute(
"type"));
81 for(
unsigned int i = 0; i < classes.size(); ++i)
85 ROS_WARN(
"The deprecated transmission type %s was not found. Using the namespaced version %s instead. " 86 "Please update your urdf file to use the namespaced version.",
87 type.c_str(), classes[i].c_str());
95 catch (
const std::runtime_error &ex)
97 ROS_ERROR(
"Could not load class %s: %s", type.c_str(), ex.what());
101 ROS_ERROR(
"Unknown transmission type: %s", type.c_str());
102 else if (!t->initXml(xit,
this)){
103 ROS_ERROR(
"Failed to initialize transmission");
119 const std::string &name)
121 for (
unsigned int i = 0; i < v.size(); ++i)
123 if (v[i]->name_ == name)
158 unsigned int js_size = 0;
162 for (
unsigned int j = 0; j < t->actuator_names_.size(); ++j)
168 js_size += t->joint_names_.size();
173 unsigned int js_id = 0;
177 for (
unsigned int j = 0; j < t->joint_names_.size(); ++j)
188 ROS_WARN(
"No transmissions were specified in the robot description.");
190 ROS_WARN(
"None of the joints in the robot desription matches up to a motor. The robot is uncontrollable.");
205 std::map<std::string, JointState*>::const_iterator it =
joint_states_map_.find(name);
boost::shared_ptr< pr2_mechanism_model::Transmission > getTransmission(const std::string &name) const
get a transmission pointer based on the transmission name. Returns NULL on failure ...
void enforceSafety()
Modify the commanded_effort_ of each joint state so that the joint limits are satisfied.
Robot(pr2_hardware_interface::HardwareInterface *hw)
Constructor.
URDF_EXPORT bool initXml(TiXmlElement *xml)
void propagateActuatorPositionToJointPosition()
Propagete the actuator positions, through the transmissions, to the joint positions.
std::vector< boost::shared_ptr< Transmission > > transmissions_
The list of transmissions.
pr2_hardware_interface::HardwareInterface * hw_
a pointer to the pr2 hardware interface. Only for advanced users
RobotState(Robot *model)
constructor
Actuator * getActuator(const std::string &name) const
bool initXml(TiXmlElement *root)
Initialize the robot model form xml.
int getTransmissionIndex(const std::string &name) const
get the transmission index based on the transmission name. Returns -1 on failure
bool isHalted()
Checks if one (or more) of the motors are halted.
void propagateJointPositionToActuatorPosition()
Propagete the joint positions, through the transmissions, to the actuator positions.
ros::Time getTime()
Get the time when the current controller cycle was started.
Robot * model_
The robot model containing the transmissions, urdf robot model, and hardware interface.
JointState * getJointState(const std::string &name)
Get a joint state by name.
std::vector< std::vector< pr2_mechanism_model::JointState * > > transmissions_out_
void propagateActuatorEffortToJointEffort()
Propagete the actuator efforts, through the transmissions, to the joint efforts.
void zeroCommands()
Set the commanded_effort_ of each joint state to zero.
std::vector< JointState > joint_states_
The vector of joint states, in no particular order.
std::map< std::string, JointState * > joint_states_map_
boost::shared_ptr< pluginlib::ClassLoader< pr2_mechanism_model::Transmission > > transmission_loader_
pr2_hardware_interface::Actuator * getActuator(const std::string &name) const
get an actuator pointer based on the actuator name. Returns NULL on failure
std::vector< std::vector< pr2_hardware_interface::Actuator * > > transmissions_in_
This class provides the controllers with an interface to the robot model.
urdf::Model robot_model_
The kinematic/dynamic model of the robot.
int findIndexByName(const std::vector< boost::shared_ptr< T > > &v, const std::string &name)
void propagateJointEffortToActuatorEffort()
Propagete the joint efforts, through the transmissions, to the actuator efforts.