GripperDataTrace.cpp
Go to the documentation of this file.
1 /****************************************************************
2  *
3  * Copyright (c) 2011
4  * All rights reserved.
5  *
6  * Hochschule Bonn-Rhein-Sieg
7  * University of Applied Sciences
8  * Computer Science Department
9  *
10  * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
11  *
12  * Author:
13  * Jan Paulus, Nico Hochgeschwender, Michael Reckhaus, Azamat Shakhimardanov
14  * Supervised by:
15  * Gerhard K. Kraetzschmar
16  *
17  * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
18  *
19  * This sofware is published under a dual-license: GNU Lesser General Public
20  * License LGPL 2.1 and BSD license. The dual-license implies that users of this
21  * code may choose which terms they prefer.
22  *
23  * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
24  *
25  * Redistribution and use in source and binary forms, with or without
26  * modification, are permitted provided that the following conditions are met:
27  *
28  * * Redistributions of source code must retain the above copyright
29  * notice, this list of conditions and the following disclaimer.
30  * * Redistributions in binary form must reproduce the above copyright
31  * notice, this list of conditions and the following disclaimer in the
32  * documentation and/or other materials provided with the distribution.
33  * * Neither the name of the Hochschule Bonn-Rhein-Sieg nor the names of its
34  * contributors may be used to endorse or promote products derived from
35  * this software without specific prior written permission.
36  *
37  * This program is free software: you can redistribute it and/or modify
38  * it under the terms of the GNU Lesser General Public License LGPL as
39  * published by the Free Software Foundation, either version 2.1 of the
40  * License, or (at your option) any later version or the BSD license.
41  *
42  * This program is distributed in the hope that it will be useful,
43  * but WITHOUT ANY WARRANTY; without even the implied warranty of
44  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
45  * GNU Lesser General Public License LGPL and the BSD license for more details.
46  *
47  * You should have received a copy of the GNU Lesser General Public
48  * License LGPL and BSD license along with this program.
49  *
50  ****************************************************************/
52 namespace youbot {
53 
54 GripperDataTrace::GripperDataTrace(YouBotGripperBar& youBotGripperBar, const std::string Name, const bool overwriteFiles):gripperBar(youBotGripperBar) {
55  // Bouml preserved body begin 00101BF1
56 
58  PWMSetpoint.pwm = 0;
60  this->name = Name;
61  if(Name != ""){
62  this->path = Name;
63  this->path.append("/");
64  }
65  char input = 0;
66 
67  if(boost::filesystem::exists((path+"gripperDataTrace").c_str())){
68  while(input != 'y' && input != 'n' && overwriteFiles == false){
69  std::cout << "Do you want to overwrite the existing files? [n/y]" << std::endl;
70 
71  input = getchar();
72 
73  if(input == 'n'){
74  throw std::runtime_error("Will not overwrite files!");
75  }
76  }
77 
78  }else{
79  boost::filesystem::path rootPath (this->path);
80 
81  if ( !boost::filesystem::exists(this->path) ){
82  if ( !boost::filesystem::create_directory( rootPath ))
83  throw std::runtime_error("could not create folder: " + this->path);
84  }
85  }
86 
87  // Bouml preserved body end 00101BF1
88 }
89 
91  // Bouml preserved body begin 00101C71
92  // Bouml preserved body end 00101C71
93 }
94 
95 void GripperDataTrace::startTrace(const std::string parameterName, const std::string unit) {
96  // Bouml preserved body begin 00101CF1
97 
98  std::string parameterString;
100 
101 
102  file.open((path+"gripperDataTrace").c_str(), std::fstream::out | std::fstream::trunc);
103 
104  ptime today;
105  today = second_clock::local_time();
106 
107  file << "# Name: " << this->name << std::endl;
108 
109  file << "# Date: " << boost::posix_time::to_simple_string(today) << std::endl;
110 
111  file << "# time [milliseconds]"
112  << " " << parameterName
113  << std::endl;
114 
115  parametersBeginTraceFile.open((path+"ParametersAtBegin").c_str(), std::fstream::out | std::fstream::trunc);
116 
117 
118 
119  // parameterVector.push_back(new GripperFirmwareVersion);
120  // parameterVector.push_back(new BarSpacingOffset);
121  // parameterVector.push_back(new MaxEncoderValue);
122 // parameterVector.push_back(new MaxTravelDistance);
123  parameterVector.push_back(new ActualPosition);
124  parameterVector.push_back(new ActualVelocity);
125  parameterVector.push_back(new ActualAcceleration);
126  parameterVector.push_back(new ActualLoadValue);
127  parameterVector.push_back(new ChopperBlankTime);
130  parameterVector.push_back(new ChopperHysteresisEnd);
131  parameterVector.push_back(new ChopperMode);
132  parameterVector.push_back(new ChopperOffTime);
133  parameterVector.push_back(new DoubleStepEnable);
134  parameterVector.push_back(new ErrorFlags);
135  parameterVector.push_back(new Freewheeling);
136  parameterVector.push_back(new MaximumAcceleration);
137  parameterVector.push_back(new MaximumCurrent);
139  parameterVector.push_back(new MicrostepResolution);
140  parameterVector.push_back(new PowerDownDelay);
141  parameterVector.push_back(new PulseDivisor);
142  parameterVector.push_back(new RampDivisor);
143  parameterVector.push_back(new RampMode);
144  parameterVector.push_back(new ShortDetectionTimer);
146  parameterVector.push_back(new SlopeControlHighSide);
147  parameterVector.push_back(new SlopeControlLowSide);
152  parameterVector.push_back(new SmartEnergyHysteresis);
157  parameterVector.push_back(new StallGuard2Threshold);
158  parameterVector.push_back(new StandbyCurrent);
160  parameterVector.push_back(new StopOnStall);
161  parameterVector.push_back(new Vsense);
162  parameterVector.push_back(new MinimumSpeed);
163 
164  parametersBeginTraceFile << "Name: " << this->name << std::endl;
165  parametersBeginTraceFile << "Date: " << boost::posix_time::to_simple_string(today) << std::endl;
166 
167 
168  for (unsigned int i = 0; i < parameterVector.size(); i++) {
170  parameterVector[i]->toString(parameterString);
171  // std::cout << parameterString << std::endl;
172  parametersBeginTraceFile << parameterString << std::endl;
173  }
174  parametersBeginTraceFile.close();
175 
176 
177  traceStartTime = microsec_clock::local_time();
178  // Bouml preserved body end 00101CF1
179 }
180 
182  // Bouml preserved body begin 00101D71
183  file.close();
184 
185  parametersEndTraceFile.open((path+"ParametersAfterTrace").c_str(), std::fstream::out | std::fstream::trunc);
186  std::string parameterString;
187 
188  parametersEndTraceFile << "Name: " << this->name << std::endl;
189  ptime today;
190  today = second_clock::local_time();
191  parametersEndTraceFile << "Date: " << boost::posix_time::to_simple_string(today) << std::endl;
192 
193 
194  for (unsigned int i = 0; i < parameterVector.size(); i++) {
196  parameterVector[i]->toString(parameterString);
197  parametersEndTraceFile << parameterString << std::endl;
198  delete parameterVector[i];
199  }
200 
201 
202  parametersEndTraceFile.close();
203  // Bouml preserved body end 00101D71
204 }
205 
207  // Bouml preserved body begin 00101DF1
208 
209  std::string executeString = "cd ";
210  executeString.append(path);
211  executeString.append("; gnuplot ../../GripperGnuPlotConfig");
212  // > /dev/null 2>&1");
213  std::system(executeString.c_str());
214  // Bouml preserved body end 00101DF1
215 }
216 
217 void GripperDataTrace::updateTrace(const double parameterValue) {
218  // Bouml preserved body begin 001021F1
219  timeDuration = microsec_clock::local_time() - traceStartTime;
220  timeDurationMicroSec = timeDuration.total_milliseconds();
221  file << timeDurationMicroSec << " " << parameterValue << std::endl;
222  // Bouml preserved body end 001021F1
223 }
224 
226  // Bouml preserved body begin 00102271
227  return timeDurationMicroSec;
228  // Bouml preserved body end 00102271
229 }
230 
231 
232 } // namespace youbot
Actual position of one gripper bar.
JointRoundsPerMinuteSetpoint roundsPerMinuteSetpoint
The lower threshold for the stallGuard2 value (see smart Energy current up step). ...
The current acceleration (read only).
unsigned long getTimeDurationMilliSec()
Hysteresis start setting. Please remark, that this value is an offset to the hysteresis end value...
virtual void getConfigurationParameter(MaxEncoderValue &parameter) const
Standstill period before the current is changed down to standby current. The standard value is 200 (v...
Readout of the actual load value with used for stall detection (stallGuard2).
The most important motor setting, since too high values might cause motor damage! The maximum value i...
Acceleration parameter for velocity control and position control.
JointEncoderSetpoint encoderSetpoint
The exponent of the scaling factor for the ramp generator- should be de/incremented carefully (in ste...
The current limit two seconds after the motor has stopped.
Motor stop in case of stall.
Determines the slope of the motor driver outputs. Set identical to slope control high side...
One bar of the youBot gripper.
std::vector< YouBotGripperParameter * > parameterVector
void startTrace(const std::string parameterName, const std::string unit)
Sets the motor current which is used below the threshold speed.
YouBotGripperBar & gripperBar
Above this speed coolStep becomes enabled.
Should always be set 1 to ensure exact reaching of the target position. Do not change! ...
GripperDataTrace(YouBotGripperBar &youBotGripperBar, const std::string Name, const bool overwriteFiles=false)
The exponent of the scaling factor for the pulse (step) generator should be de/incremented carefully ...
void updateTrace(const double parameterValue)
The limit for acceleration (and deceleration). Changing this parameter requires re-calculation of the...
Selects the comparator blank time. This time needs to safely cover the switching event and the durati...
Actual velocity of one gripper bar.


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