00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #include "ArExport.h"
00027 #include "ariaOSDef.h"
00028 #include "ArActionMovementParameters.h"
00029 #include "ArConfig.h"
00030 #include "ArRobot.h"
00031
00040 AREXPORT ArActionMovementParameters::ArActionMovementParameters(
00041 const char *name,
00042 bool overrideFaster) :
00043 ArAction(name, "Sets all the max vel and accels/decels")
00044 {
00045 myOverrideFaster = overrideFaster;
00046 myEnabled = true;
00047 myEnableOnce = false;
00048 setParameters();
00049 }
00050
00051 AREXPORT ArActionMovementParameters::~ArActionMovementParameters()
00052 {
00053
00054 }
00055
00056 AREXPORT void ArActionMovementParameters::setParameters(double maxVel,
00057 double maxNegVel,
00058 double transAccel,
00059 double transDecel,
00060 double rotVelMax,
00061 double rotAccel,
00062 double rotDecel)
00063 {
00064 myMaxVel = maxVel;
00065 myMaxNegVel = maxNegVel;
00066 myTransAccel = transAccel;
00067 myTransDecel = transDecel;
00068 myMaxRotVel = rotVelMax;
00069 myRotAccel = rotAccel;
00070 myRotDecel = rotDecel;
00071 }
00072
00073 AREXPORT void ArActionMovementParameters::addToConfig(ArConfig *config,
00074 const char *section,
00075 const char *prefix)
00076 {
00077 std::string strPrefix;
00078 std::string name;
00079 if (prefix == NULL || prefix[0] == '\0')
00080 strPrefix = "";
00081 else
00082 strPrefix = prefix;
00083
00084 config->addParam(ArConfigArg(ArConfigArg::SEPARATOR), section, ArPriority::DETAILED);
00085 name = strPrefix;
00086 name += "TransVelMax";
00087 config->addParam(
00088 ArConfigArg(name.c_str(), &myMaxVel,
00089 "Maximum forward translational velocity (0 means use default)",
00090 0),
00091
00092 section, ArPriority::DETAILED);
00093
00094
00095 name = strPrefix;
00096 name += "TransNegVelMax";
00097 config->addParam(
00098 ArConfigArg(name.c_str(), &myMaxNegVel,
00099 "Maximum backwards translational velocity (0 means use default)",
00100 0),
00101
00102 section, ArPriority::DETAILED);
00103
00104 name = strPrefix;
00105 name += "TransAccel";
00106 config->addParam(
00107 ArConfigArg(name.c_str(), &myTransAccel,
00108 "Translational acceleration (0 means use default)", 0),
00109
00110 section, ArPriority::DETAILED);
00111
00112 name = strPrefix;
00113 name += "TransDecel";
00114 config->addParam(
00115 ArConfigArg(name.c_str(), &myTransDecel,
00116 "Translational deceleration (0 means use default)", 0),
00117
00118 section, ArPriority::DETAILED);
00119
00120 name = strPrefix;
00121 name += "RotVelMax";
00122 config->addParam(
00123 ArConfigArg(name.c_str(), &myMaxRotVel,
00124 "Maximum rotational velocity (0 means use default)",
00125 0),
00126 section, ArPriority::DETAILED);
00127
00128 name = strPrefix;
00129 name += "RotAccel";
00130 config->addParam(
00131 ArConfigArg(name.c_str(), &myRotAccel,
00132 "Rotational acceleration (0 means use default)", 0),
00133
00134 section, ArPriority::DETAILED);
00135
00136 name = strPrefix;
00137 name += "RotDecel";
00138 config->addParam(
00139 ArConfigArg(name.c_str(), &myRotDecel,
00140 "Rotational deceleration (0 means use default)", 0),
00141
00142 section, ArPriority::DETAILED);
00143 config->addParam(ArConfigArg(ArConfigArg::SEPARATOR), section, ArPriority::DETAILED);
00144
00145
00146 }
00147
00148 AREXPORT ArActionDesired *ArActionMovementParameters::fire(
00149 ArActionDesired currentDesired)
00150 {
00151 myDesired.reset();
00152
00153 if (!myEnabled && !myEnableOnce)
00154 return NULL;
00155 myEnableOnce = false;
00156
00157 if (fabs(myMaxVel) >= 1)
00158 myDesired.setMaxVel(myMaxVel);
00159
00160 if (fabs(myMaxNegVel) >= 1)
00161 myDesired.setMaxNegVel(myMaxNegVel);
00162
00163 if (fabs(myTransAccel) >= 1)
00164 myDesired.setTransAccel(myTransAccel);
00165
00166 if (fabs(myTransDecel) >= 1)
00167 myDesired.setTransDecel(myTransDecel);
00168
00169 if (fabs(myMaxRotVel) >= 1)
00170 myDesired.setMaxRotVel(myMaxRotVel);
00171
00172 if (fabs(myRotAccel) >= 1)
00173 myDesired.setRotAccel(myRotAccel);
00174
00175 if (fabs(myRotDecel) >= 1)
00176 myDesired.setRotDecel(myRotDecel);
00177
00178 return &myDesired;
00179 }