DataTrace.hpp
Go to the documentation of this file.
00001 #ifndef YOUBOT_DATATRACE_H
00002 #define YOUBOT_DATATRACE_H
00003 
00004 /****************************************************************
00005  *
00006  * Copyright (c) 2011
00007  * All rights reserved.
00008  *
00009  * Hochschule Bonn-Rhein-Sieg
00010  * University of Applied Sciences
00011  * Computer Science Department
00012  *
00013  * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00014  *
00015  * Author:
00016  * Jan Paulus, Nico Hochgeschwender, Michael Reckhaus, Azamat Shakhimardanov
00017  * Supervised by:
00018  * Gerhard K. Kraetzschmar
00019  *
00020  * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00021  *
00022  * This sofware is published under a dual-license: GNU Lesser General Public 
00023  * License LGPL 2.1 and BSD license. The dual-license implies that users of this
00024  * code may choose which terms they prefer.
00025  *
00026  * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00027  *
00028  * Redistribution and use in source and binary forms, with or without
00029  * modification, are permitted provided that the following conditions are met:
00030  *
00031  *     * Redistributions of source code must retain the above copyright
00032  *       notice, this list of conditions and the following disclaimer.
00033  *     * Redistributions in binary form must reproduce the above copyright
00034  *       notice, this list of conditions and the following disclaimer in the
00035  *       documentation and/or other materials provided with the distribution.
00036  *     * Neither the name of the Hochschule Bonn-Rhein-Sieg nor the names of its
00037  *       contributors may be used to endorse or promote products derived from
00038  *       this software without specific prior written permission.
00039  *
00040  * This program is free software: you can redistribute it and/or modify
00041  * it under the terms of the GNU Lesser General Public License LGPL as
00042  * published by the Free Software Foundation, either version 2.1 of the
00043  * License, or (at your option) any later version or the BSD license.
00044  *
00045  * This program is distributed in the hope that it will be useful,
00046  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00047  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00048  * GNU Lesser General Public License LGPL and the BSD license for more details.
00049  *
00050  * You should have received a copy of the GNU Lesser General Public
00051  * License LGPL and BSD license along with this program.
00052  *
00053  ****************************************************************/
00054 #include <vector>
00055 #include <sstream>
00056 #include <string>
00057 #include <cstdio>
00058 #include <stdexcept>
00059 #include <iostream>
00060 #include <stdlib.h>
00061 #include <boost/date_time/gregorian/gregorian.hpp>
00062 #include <boost/filesystem.hpp>
00063 #include <youbot_driver/generic/Logger.hpp>
00064 #include <youbot_driver/generic/Units.hpp>
00065 #include <youbot_driver/generic/Time.hpp>
00066 #include <youbot_driver/generic/ConfigFile.hpp>
00067 #include <youbot_driver/generic/Exceptions.hpp>
00068 #include <youbot_driver/youbot/YouBotJoint.hpp>
00069 #include <youbot_driver/youbot/YouBotJointParameter.hpp>
00070 
00071 using namespace boost::posix_time;
00072 namespace youbot
00073 {
00074 
00075 enum DataTraceCntrollerMode
00076 {
00077   POSITION_CONTROL_RAD, POSITION_CONTROL_ENC, VELOCITY_CONTROL_RAD_SEC, VELOCITY_CONTROL_RPM, CURRENT_CONTROL_MODE,
00078   TORQUE_CONTROL_MODE, NOT_DEFINED
00079 };
00083 class DataTrace
00084 {
00085 public:
00086   DataTrace(YouBotJoint& youBotJoint, const std::string Name, const bool overwriteFiles = false);
00087 
00088   virtual ~DataTrace();
00089 
00090   void startTrace();
00091 
00092   void stopTrace();
00093 
00094   void plotTrace();
00095 
00096   void updateTrace(const JointAngleSetpoint& setpoint);
00097 
00098   void updateTrace(const JointVelocitySetpoint& setpoint);
00099 
00100   void updateTrace(const JointRoundsPerMinuteSetpoint& setpoint);
00101 
00102   void updateTrace(const JointCurrentSetpoint& setpoint);
00103 
00104   void updateTrace(const JointTorqueSetpoint& setpoint);
00105 
00106   void updateTrace(const JointEncoderSetpoint& setpoint);
00107 
00108   void updateTrace();
00109 
00110   unsigned long getTimeDurationMilliSec();
00111 
00112 private:
00113   DataTrace(const DataTrace & source);
00114 
00115   DataTrace & operator=(const DataTrace & source);
00116 
00117   void update();
00118 
00119   YouBotJoint& joint;
00120 
00121   JointSensedAngle sensedAngle;
00122 
00123   JointSensedEncoderTicks sensedEncoderTicks;
00124 
00125   JointSensedVelocity sensedVelocity;
00126 
00127   JointSensedRoundsPerMinute sensedRoundsPerMinute;
00128 
00129   JointSensedCurrent sensedCurrent;
00130 
00131   JointSensedTorque sensedTorque;
00132 
00133   std::fstream file;
00134 
00135   JointAngleSetpoint angleSetpoint;
00136 
00137   JointVelocitySetpoint velocitySetpoint;
00138 
00139   JointRoundsPerMinuteSetpoint roundsPerMinuteSetpoint;
00140 
00141   JointCurrentSetpoint currentSetpoint;
00142 
00143   JointTorqueSetpoint torqueSetpoint;
00144 
00145   JointPWMSetpoint PWMSetpoint;
00146 
00147   JointEncoderSetpoint encoderSetpoint;
00148 
00149   std::fstream parametersBeginTraceFile;
00150 
00151   std::fstream parametersEndTraceFile;
00152 
00153   ptime traceStartTime;
00154 
00155   time_duration timeDuration;
00156 
00157   unsigned long timeDurationMicroSec;
00158 
00159   DataTraceCntrollerMode controllerMode;
00160 
00161   JointSensedPWM actualPWM;
00162 
00163   std::vector<YouBotJointParameterReadOnly*> parameterVector;
00164 
00165   std::string name;
00166 
00167   std::string path;
00168 
00169   int invertDirection;
00170 
00171   JointRampGeneratorVelocity rampGenSetpoint;
00172 
00173   JointCurrentSetpoint targetCurrent;
00174 
00175   JointVelocitySetpoint targetVelocity;
00176 
00177   JointAngleSetpoint targetAngle;
00178 
00179 };
00180 
00181 } // namespace youbot
00182 #endif


youbot_driver
Author(s): Jan Paulus
autogenerated on Mon Oct 6 2014 09:08:01