00001 /********************************************************************* 00002 * Software License Agreement (BSD License) 00003 * 00004 * Copyright (c) 2015, Neobotix GmbH 00005 * All rights reserved. 00006 * 00007 * Redistribution and use in source and binary forms, with or without 00008 * modification, are permitted provided that the following conditions 00009 * are met: 00010 * 00011 * * Redistributions of source code must retain the above copyright 00012 * notice, this list of conditions and the following disclaimer. 00013 * * Redistributions in binary form must reproduce the above 00014 * copyright notice, this list of conditions and the following 00015 * disclaimer in the documentation and/or other materials provided 00016 * with the distribution. 00017 * * Neither the name of the Neobotix nor the names of its 00018 * contributors may be used to endorse or promote products derived 00019 * from this software without specific prior written permission. 00020 * 00021 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 00022 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 00023 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 00024 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 00025 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 00026 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 00027 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 00028 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 00029 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 00030 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 00031 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00032 * POSSIBILITY OF SUCH DAMAGE. 00033 *********************************************************************/ 00034 00035 00036 #ifndef DRIVEPARAM_INCLUDEDEF_H 00037 #define DRIVEPARAM_INCLUDEDEF_H 00038 00039 //----------------------------------------------- 00040 00041 const double PI = 3.14159265358979323846; 00042 00046 class DriveParam 00047 { 00048 public: 00049 DriveParam() 00050 { 00051 imotor_active = 0; 00052 ihoming_active = 0; 00053 iEncIncrPerRevMot = 0; 00054 dVelMeasFrqHz = 0; 00055 dGearRatio = 0; 00056 dBeltRatio = 0; 00057 iSign = 0; 00058 dVelMaxEncIncrS = 0; 00059 dVelPModeEncIncrS = 0; 00060 dAccIncrS2 = 0; 00061 dDecIncrS2 = 0; 00062 dRadToIncr = 0; 00063 } 00064 00065 int imotor_active; // if motor is active 00066 int ihoming_active; // if homing is nessecary 00067 int iEncIncrPerRevMot; // encoder increments per revolution of motor shaft 00068 double dVelMeasFrqHz; // only used for Neo drive = 500, else = 1 00069 double dGearRatio; // gear ratio 00070 double dBeltRatio; // if drive has belt set ratio, else = 1 00071 int iSign; // direction of motion 00072 double dVelMaxEncIncrS; // max. veloctiy [encoder increments / s] 00073 double dVelPModeEncIncrS; // velocity in position mode e. g. if amplifier generates trajectory 00074 double dAccIncrS2; // max. acceleration [encoder increments / S^2] 00075 double dDecIncrS2; // max. deceleration [encoder increments / S^2] 00076 double dModulo; // Modulo for ELMO encoder 00077 double dRadToIncr; // factor for conversion 00078 00079 void calcRadToIncr() 00080 { 00081 dRadToIncr = (iEncIncrPerRevMot * dGearRatio * dBeltRatio) / (2. * PI); 00082 } 00083 00091 void convRadSToIncrPerPeriod(double dPosRad, double dVelRadS, int* piPosIncr, int* piVelIncrPeriod) 00092 { 00093 *piPosIncr = (int)convRadToIncr(dPosRad); 00094 *piVelIncrPeriod = (int)convRadSToIncrPerPeriod(dVelRadS); 00095 } 00096 00098 double convRadToIncr(double dPosWheelRad) 00099 { 00100 return (dPosWheelRad * dRadToIncr); 00101 } 00102 00104 double convIncrToRad(int iPosIncr) 00105 { 00106 return ((double)iPosIncr / dRadToIncr); 00107 } 00108 00110 double convRadSToIncrPerPeriod(double dVelWheelRadS) 00111 { 00112 return ( (dVelWheelRadS * dRadToIncr) / dVelMeasFrqHz ); 00113 } 00114 00116 double convIncrPerPeriodToRadS(int iVelMotIncrPeriod) 00117 { 00118 return ( (double)iVelMotIncrPeriod / dRadToIncr * dVelMeasFrqHz ); 00119 } 00120 00121 private: 00122 00123 // 00124 00125 00126 00127 }; 00128 00129 #endif