YouBotGripperTest.cpp
Go to the documentation of this file.
00001 #include <youbot_driver/testing/YouBotGripperTest.hpp>
00002 #include <stdio.h>
00003 #include <stdlib.h>
00004 #include <stdexcept>
00005 
00006 using namespace youbot;
00007 
00008 YouBotGripperTest::YouBotGripperTest() :
00009     dof(5)
00010 {
00011   char* location = getenv("YOUBOT_CONFIG_FOLDER_LOCATION");
00012   if (location == NULL)
00013     throw std::runtime_error(
00014         "YouBotGripperTest.cpp: Could not find environment variable YOUBOT_CONFIG_FOLDER_LOCATION");
00015   EthercatMaster::getInstance("youbot-ethercat.cfg", location, true);
00016 
00017 }
00018 
00019 YouBotGripperTest::~YouBotGripperTest()
00020 {
00021 
00022 }
00023 
00024 void YouBotGripperTest::setUp()
00025 {
00026   Logger::logginLevel = trace;
00027   updateCycle = 2000;
00028 
00029 }
00030 
00031 void YouBotGripperTest::tearDown()
00032 {
00033   //    EthercatMaster::destroy();
00034 }
00035 
00036 void YouBotGripperTest::youBotGripperTest()
00037 {
00038   char* configLocation = getenv("YOUBOT_CONFIG_FOLDER_LOCATION");
00039   if (configLocation == NULL)
00040     throw std::runtime_error("YouBotArmTest.cpp: Could not find environment variable YOUBOT_CONFIG_FOLDER_LOCATION");
00041 
00042   LOG(info) << __func__ << "\n";
00043   YouBotManipulator myArm("youbot-manipulator", configLocation);
00044 
00045   GripperDataTrace myTrace(myArm.getArmGripper().getGripperBar2(), __func__, true);
00046 
00047   TargetPositionReached bar1TargetReched;
00048   TargetPositionReached bar2TargetReched;
00049   bool targetReachedBar1 = false;
00050   bool targetReachedBar2 = false;
00051 
00052   myArm.calibrateGripper(true);
00053   myTrace.startTrace("Load", "");
00054 
00055   //open gripper
00056   myArm.getArmGripper().open();
00057 
00058   for (int i = 0; i < 40; i++)
00059   {
00060     myArm.getArmGripper().getGripperBar1().getConfigurationParameter(bar1TargetReched);
00061     bar1TargetReched.getParameter(targetReachedBar1);
00062     myArm.getArmGripper().getGripperBar2().getConfigurationParameter(bar2TargetReched);
00063     bar2TargetReched.getParameter(targetReachedBar2);
00064     myTrace.updateTrace((double)targetReachedBar1);
00065     if (targetReachedBar1 && targetReachedBar2)
00066     {
00067       break;
00068     }
00069   }
00070   targetReachedBar1 = false;
00071   targetReachedBar2 = false;
00072 
00073   //close gripper
00074   myArm.getArmGripper().close();
00075 
00076   for (int i = 0; i < 40; i++)
00077   {
00078     myArm.getArmGripper().getGripperBar1().getConfigurationParameter(bar1TargetReched);
00079     bar1TargetReched.getParameter(targetReachedBar1);
00080     myArm.getArmGripper().getGripperBar2().getConfigurationParameter(bar2TargetReched);
00081     bar2TargetReched.getParameter(targetReachedBar2);
00082     myTrace.updateTrace((double)targetReachedBar2);
00083     if (targetReachedBar1 && targetReachedBar2)
00084     {
00085       break;
00086     }
00087   }
00088 
00089   myTrace.stopTrace();
00090   myTrace.plotTrace();
00091 
00092 }


youbot_driver
Author(s): Jan Paulus
autogenerated on Mon Oct 6 2014 09:08:02