YouBotBaseKinematicsTest.cpp
Go to the documentation of this file.00001 #include "YouBotBaseKinematicsTest.hpp"
00002
00003 using namespace youbot;
00004
00005 YouBotBaseKinematicsTest::YouBotBaseKinematicsTest() {
00006
00007 EthercatMaster::getInstance("youbot-ethercat.cfg", "../config/", true);
00008
00009
00010 }
00011
00012 YouBotBaseKinematicsTest::~YouBotBaseKinematicsTest() {
00013
00014 }
00015
00016 void YouBotBaseKinematicsTest::setUp() {
00017 Logger::logginLevel = trace;
00018 updateCycle = 2000;
00019
00020 }
00021
00022 void YouBotBaseKinematicsTest::tearDown() {
00023
00024 }
00025
00026 void YouBotBaseKinematicsTest::youBotBaseKinematicsTest() {
00027
00028 LOG(info) << __func__ << "\n";
00029 YouBotBase myBase("youbot-base");
00030 myBase.doJointCommutation();
00031 std::stringstream jointNameStream;
00032 boost::ptr_vector<DataTrace> myTrace;
00033 unsigned int step1 = 1000;
00034 unsigned int step2 = 4000;
00035 unsigned int step3 = 7000;
00036 unsigned int step4 = 10000;
00037 unsigned int step5 = 13000;
00038 unsigned int step6 = 16000;
00039
00040
00041 quantity<si::velocity> longitudinalVelocity = 0.0 * meter_per_second;
00042 quantity<si::velocity> transversalVelocity = 0.0 * meter_per_second;
00043 quantity<si::angular_velocity> angularVelocity = 0 * radian_per_second;
00044
00045 quantity<si::velocity> actualLongitudinalVelocity = 0 * meter_per_second;
00046 quantity<si::velocity> actualTransversalVelocity = 0 * meter_per_second;
00047 quantity<si::angular_velocity> actualAngularVelocity = 0 * radian_per_second;
00048
00049 quantity<si::length> actualLongitudinalPose = 0 * meter;
00050 quantity<si::length> actualTransversalPose = 0 * meter;
00051 quantity<si::plane_angle> actualAngle = 0 * radian;
00052
00053 for (int i = 1; i <= 4; i++) {
00054 jointNameStream << "Joint_" << i << "_" << __func__;
00055 myTrace.push_back(new DataTrace(myBase.getBaseJoint(i), jointNameStream.str(), true));
00056 jointNameStream.str("");
00057 myBase.getBaseJoint(i).setEncoderToZero();
00058 }
00059
00060 for (int i = 0; i < 4; i++) {
00061 myTrace[i].startTrace();
00062 }
00063
00064 startTime = myTrace[0].getTimeDurationMilliSec();
00065 overallTime = startTime + step6 +10;
00066
00067 while (myTrace[0].getTimeDurationMilliSec() < overallTime) {
00068 if (myTrace[0].getTimeDurationMilliSec() > startTime + step1) {
00069 longitudinalVelocity = 0.0 * meter_per_second;
00070 transversalVelocity = 0.0 * meter_per_second;
00071 angularVelocity = 0 * radian_per_second;
00072 }
00073 if (myTrace[0].getTimeDurationMilliSec() > startTime + step1
00074 && myTrace[0].getTimeDurationMilliSec() < startTime + step2) {
00075 longitudinalVelocity = 0.2 * meter_per_second;
00076 transversalVelocity = 0.0 * meter_per_second;
00077 angularVelocity = 0 * radian_per_second;
00078 }
00079 if (myTrace[0].getTimeDurationMilliSec() > startTime + step2
00080 && myTrace[0].getTimeDurationMilliSec() < startTime + step3) {
00081 longitudinalVelocity = 0.0 * meter_per_second;
00082 transversalVelocity = 0.2 * meter_per_second;
00083 angularVelocity = 0.0 * radian_per_second;
00084 }
00085
00086 if (myTrace[0].getTimeDurationMilliSec() > startTime + step3
00087 && myTrace[0].getTimeDurationMilliSec() < startTime + step4) {
00088 longitudinalVelocity = 0.0 * meter_per_second;
00089 transversalVelocity = 0.0 * meter_per_second;
00090 angularVelocity = 0.2 * radian_per_second;
00091 }
00092
00093 if (myTrace[0].getTimeDurationMilliSec() > startTime + step4
00094 && myTrace[0].getTimeDurationMilliSec() < startTime + step5) {
00095 longitudinalVelocity = 0.1 * meter_per_second;
00096 transversalVelocity = 0.1 * meter_per_second;
00097 angularVelocity = 0.0 * radian_per_second;
00098 }
00099
00100 if (myTrace[0].getTimeDurationMilliSec() > startTime + step5
00101 && myTrace[0].getTimeDurationMilliSec() < startTime + step6) {
00102 longitudinalVelocity = 0.1 * meter_per_second;
00103 transversalVelocity = 0.1 * meter_per_second;
00104 angularVelocity = 0.0 * radian_per_second;
00105 }
00106
00107 if (myTrace[0].getTimeDurationMilliSec() > startTime + step6) {
00108 longitudinalVelocity = 0 * meter_per_second;
00109 transversalVelocity = 0 * meter_per_second;
00110 angularVelocity = 0 * radian_per_second;
00111 }
00112
00113 myBase.setBaseVelocity(longitudinalVelocity, transversalVelocity, angularVelocity);
00114 for (int i = 0; i < 4; i++) {
00115 myTrace[i].updateTrace();
00116 }
00117
00118
00119 SLEEP_MICROSEC(updateCycle);
00120 }
00121 for (int i = 0; i < 4; i++) {
00122 myTrace[i].stopTrace();
00123 myTrace[i].plotTrace();
00124 }
00125
00126 }