YouBotBaseTest.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  jointNO = 4;
19  stepStartTime = 1000;
20  durationNull = 1000;
21  overallTime = 0;
22  startTime = 0;
23  updateCycle = 2000;
24  setAngle.angle = 0 * radian;
25  setVel.angularVelocity = 0 * radian_per_second;
26  currentSetpoint.current = 0 * ampere;
27 
28 }
29 
31 // EthercatMaster::destroy();
32 }
33 
35 
36  LOG(info) <<__func__<< "\n";
37  YouBotBase myBase("youbot-base", CONFIG_FOLDER_PATH);
38  myBase.doJointCommutation();
39  DataTrace myTrace(myBase.getBaseJoint(jointNO), __func__, true);
40  myBase.getBaseJoint(jointNO).setEncoderToZero();
41  myTrace.startTrace();
42 
43  startTime = myTrace.getTimeDurationMilliSec();
44  overallTime = startTime + durationNull + stepStartTime + durationNull;
45 
46  while (myTrace.getTimeDurationMilliSec() < overallTime) {
47  if (myTrace.getTimeDurationMilliSec() > startTime + durationNull) {
48  setAngle.angle = 0 * radian;
49  }
50  if (myTrace.getTimeDurationMilliSec() > startTime + durationNull
51  && myTrace.getTimeDurationMilliSec() < startTime + durationNull + stepStartTime) {
52  setAngle.angle = 1 * radian;
53  }
54  if (myTrace.getTimeDurationMilliSec() > startTime + durationNull + stepStartTime) {
55  setAngle.angle = 0 * radian;
56  }
57 
58  myBase.getBaseJoint(jointNO).setData(setAngle);
59  myTrace.updateTrace(setAngle);
60 
61  SLEEP_MICROSEC(updateCycle);
62  }
63  myTrace.stopTrace();
64  myTrace.plotTrace();
65 }
66 
68  LOG(info) <<__func__<< "\n";
69  YouBotBase myBase("youbot-base", CONFIG_FOLDER_PATH);
70  myBase.doJointCommutation();
71  DataTrace myTrace(myBase.getBaseJoint(jointNO), __func__, true);
72  myBase.getBaseJoint(jointNO).setEncoderToZero();
73  myTrace.startTrace();
74 
75  startTime = myTrace.getTimeDurationMilliSec();
76  overallTime = startTime + durationNull + stepStartTime + durationNull;
77 
78  while (myTrace.getTimeDurationMilliSec() < overallTime) {
79  if (myTrace.getTimeDurationMilliSec() > startTime + durationNull) {
80  setVel.angularVelocity = 0 * radian_per_second;
81  }
82  if (myTrace.getTimeDurationMilliSec() > startTime + durationNull
83  && myTrace.getTimeDurationMilliSec() < startTime + durationNull + stepStartTime) {
84  setVel.angularVelocity = 1 * radian_per_second;
85  }
86  if (myTrace.getTimeDurationMilliSec() > startTime + durationNull + stepStartTime) {
87  setVel.angularVelocity = 0 * radian_per_second;
88  }
89 
90  myBase.getBaseJoint(jointNO).setData(setVel);
91  myTrace.updateTrace(setVel);
92 
93  SLEEP_MICROSEC(updateCycle);
94  }
95  myTrace.stopTrace();
96  myTrace.plotTrace();
97 }
98 
100  LOG(info) <<__func__<< "\n";
101  YouBotBase myBase("youbot-base", CONFIG_FOLDER_PATH);
102  myBase.doJointCommutation();
103  DataTrace myTrace(myBase.getBaseJoint(jointNO), __func__, true);
104  myBase.getBaseJoint(jointNO).setEncoderToZero();
105  myTrace.startTrace();
106 
107  startTime = myTrace.getTimeDurationMilliSec();
108  overallTime = startTime + durationNull + stepStartTime + durationNull;
109 
110  while (myTrace.getTimeDurationMilliSec() < overallTime) {
111  if (myTrace.getTimeDurationMilliSec() > startTime + durationNull) {
112  currentSetpoint.current = 0 * ampere;
113  }
114  if (myTrace.getTimeDurationMilliSec() > startTime + durationNull
115  && myTrace.getTimeDurationMilliSec() < startTime + durationNull + stepStartTime) {
116  currentSetpoint.current = 0.3 * ampere;
117  }
118  if (myTrace.getTimeDurationMilliSec() > startTime + durationNull + stepStartTime) {
119  currentSetpoint.current = 0 * ampere;
120  }
121 
122  myBase.getBaseJoint(jointNO).setData(currentSetpoint);
123  myTrace.updateTrace(currentSetpoint);
124 
125  SLEEP_MICROSEC(updateCycle);
126  }
127  myTrace.stopTrace();
128  myTrace.plotTrace();
129 }
virtual void setData(const JointDataSetpoint &data)
static severity_level logginLevel
Definition: Logger.hpp:90
void youBotBaseTest_VelocityMode()
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 youBotBaseTest_PositionMode()
It groups the base joints together.
Definition: YouBotBase.hpp:76
void doJointCommutation()
does the sine commutation of the base joints
Definition: YouBotBase.cpp:95
virtual ~YouBotBaseTest()
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.
void youBotBaseTest_CurrentMode()


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