YouBotBaseTestWithoutThread.cpp
Go to the documentation of this file.
2 
3 using namespace youbot;
4 
6 
7 
8 }
9 
11 }
12 
14 
16  ethercatMaster = &EthercatMaster::getInstance("youbot-ethercat.cfg", CONFIG_FOLDER_PATH, false);
17  if(ethercatMaster->isThreadActive()){
18  LOG(error) << "Thread Active";
20  ethercatMaster = &EthercatMaster::getInstance("youbot-ethercat.cfg", CONFIG_FOLDER_PATH, false);
21  }
22 
23  jointNO = 4;
24  stepStartTime = 1000;
25  durationNull = 1000;
26  overallTime = 0;
27  startTime = 0;
28  updateCycle = 2000;
29  setAngle.angle = 0 * radian;
30  setVel.angularVelocity = 0 * radian_per_second;
31  currentSetpoint.current = 0 * ampere;
32 }
33 
35 
37 }
38 
40  LOG(info) <<__func__<< "\n";
41  YouBotBase myBase("youbot-base", CONFIG_FOLDER_PATH);
42  myBase.doJointCommutation();
43  DataTrace myTrace(myBase.getBaseJoint(jointNO), __func__, true);
44  myBase.getBaseJoint(jointNO).setEncoderToZero();
45  if (!ethercatMaster->isThreadActive()) {
46  ethercatMaster->sendProcessData();
47  ethercatMaster->receiveProcessData();
48  }
49  myTrace.startTrace();
50 
51  ClearMotorControllerTimeoutFlag clearTimeoutFlag;
52  myBase.getBaseJoint(1).setConfigurationParameter(clearTimeoutFlag);
53  myBase.getBaseJoint(2).setConfigurationParameter(clearTimeoutFlag);
54  myBase.getBaseJoint(3).setConfigurationParameter(clearTimeoutFlag);
55  myBase.getBaseJoint(4).setConfigurationParameter(clearTimeoutFlag);
56 
57  startTime = myTrace.getTimeDurationMilliSec();
58  overallTime = startTime + durationNull + stepStartTime + durationNull;
59 
60  while (myTrace.getTimeDurationMilliSec() < overallTime) {
61  if (myTrace.getTimeDurationMilliSec() > startTime + durationNull) {
62  setAngle.angle = 0 * radian;
63  }
64  if (myTrace.getTimeDurationMilliSec() > startTime + durationNull
65  && myTrace.getTimeDurationMilliSec() < startTime + durationNull + stepStartTime) {
66  setAngle.angle = 2 * radian;
67  }
68  if (myTrace.getTimeDurationMilliSec() > startTime + durationNull + stepStartTime) {
69  setAngle.angle = 0 * radian;
70  }
71 
72  myBase.getBaseJoint(jointNO).setData(setAngle);
73  if (!ethercatMaster->isThreadActive()) {
74  ethercatMaster->sendProcessData();
75  ethercatMaster->receiveProcessData();
76  }
77  myTrace.updateTrace(setAngle);
78 
79  SLEEP_MICROSEC(updateCycle);
80  }
81  myTrace.stopTrace();
82  myTrace.plotTrace();
83 }
84 
86  LOG(info) <<__func__<< "\n";
87  YouBotBase myBase("youbot-base", CONFIG_FOLDER_PATH);
88  myBase.doJointCommutation();
89  DataTrace myTrace(myBase.getBaseJoint(jointNO), __func__, true);
90  myBase.getBaseJoint(jointNO).setEncoderToZero();
91  if (!ethercatMaster->isThreadActive()) {
92  ethercatMaster->sendProcessData();
93  ethercatMaster->receiveProcessData();
94  }
95  myTrace.startTrace();
96 
97  ClearMotorControllerTimeoutFlag clearTimeoutFlag;
98  myBase.getBaseJoint(1).setConfigurationParameter(clearTimeoutFlag);
99  myBase.getBaseJoint(2).setConfigurationParameter(clearTimeoutFlag);
100  myBase.getBaseJoint(3).setConfigurationParameter(clearTimeoutFlag);
101  myBase.getBaseJoint(4).setConfigurationParameter(clearTimeoutFlag);
102 
103  startTime = myTrace.getTimeDurationMilliSec();
104  overallTime = startTime + durationNull + stepStartTime + durationNull;
105 
106  while (myTrace.getTimeDurationMilliSec() < overallTime) {
107  if (myTrace.getTimeDurationMilliSec() > startTime + durationNull) {
108  setVel.angularVelocity = 0 * radian_per_second;
109  }
110  if (myTrace.getTimeDurationMilliSec() > startTime + durationNull
111  && myTrace.getTimeDurationMilliSec() < startTime + durationNull + stepStartTime) {
112  setVel.angularVelocity = 2 * radian_per_second;
113  }
114  if (myTrace.getTimeDurationMilliSec() > startTime + durationNull + stepStartTime) {
115  setVel.angularVelocity = 0 * radian_per_second;
116  }
117 
118  myBase.getBaseJoint(jointNO).setData(setVel);
119  if (!ethercatMaster->isThreadActive()) {
120  ethercatMaster->sendProcessData();
121  ethercatMaster->receiveProcessData();
122  }
123  myTrace.updateTrace(setVel);
124 
125  SLEEP_MICROSEC(updateCycle);
126  }
127  myTrace.stopTrace();
128  myTrace.plotTrace();
129 }
130 
132  LOG(info) <<__func__<< "\n";
133  YouBotBase myBase("youbot-base", CONFIG_FOLDER_PATH);
134  myBase.doJointCommutation();
135  DataTrace myTrace(myBase.getBaseJoint(jointNO), __func__, true);
136  myBase.getBaseJoint(jointNO).setEncoderToZero();
137  if (!ethercatMaster->isThreadActive()) {
138  ethercatMaster->sendProcessData();
139  ethercatMaster->receiveProcessData();
140  }
141  myTrace.startTrace();
142 
143  ClearMotorControllerTimeoutFlag clearTimeoutFlag;
144  myBase.getBaseJoint(1).setConfigurationParameter(clearTimeoutFlag);
145  myBase.getBaseJoint(2).setConfigurationParameter(clearTimeoutFlag);
146  myBase.getBaseJoint(3).setConfigurationParameter(clearTimeoutFlag);
147  myBase.getBaseJoint(4).setConfigurationParameter(clearTimeoutFlag);
148 
149  startTime = myTrace.getTimeDurationMilliSec();
150  overallTime = startTime + durationNull + stepStartTime + durationNull;
151 
152  while (myTrace.getTimeDurationMilliSec() < overallTime) {
153  if (myTrace.getTimeDurationMilliSec() > startTime + durationNull) {
154  currentSetpoint.current = 0 * ampere;
155  }
156  if (myTrace.getTimeDurationMilliSec() > startTime + durationNull
157  && myTrace.getTimeDurationMilliSec() < startTime + durationNull + stepStartTime) {
158  currentSetpoint.current = 0.5 * ampere;
159  }
160  if (myTrace.getTimeDurationMilliSec() > startTime + durationNull + stepStartTime) {
161  currentSetpoint.current = 0 * ampere;
162  }
163 
164  myBase.getBaseJoint(jointNO).setData(currentSetpoint);
165  if (!ethercatMaster->isThreadActive()) {
166  ethercatMaster->sendProcessData();
167  ethercatMaster->receiveProcessData();
168  }
169  myTrace.updateTrace(currentSetpoint);
170 
171  SLEEP_MICROSEC(updateCycle);
172  }
173  myTrace.stopTrace();
174  myTrace.plotTrace();
175 }
virtual void setData(const JointDataSetpoint &data)
virtual void setConfigurationParameter(const JointParameter &parameter)
Definition: YouBotJoint.cpp:77
static severity_level logginLevel
Definition: Logger.hpp:90
Clear the flag that indicates a communication timeout between the EtherCAT master and the controller...
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
static void destroy()
destroy the singleton instance by calling the destructor
Creates a trace of all process data and reads all configuration parameter from one joint...
Definition: DataTrace.hpp:82
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