YouBotArmTestWithoutThread.cpp
Go to the documentation of this file.
2 
3 using namespace youbot;
4 
6 
7 
8 
9 }
10 
12 
13 }
14 
16  Logger::logginLevel = trace;
17  updateCycle = 2000;
18  ethercatMaster = &EthercatMaster::getInstance("youbot-ethercat.cfg", CONFIG_FOLDER_PATH, false);
20  LOG(error) << "Thread Active";
21  EthercatMaster::destroy();
22  ethercatMaster = &EthercatMaster::getInstance("youbot-ethercat.cfg", CONFIG_FOLDER_PATH, false);
23  }
24 
25 }
26 
28  EthercatMaster::destroy();
29 }
30 
32 
33  LOG(info) << __func__ << "\n";
34  YouBotManipulator myArm("youbot-manipulator", CONFIG_FOLDER_PATH);
35  myArm.doJointCommutation();
36  myArm.calibrateManipulator();
37 
38  std::stringstream jointNameStream;
39  boost::ptr_vector<DataTrace> myTrace;
40  std::vector<JointAngleSetpoint> upstretchedpose;
41  std::vector<JointAngleSetpoint> foldedpose;
42  JointAngleSetpoint desiredJointAngle;
43 
44  desiredJointAngle.angle = 2.56244 * radian;
45  upstretchedpose.push_back(desiredJointAngle);
46  desiredJointAngle.angle = 1.04883 * radian;
47  upstretchedpose.push_back(desiredJointAngle);
48  desiredJointAngle.angle = -2.43523 * radian;
49  upstretchedpose.push_back(desiredJointAngle);
50  desiredJointAngle.angle = 1.73184 * radian;
51  upstretchedpose.push_back(desiredJointAngle);
52  desiredJointAngle.angle = 1.5 * radian;
53  upstretchedpose.push_back(desiredJointAngle);
54 
55  desiredJointAngle.angle = 0.11 * radian;
56  foldedpose.push_back(desiredJointAngle);
57  desiredJointAngle.angle = 0.11 * radian;
58  foldedpose.push_back(desiredJointAngle);
59  desiredJointAngle.angle = -0.11 * radian;
60  foldedpose.push_back(desiredJointAngle);
61  desiredJointAngle.angle = 0.11 * radian;
62  foldedpose.push_back(desiredJointAngle);
63  desiredJointAngle.angle = 0.2 * radian;
64  foldedpose.push_back(desiredJointAngle);
65 
66 
67  for (int i = 1; i <= dof; i++) {
68  jointNameStream << "Joint_" << i << "_" << __func__;
69  myTrace.push_back(new DataTrace(myArm.getArmJoint(i), jointNameStream.str(), true));
70  jointNameStream.str("");
71  }
72 
73 
74  for (int i = 0; i < dof; i++) {
75  myTrace[i].startTrace();
76  }
77 
78  ClearMotorControllerTimeoutFlag clearTimeoutFlag;
79  myArm.getArmJoint(1).setConfigurationParameter(clearTimeoutFlag);
80  myArm.getArmJoint(2).setConfigurationParameter(clearTimeoutFlag);
81  myArm.getArmJoint(3).setConfigurationParameter(clearTimeoutFlag);
82  myArm.getArmJoint(4).setConfigurationParameter(clearTimeoutFlag);
83  myArm.getArmJoint(5).setConfigurationParameter(clearTimeoutFlag);
84 
85 
89  }
90 
91 
92  // 1 sec no movement
93  startTime = myTrace[0].getTimeDurationMilliSec();
94  overallTime = startTime + 1000;
95  while (myTrace[0].getTimeDurationMilliSec() < overallTime) {
99  }
100  for (int i = 0; i < dof; i++) {
101  myTrace[i].updateTrace();
102  }
104  }
105 
106  // move to upstretched position
107  startTime = myTrace[0].getTimeDurationMilliSec();
108  overallTime = startTime + 5000;
109  myArm.setJointData(upstretchedpose);
110  while (myTrace[0].getTimeDurationMilliSec() < overallTime) {
111  if (!ethercatMaster->isThreadActive()) {
114  }
115  for (int i = 0; i < dof; i++) {
116  myTrace[i].updateTrace();
117  }
119  }
120 
121  // move to folded position
122  startTime = myTrace[0].getTimeDurationMilliSec();
123  overallTime = startTime + 5000;
124  myArm.setJointData(foldedpose);
125  while (myTrace[0].getTimeDurationMilliSec() < overallTime) {
126  if (!ethercatMaster->isThreadActive()) {
129  }
130  for (int i = 0; i < dof; i++) {
131  myTrace[i].updateTrace();
132  }
134  }
135 
136  // 1 sec no movement
137  startTime = myTrace[0].getTimeDurationMilliSec();
138  overallTime = startTime + 1000;
139  while (myTrace[0].getTimeDurationMilliSec() < overallTime) {
140  if (!ethercatMaster->isThreadActive()) {
143  }
144  for (int i = 0; i < dof; i++) {
145  myTrace[i].updateTrace();
146  }
148  }
149 
150  for (int i = 0; i < dof; i++) {
151  myTrace[i].stopTrace();
152  myTrace[i].plotTrace();
153  }
154 
155 }
void doJointCommutation()
does the sine commutation of the arm joints
It groups the manipulator joints and the gripper together.
virtual void setConfigurationParameter(const JointParameter &parameter)
Definition: YouBotJoint.cpp:77
void calibrateManipulator(const bool forceCalibration=false)
calibrate the reference position of the arm joints
Clear the flag that indicates a communication timeout between the EtherCAT master and the controller...
virtual bool sendProcessData()=0
#define SLEEP_MICROSEC(microsec)
Definition: Time.hpp:61
#define LOG(level)
Definition: Logger.hpp:102
virtual bool receiveProcessData()=0
Creates a trace of all process data and reads all configuration parameter from one joint...
Definition: DataTrace.hpp:82
virtual void setJointData(const std::vector< JointAngleSetpoint > &JointData)
YouBotJoint & getArmJoint(const unsigned int armJointNumber)
EthercatMasterInterface * ethercatMaster
quantity< plane_angle > angle
Definition: JointData.hpp:172
Set-point angle / position of the joint.
Definition: JointData.hpp:170


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