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
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051 #include <youbot_driver/youbot/YouBotBase.hpp>
00052 namespace youbot
00053 {
00054
00055 YouBotBase::YouBotBase(const std::string name, const std::string configFilePath) :
00056 ethercatMaster(EthercatMaster::getInstance("youbot-ethercat.cfg", configFilePath))
00057 {
00058
00059
00060 this->controllerType = 174;
00061 this->alternativeControllerType = 1632;
00062 this->supportedFirmwareVersions.push_back("148");
00063 this->supportedFirmwareVersions.push_back("200");
00064 this->actualFirmwareVersionAllJoints = "";
00065
00066 string filename;
00067 filename = name;
00068 filename.append(".cfg");
00069
00070 configfile.reset(new ConfigFile(filename, configFilePath));
00071
00072 if (ethercatMaster.isThreadActive())
00073 {
00074 ethercatMasterWithThread = static_cast<EthercatMasterWithThread*>(&(EthercatMaster::getInstance(filename,
00075 configFilePath,
00076 true)));
00077 }
00078 else
00079 {
00080 ethercatMasterWithThread = NULL;
00081 }
00082
00083 this->initializeJoints();
00084
00085 this->initializeKinematic();
00086
00087
00088 }
00089
00090 YouBotBase::~YouBotBase()
00091 {
00092
00093 if (ethercatMaster.isThreadActive())
00094 {
00095 for (unsigned int i = 0; i < BASEJOINTS; i++)
00096 {
00097 ethercatMasterWithThread->deleteJointTrajectoryControllerRegistration(this->joints[i].getJointNumber());
00098 }
00099 }
00100
00101 }
00102
00104 void YouBotBase::doJointCommutation()
00105 {
00106
00107
00108 if (this->actualFirmwareVersionAllJoints == "148")
00109 {
00110 this->commutationFirmware148();
00111 }
00112 else if (this->actualFirmwareVersionAllJoints == "200")
00113 {
00114 this->commutationFirmware200();
00115 }
00116 else
00117 {
00118 throw std::runtime_error("Unable to commutate joints - Unsupported firmware version!");
00119 }
00120
00121 }
00122
00125 YouBotJoint& YouBotBase::getBaseJoint(const unsigned int baseJointNumber)
00126 {
00127
00128 if (baseJointNumber <= 0 || baseJointNumber > BASEJOINTS)
00129 {
00130 throw std::out_of_range("Invalid Joint Number");
00131 }
00132 return joints[baseJointNumber - 1];
00133
00134 }
00135
00140 void YouBotBase::getBasePosition(quantity<si::length>& longitudinalPosition, quantity<si::length>& transversalPosition,
00141 quantity<plane_angle>& orientation)
00142 {
00143
00144
00145 std::vector<quantity<plane_angle> > wheelPositions;
00146 quantity<plane_angle> dummy;
00147 JointSensedAngle sensedPos;
00148 wheelPositions.assign(BASEJOINTS, dummy);
00149
00150 ethercatMaster.AutomaticReceiveOn(false);
00151 joints[0].getData(sensedPos);
00152 wheelPositions[0] = sensedPos.angle;
00153 joints[1].getData(sensedPos);
00154 wheelPositions[1] = sensedPos.angle;
00155 joints[2].getData(sensedPos);
00156 wheelPositions[2] = sensedPos.angle;
00157 joints[3].getData(sensedPos);
00158 wheelPositions[3] = sensedPos.angle;
00159 ethercatMaster.AutomaticReceiveOn(true);
00160
00161 youBotBaseKinematic.wheelPositionsToCartesianPosition(wheelPositions, longitudinalPosition, transversalPosition,
00162 orientation);
00163
00164 }
00165
00170 void YouBotBase::setBasePosition(const quantity<si::length>& longitudinalPosition,
00171 const quantity<si::length>& transversalPosition,
00172 const quantity<plane_angle>& orientation)
00173 {
00174
00175
00176 std::vector<quantity<plane_angle> > wheelPositions;
00177 quantity<plane_angle> dummy;
00178 JointAngleSetpoint setpointPos;
00179 wheelPositions.assign(BASEJOINTS, dummy);
00180 JointSensedAngle sensedPos;
00181
00182 youBotBaseKinematic.cartesianPositionToWheelPositions(longitudinalPosition, transversalPosition, orientation,
00183 wheelPositions);
00184
00185 if (wheelPositions.size() < BASEJOINTS)
00186 throw std::out_of_range("To less wheel velocities");
00187
00188 joints[0].setEncoderToZero();
00189 joints[1].setEncoderToZero();
00190 joints[2].setEncoderToZero();
00191 joints[3].setEncoderToZero();
00192 SLEEP_MILLISEC(10);
00193
00194 ethercatMaster.AutomaticSendOn(false);
00195 joints[0].getData(sensedPos);
00196 setpointPos.angle = sensedPos.angle + wheelPositions[0];
00197 joints[0].setData(setpointPos);
00198
00199 joints[1].getData(sensedPos);
00200 setpointPos.angle = sensedPos.angle + wheelPositions[1];
00201 joints[1].setData(setpointPos);
00202
00203 joints[2].getData(sensedPos);
00204 setpointPos.angle = sensedPos.angle + wheelPositions[2];
00205 joints[2].setData(setpointPos);
00206
00207 joints[3].getData(sensedPos);
00208 setpointPos.angle = sensedPos.angle + wheelPositions[3];
00209 joints[3].setData(setpointPos);
00210 ethercatMaster.AutomaticSendOn(true);
00211
00212
00213 }
00214
00219 void YouBotBase::getBaseVelocity(quantity<si::velocity>& longitudinalVelocity,
00220 quantity<si::velocity>& transversalVelocity,
00221 quantity<si::angular_velocity>& angularVelocity)
00222 {
00223
00224
00225 std::vector<quantity<angular_velocity> > wheelVelocities;
00226 quantity<angular_velocity> dummy;
00227 JointSensedVelocity sensedVel;
00228 wheelVelocities.assign(BASEJOINTS, dummy);
00229
00230 ethercatMaster.AutomaticReceiveOn(false);
00231 joints[0].getData(sensedVel);
00232 wheelVelocities[0] = sensedVel.angularVelocity;
00233 joints[1].getData(sensedVel);
00234 wheelVelocities[1] = sensedVel.angularVelocity;
00235 joints[2].getData(sensedVel);
00236 wheelVelocities[2] = sensedVel.angularVelocity;
00237 joints[3].getData(sensedVel);
00238 wheelVelocities[3] = sensedVel.angularVelocity;
00239 ethercatMaster.AutomaticReceiveOn(true);
00240
00241 youBotBaseKinematic.wheelVelocitiesToCartesianVelocity(wheelVelocities, longitudinalVelocity, transversalVelocity,
00242 angularVelocity);
00243
00244
00245 }
00246
00251 void YouBotBase::setBaseVelocity(const quantity<si::velocity>& longitudinalVelocity,
00252 const quantity<si::velocity>& transversalVelocity,
00253 const quantity<si::angular_velocity>& angularVelocity)
00254 {
00255
00256
00257 std::vector<quantity<angular_velocity> > wheelVelocities;
00258 JointVelocitySetpoint setVel;
00259
00260 youBotBaseKinematic.cartesianVelocityToWheelVelocities(longitudinalVelocity, transversalVelocity, angularVelocity,
00261 wheelVelocities);
00262
00263 if (wheelVelocities.size() < BASEJOINTS)
00264 throw std::out_of_range("To less wheel velocities");
00265
00266 ethercatMaster.AutomaticSendOn(false);
00267 setVel.angularVelocity = wheelVelocities[0];
00268 joints[0].setData(setVel);
00269 setVel.angularVelocity = wheelVelocities[1];
00270 joints[1].setData(setVel);
00271 setVel.angularVelocity = wheelVelocities[2];
00272 joints[2].setData(setVel);
00273 setVel.angularVelocity = wheelVelocities[3];
00274 joints[3].setData(setVel);
00275 ethercatMaster.AutomaticSendOn(true);
00276
00277 }
00278
00282 void YouBotBase::setJointData(const std::vector<JointAngleSetpoint>& JointData)
00283 {
00284
00285 if (JointData.size() != BASEJOINTS)
00286 throw std::out_of_range("Wrong number of JointAngleSetpoints");
00287
00288 ethercatMaster.AutomaticSendOn(false);
00289 joints[0].setData(JointData[0]);
00290 joints[1].setData(JointData[1]);
00291 joints[2].setData(JointData[2]);
00292 joints[3].setData(JointData[3]);
00293 ethercatMaster.AutomaticSendOn(true);
00294
00295
00296 }
00297
00301 void YouBotBase::getJointData(std::vector<JointSensedAngle>& data)
00302 {
00303
00304 data.resize(BASEJOINTS);
00305 ethercatMaster.AutomaticReceiveOn(false);
00306 joints[0].getData(data[0]);
00307 joints[1].getData(data[1]);
00308 joints[2].getData(data[2]);
00309 joints[3].getData(data[3]);
00310 ethercatMaster.AutomaticReceiveOn(true);
00311
00312 }
00313
00317 void YouBotBase::setJointData(const std::vector<JointVelocitySetpoint>& JointData)
00318 {
00319
00320 if (JointData.size() != BASEJOINTS)
00321 throw std::out_of_range("Wrong number of JointVelocitySetpoints");
00322
00323 ethercatMaster.AutomaticSendOn(false);
00324 joints[0].setData(JointData[0]);
00325 joints[1].setData(JointData[1]);
00326 joints[2].setData(JointData[2]);
00327 joints[3].setData(JointData[3]);
00328 ethercatMaster.AutomaticSendOn(true);
00329
00330 }
00331
00335 void YouBotBase::getJointData(std::vector<JointSensedVelocity>& data)
00336 {
00337
00338 data.resize(BASEJOINTS);
00339 ethercatMaster.AutomaticReceiveOn(false);
00340 joints[0].getData(data[0]);
00341 joints[1].getData(data[1]);
00342 joints[2].getData(data[2]);
00343 joints[3].getData(data[3]);
00344 ethercatMaster.AutomaticReceiveOn(true);
00345
00346 }
00347
00351 void YouBotBase::setJointData(const std::vector<JointCurrentSetpoint>& JointData)
00352 {
00353
00354 if (JointData.size() != BASEJOINTS)
00355 throw std::out_of_range("Wrong number of JointCurrentSetpoint");
00356
00357 ethercatMaster.AutomaticSendOn(false);
00358 joints[0].setData(JointData[0]);
00359 joints[1].setData(JointData[1]);
00360 joints[2].setData(JointData[2]);
00361 joints[3].setData(JointData[3]);
00362 ethercatMaster.AutomaticSendOn(true);
00363
00364 }
00365
00369 void YouBotBase::getJointData(std::vector<JointSensedCurrent>& data)
00370 {
00371
00372 data.resize(BASEJOINTS);
00373 ethercatMaster.AutomaticReceiveOn(false);
00374 joints[0].getData(data[0]);
00375 joints[1].getData(data[1]);
00376 joints[2].getData(data[2]);
00377 joints[3].getData(data[3]);
00378 ethercatMaster.AutomaticReceiveOn(true);
00379
00380 }
00381
00385 void YouBotBase::setJointData(const std::vector<JointTorqueSetpoint>& JointData)
00386 {
00387
00388 if (JointData.size() != BASEJOINTS)
00389 throw std::out_of_range("Wrong number of JointTorqueSetpoint");
00390
00391 ethercatMaster.AutomaticSendOn(false);
00392 joints[0].setData(JointData[0]);
00393 joints[1].setData(JointData[1]);
00394 joints[2].setData(JointData[2]);
00395 joints[3].setData(JointData[3]);
00396 ethercatMaster.AutomaticSendOn(true);
00397
00398 }
00399
00403 void YouBotBase::getJointData(std::vector<JointSensedTorque>& data)
00404 {
00405
00406 data.resize(BASEJOINTS);
00407 ethercatMaster.AutomaticReceiveOn(false);
00408 joints[0].getData(data[0]);
00409 joints[1].getData(data[1]);
00410 joints[2].getData(data[2]);
00411 joints[3].getData(data[3]);
00412 ethercatMaster.AutomaticReceiveOn(true);
00413
00414 }
00415
00417 void YouBotBase::commutationFirmware200()
00418 {
00419
00420
00421 InitializeJoint doInitialization;
00422 bool isInitialized = false;
00423 int noInitialization = 0;
00424 std::string jointName;
00425 unsigned int statusFlags;
00426 std::vector<bool> isCommutated;
00427 isCommutated.assign(BASEJOINTS, false);
00428 unsigned int u = 0;
00429 JointCurrentSetpoint zerocurrent;
00430 zerocurrent.current = 0.0 * ampere;
00431
00432 ClearMotorControllerTimeoutFlag clearTimeoutFlag;
00433 for (unsigned int i = 1; i <= BASEJOINTS; i++)
00434 {
00435 this->getBaseJoint(i).setConfigurationParameter(clearTimeoutFlag);
00436 }
00437
00438 for (unsigned int i = 1; i <= BASEJOINTS; i++)
00439 {
00440 doInitialization.setParameter(false);
00441 this->getBaseJoint(i).getConfigurationParameter(doInitialization);
00442 doInitialization.getParameter(isInitialized);
00443 if (!isInitialized)
00444 {
00445 noInitialization++;
00446 }
00447 }
00448
00449 if (noInitialization != 0)
00450 {
00451 LOG(info) << "Base Joint Commutation with firmware 2.0";
00452 doInitialization.setParameter(true);
00453
00454 JointRoundsPerMinuteSetpoint rpmSetpoint(100);
00455
00456 ethercatMaster.AutomaticReceiveOn(false);
00457 this->getBaseJoint(1).setData(rpmSetpoint);
00458 this->getBaseJoint(2).setData(rpmSetpoint);
00459 this->getBaseJoint(3).setData(rpmSetpoint);
00460 this->getBaseJoint(4).setData(rpmSetpoint);
00461 ethercatMaster.AutomaticReceiveOn(true);
00462 rpmSetpoint.rpm = 0;
00463
00464
00465 for (u = 1; u <= 5000; u++)
00466 {
00467 for (unsigned int i = 1; i <= BASEJOINTS; i++)
00468 {
00469 this->getBaseJoint(i).getStatus(statusFlags);
00470 if (statusFlags & INITIALIZED)
00471 {
00472 isCommutated[i - 1] = true;
00473 this->getBaseJoint(i).setData(rpmSetpoint);
00474 }
00475 }
00476 if (!ethercatMaster.isThreadActive())
00477 {
00478 ethercatMaster.sendProcessData();
00479 ethercatMaster.receiveProcessData();
00480 }
00481 if (isCommutated[0] && isCommutated[1] && isCommutated[2] && isCommutated[3])
00482 {
00483 break;
00484 }
00485 SLEEP_MILLISEC(1);
00486 }
00487
00488 for (unsigned int i = 1; i <= BASEJOINTS; i++)
00489 {
00490 this->getBaseJoint(i).setData(rpmSetpoint);
00491 if (!ethercatMaster.isThreadActive())
00492 {
00493 ethercatMaster.sendProcessData();
00494 ethercatMaster.receiveProcessData();
00495 }
00496 doInitialization.setParameter(false);
00497 this->getBaseJoint(i).getConfigurationParameter(doInitialization);
00498 doInitialization.getParameter(isInitialized);
00499 if (!isInitialized)
00500 {
00501 std::stringstream jointNameStream;
00502 jointNameStream << "base joint " << i;
00503 jointName = jointNameStream.str();
00504 throw std::runtime_error("Could not commutate " + jointName);
00505 }
00506 }
00507 }
00508
00509 }
00510
00512 void YouBotBase::commutationFirmware148()
00513 {
00514
00515
00516 InitializeJoint doInitialization;
00517 bool isInitialized = false;
00518 int noInitialization = 0;
00519 std::string jointName;
00520
00521 ClearMotorControllerTimeoutFlag clearTimeoutFlag;
00522 for (unsigned int i = 1; i <= BASEJOINTS; i++)
00523 {
00524 this->getBaseJoint(i).setConfigurationParameter(clearTimeoutFlag);
00525 }
00526
00527 for (unsigned int i = 1; i <= BASEJOINTS; i++)
00528 {
00529 doInitialization.setParameter(false);
00530 this->getBaseJoint(i).getConfigurationParameter(doInitialization);
00531 doInitialization.getParameter(isInitialized);
00532 if (!isInitialized)
00533 {
00534 noInitialization++;
00535 }
00536 }
00537
00538 if (noInitialization != 0)
00539 {
00540 LOG(info) << "Base Joint Commutation with firmware 1.48";
00541 doInitialization.setParameter(true);
00542
00543 ethercatMaster.AutomaticReceiveOn(false);
00544 this->getBaseJoint(1).setConfigurationParameter(doInitialization);
00545 this->getBaseJoint(2).setConfigurationParameter(doInitialization);
00546 this->getBaseJoint(3).setConfigurationParameter(doInitialization);
00547 this->getBaseJoint(4).setConfigurationParameter(doInitialization);
00548 ethercatMaster.AutomaticReceiveOn(true);
00549
00550 unsigned int statusFlags;
00551 std::vector<bool> isCommutated;
00552 isCommutated.assign(BASEJOINTS, false);
00553 unsigned int u = 0;
00554
00555
00556 for (u = 1; u <= 5000; u++)
00557 {
00558 for (unsigned int i = 1; i <= BASEJOINTS; i++)
00559 {
00560 if (!ethercatMaster.isThreadActive())
00561 {
00562 ethercatMaster.sendProcessData();
00563 ethercatMaster.receiveProcessData();
00564 }
00565 this->getBaseJoint(i).getStatus(statusFlags);
00566 if (statusFlags & INITIALIZED)
00567 {
00568 isCommutated[i - 1] = true;
00569 }
00570 }
00571 if (isCommutated[0] && isCommutated[1] && isCommutated[2] && isCommutated[3])
00572 {
00573 break;
00574 }
00575 SLEEP_MILLISEC(1);
00576 }
00577
00578 SLEEP_MILLISEC(10);
00579
00580 for (unsigned int i = 1; i <= BASEJOINTS; i++)
00581 {
00582 doInitialization.setParameter(false);
00583 this->getBaseJoint(i).getConfigurationParameter(doInitialization);
00584 doInitialization.getParameter(isInitialized);
00585 if (!isInitialized)
00586 {
00587 std::stringstream jointNameStream;
00588 jointNameStream << "base joint " << i;
00589 jointName = jointNameStream.str();
00590 throw std::runtime_error("Could not commutate " + jointName);
00591 }
00592 }
00593 }
00594
00595
00596 }
00597
00598 void YouBotBase::initializeJoints()
00599 {
00600
00601
00602 LOG(trace) << "Initializing Joints";
00603
00604 char* configLocation = getenv("YOUBOT_CONFIG_FOLDER_LOCATION");
00605 if (configLocation == NULL)
00606 throw std::runtime_error("YouBotArmTest.cpp: Could not find environment variable YOUBOT_CONFIG_FOLDER_LOCATION");
00607
00608
00609 unsigned int noSlaves = ethercatMaster.getNumberOfSlaves();
00610
00611 if (noSlaves < BASEJOINTS)
00612 {
00613 throw std::out_of_range("Not enough ethercat slaves were found to create a YouBotBase!");
00614 }
00615
00616
00617
00618
00619
00620
00621 unsigned int slaveNumber = 0;
00622 configfile->readInto(slaveNumber, "JointTopology", "BaseLeftFront");
00623 if (slaveNumber <= noSlaves)
00624 {
00625 joints.push_back(new YouBotJoint(slaveNumber, configLocation));
00626 }
00627 else
00628 {
00629 throw std::out_of_range("The ethercat slave number is not available!");
00630 }
00631
00632 configfile->readInto(slaveNumber, "JointTopology", "BaseRightFront");
00633 if (slaveNumber <= noSlaves)
00634 {
00635 joints.push_back(new YouBotJoint(slaveNumber, configLocation));
00636 }
00637 else
00638 {
00639 throw std::out_of_range("The ethercat slave number is not available!");
00640 }
00641
00642 configfile->readInto(slaveNumber, "JointTopology", "BaseLeftBack");
00643 if (slaveNumber <= noSlaves)
00644 {
00645 joints.push_back(new YouBotJoint(slaveNumber, configLocation));
00646 }
00647 else
00648 {
00649 throw std::out_of_range("The ethercat slave number is not available!");
00650 }
00651
00652 configfile->readInto(slaveNumber, "JointTopology", "BaseRightBack");
00653 if (slaveNumber <= noSlaves)
00654 {
00655 joints.push_back(new YouBotJoint(slaveNumber, configLocation));
00656 }
00657 else
00658 {
00659 throw std::out_of_range("The ethercat slave number is not available!");
00660 }
00661
00662
00663 std::string jointName;
00664 JointName jName;
00665 GearRatio gearRatio;
00666 EncoderTicksPerRound ticksPerRound;
00667 InverseMovementDirection inverseDir;
00668 FirmwareVersion firmwareTypeVersion;
00669 TorqueConstant torqueConst;
00670
00671 double trajectory_p = 0, trajectory_i = 0, trajectory_d = 0, trajectory_imax = 0, trajectory_imin = 0;
00672 double gearRatio_numerator = 0;
00673 double gearRatio_denominator = 1;
00674 JointLimits jLimits;
00675
00676 for (unsigned int i = 0; i < BASEJOINTS; i++)
00677 {
00678 std::stringstream jointNameStream;
00679 jointNameStream << "Joint_" << i + 1;
00680 jointName = jointNameStream.str();
00681
00682
00683 joints[i].getConfigurationParameter(firmwareTypeVersion);
00684 std::string version;
00685 int controllerType;
00686 std::string firmwareVersion;
00687 firmwareTypeVersion.getParameter(controllerType, firmwareVersion);
00688
00689 string name;
00690 configfile->readInto(name, jointName, "JointName");
00691 jName.setParameter(name);
00692
00693 LOG(info) << name << "\t Controller Type: " << controllerType << " Firmware version: " << firmwareVersion;
00694
00695 if (this->controllerType != controllerType && alternativeControllerType != controllerType)
00696 {
00697 std::stringstream ss;
00698 ss << "The youBot base motor controller have to be of type: " << this->controllerType << " or "
00699 << alternativeControllerType;
00700 throw std::runtime_error(ss.str().c_str());
00701 }
00702
00703
00704 bool isfirmwareSupported = false;
00705 for (unsigned int d = 0; d < supportedFirmwareVersions.size(); d++)
00706 {
00707 if (this->supportedFirmwareVersions[d] == firmwareVersion)
00708 {
00709 isfirmwareSupported = true;
00710 break;
00711 }
00712 }
00713
00714 if (!isfirmwareSupported)
00715 {
00716 throw std::runtime_error("Unsupported firmware version: " + firmwareVersion);
00717 }
00718
00719 if (this->actualFirmwareVersionAllJoints == "")
00720 {
00721 this->actualFirmwareVersionAllJoints = firmwareVersion;
00722 }
00723
00724 if (!(firmwareVersion == this->actualFirmwareVersionAllJoints))
00725 {
00726 throw std::runtime_error("All joints must have the same firmware version!");
00727 }
00728
00729 configfile->readInto(gearRatio_numerator, jointName, "GearRatio_numerator");
00730 configfile->readInto(gearRatio_denominator, jointName, "GearRatio_denominator");
00731 gearRatio.setParameter(gearRatio_numerator / gearRatio_denominator);
00732 int ticks;
00733 configfile->readInto(ticks, jointName, "EncoderTicksPerRound");
00734 ticksPerRound.setParameter(ticks);
00735
00736 double torqueConstant;
00737 configfile->readInto(torqueConstant, jointName, "TorqueConstant_[newton_meter_divided_by_ampere]");
00738 torqueConst.setParameter(torqueConstant);
00739
00740 bool invdir = false;
00741 configfile->readInto(invdir, jointName, "InverseMovementDirection");
00742 inverseDir.setParameter(invdir);
00743
00744 joints[i].setConfigurationParameter(jName);
00745 joints[i].setConfigurationParameter(gearRatio);
00746 joints[i].setConfigurationParameter(ticksPerRound);
00747 joints[i].setConfigurationParameter(torqueConst);
00748 joints[i].setConfigurationParameter(inverseDir);
00749
00750 long upperlimit = 0, lowerlimit = 0;
00751 configfile->readInto(lowerlimit, jointName, "LowerLimit_[encoderTicks]");
00752 configfile->readInto(upperlimit, jointName, "UpperLimit_[encoderTicks]");
00753
00754 jLimits.setParameter(lowerlimit, upperlimit, false);
00755 joints[i].setConfigurationParameter(jLimits);
00756
00757
00758 if (ethercatMaster.isThreadActive())
00759 {
00760 configfile->readInto(trajectory_p, jointName, "trajectory_controller_P");
00761 configfile->readInto(trajectory_i, jointName, "trajectory_controller_I");
00762 configfile->readInto(trajectory_d, jointName, "trajectory_controller_D");
00763 configfile->readInto(trajectory_imax, jointName, "trajectory_controller_I_max");
00764 configfile->readInto(trajectory_imin, jointName, "trajectory_controller_I_min");
00765 joints[i].trajectoryController.setConfigurationParameter(trajectory_p, trajectory_i, trajectory_d,
00766 trajectory_imax, trajectory_imin);
00767 joints[i].trajectoryController.setEncoderTicksPerRound(ticks);
00768 joints[i].trajectoryController.setGearRatio(gearRatio_numerator / gearRatio_denominator);
00769 joints[i].trajectoryController.setInverseMovementDirection(invdir);
00770 ethercatMasterWithThread->registerJointTrajectoryController(&(joints[i].trajectoryController),
00771 joints[i].getJointNumber());
00772 }
00773 }
00774
00775 return;
00776
00777 }
00778
00779 void YouBotBase::initializeKinematic()
00780 {
00781
00782 FourSwedishWheelOmniBaseKinematicConfiguration kinematicConfig;
00783
00784
00785 configfile->readInto(kinematicConfig.rotationRatio, "YouBotKinematic", "RotationRatio");
00786 configfile->readInto(kinematicConfig.slideRatio, "YouBotKinematic", "SlideRatio");
00787 double dummy = 0;
00788 configfile->readInto(dummy, "YouBotKinematic", "LengthBetweenFrontAndRearWheels_[meter]");
00789 kinematicConfig.lengthBetweenFrontAndRearWheels = dummy * meter;
00790 configfile->readInto(dummy, "YouBotKinematic", "LengthBetweenFrontWheels_[meter]");
00791 kinematicConfig.lengthBetweenFrontWheels = dummy * meter;
00792 configfile->readInto(dummy, "YouBotKinematic", "WheelRadius_[meter]");
00793 kinematicConfig.wheelRadius = dummy * meter;
00794
00795 youBotBaseKinematic.setConfiguration(kinematicConfig);
00796
00797 }
00798
00799 }