YouBotBaseTest.cpp

Go to the documentation of this file.
00001 #include "YouBotBaseTest.hpp"
00002 
00003 using namespace youbot;
00004 
00005 YouBotBaseTest::YouBotBaseTest() {
00006 
00007   EthercatMaster::getInstance("youbot-ethercat.cfg", "../config/", true);
00008 
00009 
00010 }
00011 
00012 YouBotBaseTest::~YouBotBaseTest() {
00013 
00014 }
00015 
00016 void YouBotBaseTest::setUp() {
00017   Logger::logginLevel = trace;
00018   jointNO = 4;
00019   stepStartTime = 1000;
00020   durationNull = 1000;
00021   overallTime = 0;
00022   startTime = 0;
00023   updateCycle = 2000;
00024   setAngle.angle = 0 * radian;
00025   setVel.angularVelocity = 0 * radian_per_second;
00026   currentSetpoint.current = 0 * ampere;
00027 
00028 }
00029 
00030 void YouBotBaseTest::tearDown() {
00031 //  EthercatMaster::destroy();
00032 }
00033 
00034 void YouBotBaseTest::youBotBaseTest_PositionMode() {
00035 
00036   LOG(info) <<__func__<< "\n";
00037   YouBotBase myBase("youbot-base");
00038   myBase.doJointCommutation();
00039   DataTrace myTrace(myBase.getBaseJoint(jointNO), __func__, true);
00040   myBase.getBaseJoint(jointNO).setEncoderToZero();
00041   myTrace.startTrace();
00042   
00043   startTime = myTrace.getTimeDurationMilliSec();
00044   overallTime = startTime + durationNull + stepStartTime + durationNull;
00045 
00046   while (myTrace.getTimeDurationMilliSec() < overallTime) {
00047     if (myTrace.getTimeDurationMilliSec() > startTime + durationNull) {
00048       setAngle.angle = 0 * radian;
00049     }
00050     if (myTrace.getTimeDurationMilliSec() > startTime + durationNull
00051             && myTrace.getTimeDurationMilliSec() < startTime + durationNull + stepStartTime) {
00052       setAngle.angle = 1 * radian;
00053     }
00054     if (myTrace.getTimeDurationMilliSec() > startTime + durationNull + stepStartTime) {
00055       setAngle.angle = 0 * radian;
00056     }
00057 
00058     myBase.getBaseJoint(jointNO).setData(setAngle);
00059     myTrace.updateTrace(setAngle);
00060 
00061     SLEEP_MICROSEC(updateCycle);
00062   }
00063   myTrace.stopTrace();
00064   myTrace.plotTrace();
00065 }
00066 
00067 void YouBotBaseTest::youBotBaseTest_VelocityMode() {
00068   LOG(info) <<__func__<< "\n";
00069   YouBotBase myBase("youbot-base");
00070   myBase.doJointCommutation();
00071   DataTrace myTrace(myBase.getBaseJoint(jointNO), __func__, true);
00072   myBase.getBaseJoint(jointNO).setEncoderToZero();
00073   myTrace.startTrace();
00074   
00075   startTime = myTrace.getTimeDurationMilliSec();
00076   overallTime = startTime + durationNull + stepStartTime + durationNull;
00077 
00078   while (myTrace.getTimeDurationMilliSec() < overallTime) {
00079     if (myTrace.getTimeDurationMilliSec() > startTime + durationNull) {
00080       setVel.angularVelocity = 0 * radian_per_second;
00081     }
00082     if (myTrace.getTimeDurationMilliSec() > startTime + durationNull
00083             && myTrace.getTimeDurationMilliSec() < startTime + durationNull + stepStartTime) {
00084       setVel.angularVelocity = 1 * radian_per_second;
00085     }
00086     if (myTrace.getTimeDurationMilliSec() > startTime + durationNull + stepStartTime) {
00087       setVel.angularVelocity = 0 * radian_per_second;
00088     }
00089 
00090     myBase.getBaseJoint(jointNO).setData(setVel);
00091     myTrace.updateTrace(setVel);
00092 
00093     SLEEP_MICROSEC(updateCycle);
00094   }
00095   myTrace.stopTrace();
00096   myTrace.plotTrace();
00097 }
00098 
00099 void YouBotBaseTest::youBotBaseTest_CurrentMode() {
00100   LOG(info) <<__func__<< "\n";
00101   YouBotBase myBase("youbot-base");
00102   myBase.doJointCommutation();
00103   DataTrace myTrace(myBase.getBaseJoint(jointNO), __func__, true);
00104   myBase.getBaseJoint(jointNO).setEncoderToZero();
00105   myTrace.startTrace();
00106   
00107   startTime = myTrace.getTimeDurationMilliSec();
00108   overallTime = startTime + durationNull + stepStartTime + durationNull;
00109 
00110   while (myTrace.getTimeDurationMilliSec() < overallTime) {
00111     if (myTrace.getTimeDurationMilliSec() > startTime + durationNull) {
00112       currentSetpoint.current = 0 * ampere;
00113     }
00114     if (myTrace.getTimeDurationMilliSec() > startTime + durationNull
00115             && myTrace.getTimeDurationMilliSec() < startTime + durationNull + stepStartTime) {
00116       currentSetpoint.current = 0.3 * ampere;
00117     }
00118     if (myTrace.getTimeDurationMilliSec() > startTime + durationNull + stepStartTime) {
00119       currentSetpoint.current = 0 * ampere;
00120     }
00121 
00122     myBase.getBaseJoint(jointNO).setData(currentSetpoint);
00123     myTrace.updateTrace(currentSetpoint);
00124 
00125     SLEEP_MICROSEC(updateCycle);
00126   }
00127   myTrace.stopTrace();
00128   myTrace.plotTrace();
00129 }
Generated by  doxygen 1.6.3