YouBotBaseKinematicsTest.cpp
Go to the documentation of this file.
2 
3 using namespace youbot;
4 
6 
7  EthercatMaster::getInstance("youbot-ethercat.cfg", CONFIG_FOLDER_PATH, true);
8 
9 
10 }
11 
13 
14 }
15 
18  updateCycle = 2000;
19 
20 }
21 
23  // EthercatMaster::destroy();
24 }
25 
27 
28  LOG(info) << __func__ << "\n";
29  YouBotBase myBase("youbot-base", CONFIG_FOLDER_PATH);
30  myBase.doJointCommutation();
31  std::stringstream jointNameStream;
32  boost::ptr_vector<DataTrace> myTrace;
33  unsigned int step1 = 1000;
34  unsigned int step2 = 4000;
35  unsigned int step3 = 7000;
36  unsigned int step4 = 10000;
37  unsigned int step5 = 13000;
38  unsigned int step6 = 16000;
39 
40  // create variables to set and get the base cartesian velocity and pose
41  quantity<si::velocity> longitudinalVelocity = 0.0 * meter_per_second;
42  quantity<si::velocity> transversalVelocity = 0.0 * meter_per_second;
43  quantity<si::angular_velocity> angularVelocity = 0 * radian_per_second;
44 
45  for (int i = 1; i <= 4; i++) {
46  jointNameStream << "Joint_" << i << "_" << __func__;
47  myTrace.push_back(new DataTrace(myBase.getBaseJoint(i), jointNameStream.str(), true));
48  jointNameStream.str("");
49  myBase.getBaseJoint(i).setEncoderToZero();
50  }
51 
52  for (int i = 0; i < 4; i++) {
53  myTrace[i].startTrace();
54  }
55 
56  startTime = myTrace[0].getTimeDurationMilliSec();
57  overallTime = startTime + step6 +10;
58 
59  while (myTrace[0].getTimeDurationMilliSec() < overallTime) {
60  if (myTrace[0].getTimeDurationMilliSec() > startTime + step1) {
61  longitudinalVelocity = 0.0 * meter_per_second;
62  transversalVelocity = 0.0 * meter_per_second;
63  angularVelocity = 0 * radian_per_second;
64  }
65  if (myTrace[0].getTimeDurationMilliSec() > startTime + step1
66  && myTrace[0].getTimeDurationMilliSec() < startTime + step2) {
67  longitudinalVelocity = 0.2 * meter_per_second;
68  transversalVelocity = 0.0 * meter_per_second;
69  angularVelocity = 0 * radian_per_second;
70  }
71  if (myTrace[0].getTimeDurationMilliSec() > startTime + step2
72  && myTrace[0].getTimeDurationMilliSec() < startTime + step3) {
73  longitudinalVelocity = 0.0 * meter_per_second;
74  transversalVelocity = 0.2 * meter_per_second;
75  angularVelocity = 0.0 * radian_per_second;
76  }
77 
78  if (myTrace[0].getTimeDurationMilliSec() > startTime + step3
79  && myTrace[0].getTimeDurationMilliSec() < startTime + step4) {
80  longitudinalVelocity = 0.0 * meter_per_second;
81  transversalVelocity = 0.0 * meter_per_second;
82  angularVelocity = 0.2 * radian_per_second;
83  }
84 
85  if (myTrace[0].getTimeDurationMilliSec() > startTime + step4
86  && myTrace[0].getTimeDurationMilliSec() < startTime + step5) {
87  longitudinalVelocity = 0.1 * meter_per_second;
88  transversalVelocity = 0.1 * meter_per_second;
89  angularVelocity = 0.0 * radian_per_second;
90  }
91 
92  if (myTrace[0].getTimeDurationMilliSec() > startTime + step5
93  && myTrace[0].getTimeDurationMilliSec() < startTime + step6) {
94  longitudinalVelocity = 0.1 * meter_per_second;
95  transversalVelocity = 0.1 * meter_per_second;
96  angularVelocity = 0.0 * radian_per_second;
97  }
98 
99  if (myTrace[0].getTimeDurationMilliSec() > startTime + step6) {
100  longitudinalVelocity = 0 * meter_per_second;
101  transversalVelocity = 0 * meter_per_second;
102  angularVelocity = 0 * radian_per_second;
103  }
104 
105  myBase.setBaseVelocity(longitudinalVelocity, transversalVelocity, angularVelocity);
106  for (int i = 0; i < 4; i++) {
107  myTrace[i].updateTrace();
108  }
109 
110 
111  SLEEP_MICROSEC(updateCycle);
112  }
113  for (int i = 0; i < 4; i++) {
114  myTrace[i].stopTrace();
115  myTrace[i].plotTrace();
116  }
117 
118 }
static severity_level logginLevel
Definition: Logger.hpp:90
YouBotJoint & getBaseJoint(const unsigned int baseJointNumber)
Definition: YouBotBase.cpp:110
#define SLEEP_MICROSEC(microsec)
Definition: Time.hpp:61
#define LOG(level)
Definition: Logger.hpp:102
Creates a trace of all process data and reads all configuration parameter from one joint...
Definition: DataTrace.hpp:82
void setBaseVelocity(const quantity< si::velocity > &longitudinalVelocity, const quantity< si::velocity > &transversalVelocity, const quantity< si::angular_velocity > &angularVelocity)
Definition: YouBotBase.cpp:223
It groups the base joints together.
Definition: YouBotBase.hpp:76
void doJointCommutation()
does the sine commutation of the base joints
Definition: YouBotBase.cpp:95
static EthercatMasterInterface & getInstance(const std::string configFile="youbot-ethercat.cfg", const std::string configFilePath="../config/", const bool ethercatMasterWithThread=true)
void setEncoderToZero()
set the encoder values of the joint to zero. This postion will be the new reference.


youbot_driver
Author(s): Jan Paulus
autogenerated on Mon Jun 10 2019 15:46:25