Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040 #include "sr_mechanism_model/simple_transmission.hpp"
00041
00042 using namespace ros_ethercat_model;
00043 using namespace std;
00044 using namespace sr_actuator;
00045
00046 PLUGINLIB_EXPORT_CLASS(sr_mechanism_model::SimpleTransmission, Transmission)
00047
00048 namespace sr_mechanism_model
00049 {
00050
00051 bool SimpleTransmission::initXml(TiXmlElement *elt, RobotState *robot)
00052 {
00053 if (!ros_ethercat_model::Transmission::initXml(elt, robot))
00054 return false;
00055
00056
00057 TiXmlElement *jel = elt->FirstChildElement("joint");
00058 if (!jel || !jel->Attribute("name"))
00059 {
00060 ROS_ERROR_STREAM("Joint name not specified in transmission " << name_);
00061 return false;
00062 }
00063
00064 TiXmlElement *ael = elt->FirstChildElement("actuator");
00065 if (!ael || !ael->Attribute("name"))
00066 {
00067 ROS_ERROR_STREAM("Transmission " << name_ << " has no actuator in configuration");
00068 return false;
00069 }
00070
00071 joint_ = robot->getJointState(jel->Attribute("name"));
00072 actuator_ = new SrMotorActuator();
00073 actuator_->name_ = ael->Attribute("name");
00074 actuator_->command_.enable_ = true;
00075
00076 return true;
00077 }
00078
00079 void SimpleTransmission::propagatePosition()
00080 {
00081 SrMotorActuator *act = static_cast<SrMotorActuator*>(actuator_);
00082 joint_->position_ = act->state_.position_;
00083 joint_->velocity_ = act->state_.velocity_;
00084 joint_->effort_ = act->state_.last_measured_effort_;
00085 }
00086
00087 void SimpleTransmission::propagateEffort()
00088 {
00089 SrMotorActuator *act = static_cast<SrMotorActuator*>(actuator_);
00090 act->command_.enable_ = true;
00091 act->command_.effort_ = joint_->commanded_effort_;
00092 }
00093
00094 }
00095
00096
00097
00098
00099
00100