YouBotJointParameterReadOnly.hpp

Go to the documentation of this file.
00001 #ifndef YOUBOT_YOUBOTJOINTPARAMETERREADONLY_H
00002 #define YOUBOT_YOUBOTJOINTPARAMETERREADONLY_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 "generic/Logger.hpp"
00057 #include "generic/Units.hpp"
00058 #include "generic/Time.hpp"
00059 #include "generic/Exceptions.hpp"
00060 #include "generic-joint/JointParameter.hpp"
00061 #include "youbot/ProtocolDefinitions.hpp"
00062 #include "youbot/YouBotSlaveMsg.hpp"
00063 #include "youbot/YouBotSlaveMailboxMsg.hpp"
00064 #include "youbot/YouBotJointStorage.hpp"
00065 namespace youbot {
00066 
00067 ///////////////////////////////////////////////////////////////////////////////
00068 /// abstract youBot joint parameter which can be read only
00069 ///////////////////////////////////////////////////////////////////////////////
00070 class YouBotJointParameterReadOnly : public JointParameter {
00071 friend class YouBotJoint;
00072   protected:
00073     YouBotJointParameterReadOnly();
00074 
00075 
00076   public:
00077     virtual ~YouBotJointParameterReadOnly();
00078 
00079     virtual void toString(std::string& value) = 0;
00080 
00081 
00082   protected:
00083     virtual void getYouBotMailboxMsg(YouBotSlaveMailboxMsg& message, TMCLCommandNumber msgType, const YouBotJointStorage& storage) const = 0;
00084 
00085     virtual void setYouBotMailboxMsg(const YouBotSlaveMailboxMsg& message, const YouBotJointStorage& storage) = 0;
00086 
00087     virtual std::string getName() const = 0;
00088 
00089     virtual ParameterType getType() const = 0;
00090 
00091     std::string name;
00092 
00093     ParameterType parameterType;
00094 
00095 };
00096 ///////////////////////////////////////////////////////////////////////////////
00097 /// Actual supply voltage.
00098 ///////////////////////////////////////////////////////////////////////////////
00099 class ActualMotorVoltage : public YouBotJointParameterReadOnly {
00100 friend class YouBotJoint;
00101   public:
00102     ActualMotorVoltage();
00103 
00104     virtual ~ActualMotorVoltage();
00105 
00106     void getParameter(quantity<electric_potential>& parameter) const;
00107 
00108     void toString(std::string& value);
00109 
00110 
00111   private:
00112     void getYouBotMailboxMsg(YouBotSlaveMailboxMsg& message, TMCLCommandNumber msgType, const YouBotJointStorage& storage) const;
00113 
00114     void setYouBotMailboxMsg(const YouBotSlaveMailboxMsg& message, const YouBotJointStorage& storage);
00115 
00116     std::string getName() const {return this->name;};
00117 
00118     /// testt
00119     ParameterType getType() const {return this->parameterType;};
00120 
00121     quantity<electric_potential> value;
00122 
00123     std::string name;
00124 
00125     ParameterType parameterType;
00126 
00127 };
00128 ///////////////////////////////////////////////////////////////////////////////
00129 /// Error and Status flags of the joint. 
00130 /// Bit 0: Overcurrent flag. This flag is set if overcurrent limit is exceeded. \n
00131 /// Bit 1: Undervoltage flag. This flag is set if supply voltage to low for motor operation. \n
00132 /// Bit 2: Overvoltage flag. This flag is set if the motor becomes switched off due to overvoltage. \n
00133 /// Bit 3: Overtemperature flag. This flag is set if overtemperature limit is exceeded. \n
00134 /// Bit 4: Motor halted flag. This flag is set if motor has been switched off. \n
00135 /// Bit 5: Hall error flag. This flag is set upon a hall error. \n
00136 /// Bit 6: Encoder error flag. This flag is set upon an encoder error. \n
00137 /// Bit 7: Winding error flag. [currently not used] \n
00138 /// Bit 8: Cycle time violation. [currently not used] \n
00139 /// Bit 9: Initialization error of sine commutation. This flag is set if initialization is failed. \n
00140 /// Bit 10: Position mode flag. This flag is set when the module is in positioning mode. \n
00141 /// Bit 11: Position end flag. This flag becomes set if the motor has been stopped at the end position. \n
00142 ///////////////////////////////////////////////////////////////////////////////
00143 class ErrorAndStatus : public YouBotJointParameterReadOnly {
00144 friend class YouBotJoint;
00145   public:
00146     ErrorAndStatus();
00147 
00148     virtual ~ErrorAndStatus();
00149 
00150     void getParameter(unsigned int& parameter) const;
00151 
00152     void toString(std::string& value);
00153 
00154 
00155   private:
00156     void getYouBotMailboxMsg(YouBotSlaveMailboxMsg& message, TMCLCommandNumber msgType, const YouBotJointStorage& storage) const;
00157 
00158     void setYouBotMailboxMsg(const YouBotSlaveMailboxMsg& message, const YouBotJointStorage& storage);
00159 
00160     std::string getName() const {return this->name;};
00161 
00162     ParameterType getType() const {return this->parameterType;};
00163 
00164     void parseYouBotErrorFlags() const;
00165 
00166     unsigned int value;
00167 
00168     std::string name;
00169 
00170     ParameterType parameterType;
00171 
00172 };
00173 ///////////////////////////////////////////////////////////////////////////////
00174 /// Actual error of PID position regulator
00175 ///////////////////////////////////////////////////////////////////////////////
00176 class PositionError : public YouBotJointParameterReadOnly {
00177 friend class YouBotJoint;
00178   public:
00179     PositionError();
00180 
00181     virtual ~PositionError();
00182 
00183     void getParameter(quantity<plane_angle>& parameter) const;
00184 
00185     void toString(std::string& value);
00186 
00187 
00188   private:
00189     void getYouBotMailboxMsg(YouBotSlaveMailboxMsg& message, TMCLCommandNumber msgType, const YouBotJointStorage& storage) const;
00190 
00191     void setYouBotMailboxMsg(const YouBotSlaveMailboxMsg& message, const YouBotJointStorage& storage);
00192 
00193     std::string getName() const {return this->name;};
00194 
00195     ParameterType getType() const {return this->parameterType;};
00196 
00197     quantity<plane_angle> value;
00198 
00199     std::string name;
00200 
00201     ParameterType parameterType;
00202 
00203 };
00204 ///////////////////////////////////////////////////////////////////////////////
00205 /// Sums of errors of PID position regulator
00206 ///////////////////////////////////////////////////////////////////////////////
00207 class PositionErrorSum : public YouBotJointParameterReadOnly {
00208 friend class YouBotJoint;
00209   public:
00210     PositionErrorSum();
00211 
00212     virtual ~PositionErrorSum();
00213 
00214     void getParameter(quantity<plane_angle>& parameter) const;
00215 
00216     void toString(std::string& value);
00217 
00218 
00219   private:
00220     void getYouBotMailboxMsg(YouBotSlaveMailboxMsg& message, TMCLCommandNumber msgType, const YouBotJointStorage& storage) const;
00221 
00222     void setYouBotMailboxMsg(const YouBotSlaveMailboxMsg& message, const YouBotJointStorage& storage);
00223 
00224     std::string getName() const {return this->name;};
00225 
00226     ParameterType getType() const {return this->parameterType;};
00227 
00228     quantity<plane_angle> value;
00229 
00230     std::string name;
00231 
00232     ParameterType parameterType;
00233 
00234 };
00235 ///////////////////////////////////////////////////////////////////////////////
00236 /// Actual error of PID velocity regulator
00237 ///////////////////////////////////////////////////////////////////////////////
00238 class VelocityError : public YouBotJointParameterReadOnly {
00239 friend class YouBotJoint;
00240   public:
00241     VelocityError();
00242 
00243     virtual ~VelocityError();
00244 
00245     void getParameter(quantity<si::angular_velocity>& parameter) const;
00246 
00247     void toString(std::string& value);
00248 
00249 
00250   private:
00251     void getYouBotMailboxMsg(YouBotSlaveMailboxMsg& message, TMCLCommandNumber msgType, const YouBotJointStorage& storage) const;
00252 
00253     void setYouBotMailboxMsg(const YouBotSlaveMailboxMsg& message, const YouBotJointStorage& storage);
00254 
00255     std::string getName() const {return this->name;};
00256 
00257     ParameterType getType() const {return this->parameterType;};
00258 
00259     quantity<si::angular_velocity> value;
00260 
00261     std::string name;
00262 
00263     ParameterType parameterType;
00264 
00265 };
00266 ///////////////////////////////////////////////////////////////////////////////
00267 /// Sums of Errors of PID velocity regulator
00268 ///////////////////////////////////////////////////////////////////////////////
00269 class VelocityErrorSum : public YouBotJointParameterReadOnly {
00270 friend class YouBotJoint;
00271   public:
00272     VelocityErrorSum();
00273 
00274     virtual ~VelocityErrorSum();
00275 
00276     void getParameter(quantity<si::angular_velocity>& parameter) const;
00277 
00278     void toString(std::string& value);
00279 
00280 
00281   private:
00282     void getYouBotMailboxMsg(YouBotSlaveMailboxMsg& message, TMCLCommandNumber msgType, const YouBotJointStorage& storage) const;
00283 
00284     void setYouBotMailboxMsg(const YouBotSlaveMailboxMsg& message, const YouBotJointStorage& storage);
00285 
00286     std::string getName() const {return this->name;};
00287 
00288     ParameterType getType() const {return this->parameterType;};
00289 
00290     quantity<si::angular_velocity> value;
00291 
00292     std::string name;
00293 
00294     ParameterType parameterType;
00295 
00296 };
00297 ///////////////////////////////////////////////////////////////////////////////
00298 /// Actual error of current PID regulator
00299 ///////////////////////////////////////////////////////////////////////////////
00300 class CurrentError : public YouBotJointParameterReadOnly {
00301 friend class YouBotJoint;
00302   public:
00303     CurrentError();
00304 
00305     virtual ~CurrentError();
00306 
00307     void getParameter(quantity<si::current>& parameter) const;
00308 
00309     void toString(std::string& value);
00310 
00311 
00312   private:
00313     void getYouBotMailboxMsg(YouBotSlaveMailboxMsg& message, TMCLCommandNumber msgType, const YouBotJointStorage& storage) const;
00314 
00315     void setYouBotMailboxMsg(const YouBotSlaveMailboxMsg& message, const YouBotJointStorage& storage);
00316 
00317     std::string getName() const {return this->name;};
00318 
00319     ParameterType getType() const {return this->parameterType;};
00320 
00321     quantity<si::current> value;
00322 
00323     std::string name;
00324 
00325     ParameterType parameterType;
00326 
00327 };
00328 ///////////////////////////////////////////////////////////////////////////////
00329 /// Sum of errors of current PID regulator
00330 ///////////////////////////////////////////////////////////////////////////////
00331 class CurrentErrorSum : public YouBotJointParameterReadOnly {
00332 friend class YouBotJoint;
00333   public:
00334     CurrentErrorSum();
00335 
00336     virtual ~CurrentErrorSum();
00337 
00338     void getParameter(quantity<si::current>& parameter) const;
00339 
00340     void toString(std::string& value);
00341 
00342 
00343   private:
00344     void getYouBotMailboxMsg(YouBotSlaveMailboxMsg& message, TMCLCommandNumber msgType, const YouBotJointStorage& storage) const;
00345 
00346     void setYouBotMailboxMsg(const YouBotSlaveMailboxMsg& message, const YouBotJointStorage& storage);
00347 
00348     std::string getName() const {return this->name;};
00349 
00350     ParameterType getType() const {return this->parameterType;};
00351 
00352     quantity<si::current> value;
00353 
00354     std::string name;
00355 
00356     ParameterType parameterType;
00357 
00358 };
00359 ///////////////////////////////////////////////////////////////////////////////
00360 /// The actual speed of the velocity ramp used for positioning and velocity mode. 
00361 ///////////////////////////////////////////////////////////////////////////////
00362 class RampGeneratorSpeed : public YouBotJointParameterReadOnly {
00363 friend class YouBotJoint;
00364   public:
00365     RampGeneratorSpeed();
00366 
00367     virtual ~RampGeneratorSpeed();
00368 
00369     void getParameter(quantity<si::angular_velocity>& parameter) const;
00370 
00371     void toString(std::string& value);
00372 
00373 
00374   private:
00375     void getYouBotMailboxMsg(YouBotSlaveMailboxMsg& message, TMCLCommandNumber msgType, const YouBotJointStorage& storage) const;
00376 
00377     void setYouBotMailboxMsg(const YouBotSlaveMailboxMsg& message, const YouBotJointStorage& storage);
00378 
00379     std::string getName() const {return this->name;};
00380 
00381     ParameterType getType() const {return this->parameterType;};
00382 
00383     quantity<si::angular_velocity> value;
00384 
00385     std::string name;
00386 
00387     ParameterType parameterType;
00388 
00389 };
00390 ///////////////////////////////////////////////////////////////////////////////
00391 /// Actual sum of the I2t monitor.
00392 ///////////////////////////////////////////////////////////////////////////////
00393 class I2tSum : public YouBotJointParameterReadOnly {
00394 friend class YouBotJoint;
00395   public:
00396     I2tSum();
00397 
00398     virtual ~I2tSum();
00399 
00400     void getParameter(unsigned int& parameter) const;
00401 
00402     void setParameter(const unsigned int parameter);
00403 
00404     void toString(std::string& value);
00405 
00406 
00407   private:
00408     void getYouBotMailboxMsg(YouBotSlaveMailboxMsg& message, TMCLCommandNumber msgType, const YouBotJointStorage& storage) const;
00409 
00410     void setYouBotMailboxMsg(const YouBotSlaveMailboxMsg& message, const YouBotJointStorage& storage);
00411 
00412     std::string getName() const {return this->name;};
00413 
00414     ParameterType getType() const {return this->parameterType;};
00415 
00416     unsigned int upperLimit;
00417 
00418     unsigned int lowerLimit;
00419 
00420     unsigned int value;
00421 
00422     std::string name;
00423 
00424     ParameterType parameterType;
00425 
00426 };
00427 ///////////////////////////////////////////////////////////////////////////////
00428 /// Actual temperature of the motor driver. 
00429 ///////////////////////////////////////////////////////////////////////////////
00430 class ActualMotorDriverTemperature : public YouBotJointParameterReadOnly {
00431 friend class YouBotJoint;
00432   public:
00433     ActualMotorDriverTemperature();
00434 
00435     virtual ~ActualMotorDriverTemperature();
00436 
00437     void getParameter(quantity<celsius::temperature>& parameter) const;
00438 
00439     void toString(std::string& value);
00440 
00441 
00442   private:
00443     void getYouBotMailboxMsg(YouBotSlaveMailboxMsg& message, TMCLCommandNumber msgType, const YouBotJointStorage& storage) const;
00444 
00445     void setYouBotMailboxMsg(const YouBotSlaveMailboxMsg& message, const YouBotJointStorage& storage);
00446 
00447     std::string getName() const {return this->name;};
00448 
00449     ParameterType getType() const {return this->parameterType;};
00450 
00451     quantity<celsius::temperature> value;
00452 
00453     std::string name;
00454 
00455     ParameterType parameterType;
00456 
00457 };
00458 ///////////////////////////////////////////////////////////////////////////////
00459 /// Get actual supply current of the module.
00460 ///////////////////////////////////////////////////////////////////////////////
00461 class ActualModuleSupplyCurrent : public YouBotJointParameterReadOnly {
00462 friend class YouBotJoint;
00463   public:
00464     ActualModuleSupplyCurrent();
00465 
00466     virtual ~ActualModuleSupplyCurrent();
00467 
00468     void getParameter(quantity<si::current>& parameter) const;
00469 
00470     void toString(std::string& value);
00471 
00472 
00473   private:
00474     void getYouBotMailboxMsg(YouBotSlaveMailboxMsg& message, TMCLCommandNumber msgType, const YouBotJointStorage& storage) const;
00475 
00476     void setYouBotMailboxMsg(const YouBotSlaveMailboxMsg& message, const YouBotJointStorage& storage);
00477 
00478     std::string getName() const {return this->name;};
00479 
00480     ParameterType getType() const {return this->parameterType;};
00481 
00482     quantity<si::current> value;
00483 
00484     std::string name;
00485 
00486     ParameterType parameterType;
00487 
00488 };
00489 
00490 } // namespace youbot
00491 #endif
Generated by  doxygen 1.6.3