Main MRPT website > C++ reference for MRPT 1.5.7
CPTG_DiffDrive_alpha.cpp
Go to the documentation of this file.
1 /* +---------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2017, Individual contributors, see AUTHORS file |
6  | See: http://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in http://www.mrpt.org/License |
8  +---------------------------------------------------------------------------+ */
9 
10 #include "nav-precomp.h" // Precomp header
12 #include <mrpt/system/os.h>
13 
14 using namespace mrpt;
15 using namespace mrpt::nav;
16 using namespace mrpt::system;
17 using namespace mrpt::utils;
18 
20 
21 void CPTG_DiffDrive_alpha::loadFromConfigFile(const mrpt::utils::CConfigFileBase &cfg,const std::string &sSection)
22 {
24 
25  MRPT_LOAD_HERE_CONFIG_VAR_DEGREES_NO_DEFAULT(cte_a0v_deg,double, cte_a0v, cfg,sSection);
26  MRPT_LOAD_HERE_CONFIG_VAR_DEGREES_NO_DEFAULT(cte_a0w_deg,double, cte_a0w, cfg,sSection);
27 }
29 {
31  const int WN = 25, WV = 30;
33 
34  cfg.write(sSection,"cte_a0v_deg",mrpt::utils::RAD2DEG(cte_a0v), WN,WV, "Contant for vel profile [deg].");
35  cfg.write(sSection,"cte_a0w_deg",mrpt::utils::RAD2DEG(cte_a0v), WN,WV, "Contant for omega profile [deg].");
36 
37  MRPT_END
38 }
39 
41 {
42  char str[100];
43  os::sprintf(str,100,"CPTG_DiffDrive_alpha,av=%udeg,aw=%udeg",(int)RAD2DEG(cte_a0v),(int)RAD2DEG(cte_a0w) );
44  return std::string(str);
45 }
46 
47 
49 {
51 
52  switch (version)
53  {
54  case 0:
55  in >> cte_a0v >> cte_a0w;
56  break;
57  default:
59  };
60 }
61 
63 {
64  if (version)
65  {
66  *version = 0;
67  return;
68  }
69 
71  out << cte_a0v << cte_a0w;
72 }
73 /*---------------------------------------------------------------
74  ptgDiffDriveSteeringFunction
75  ---------------------------------------------------------------*/
76 void CPTG_DiffDrive_alpha::ptgDiffDriveSteeringFunction( float alpha, float t,float x, float y, float phi, float &v, float &w ) const
77 {
79  float At_a = alpha - phi;
80 
81  while (At_a>M_PI) At_a -= (float) M_2PI;
82  while (At_a<-M_PI) At_a += (float) M_2PI;
83 
84  v = V_MAX * exp(-square( At_a / cte_a0v ));
85  w= W_MAX * (-0.5f + (1/(1+exp(-At_a/cte_a0w))));
86 }
87 
88 
90 {
92 
93  cte_a0v = mrpt::utils::DEG2RAD(45.0);
94  cte_a0w = mrpt::utils::DEG2RAD(45.0);
95 }
GLclampf GLclampf GLclampf alpha
Definition: glext.h:3510
virtual void saveToConfigFile(mrpt::utils::CConfigFileBase &cfg, const std::string &sSection) const MRPT_OVERRIDE
This method saves the options to a ".ini"-like file or memory-stored string list. ...
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values, timewatch, extensions to STL.
Definition: zip.h:16
GLdouble GLdouble t
Definition: glext.h:3610
double DEG2RAD(const double x)
Degrees to radians.
This namespace provides a OS-independent interface to many useful functions: filenames manipulation...
Definition: math_frwds.h:29
#define IMPLEMENTS_SERIALIZABLE(class_name, base, NameSpace)
This must be inserted in all CSerializable classes implementation files.
STL namespace.
#define M_PI
Definition: bits.h:78
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:3962
#define M_2PI
Definition: mrpt_macros.h:380
This class allows loading and storing values and vectors of different types from a configuration text...
T square(const T x)
Inline function for the square of a number.
Definition: bits.h:52
void internal_readFromStream(mrpt::utils::CStream &in) MRPT_OVERRIDE
This base class is used to provide a unified interface to files,memory buffers,..Please see the deriv...
Definition: CStream.h:38
void loadDefaultParams() MRPT_OVERRIDE
Loads a set of default parameters; provided exclusively for the PTG-configurator tool.
This is the base class for any user-defined PTG.
double RAD2DEG(const double x)
Radians to degrees.
#define MRPT_END
#define MRPT_UNUSED_PARAM(a)
Can be used to avoid "not used parameters" warnings from the compiler.
#define MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION(__V)
For use in CSerializable implementations.
virtual void loadFromConfigFile(const mrpt::utils::CConfigFileBase &cfg, const std::string &sSection) MRPT_OVERRIDE
Possible values in "params" (those in CParameterizedTrajectoryGenerator, which is called internally...
virtual void saveToConfigFile(mrpt::utils::CConfigFileBase &cfg, const std::string &sSection) const MRPT_OVERRIDE
This method saves the options to a ".ini"-like file or memory-stored string list. ...
int version
Definition: mrpt_jpeglib.h:898
void writeToStream(mrpt::utils::CStream &out, int *getVersion) const
Introduces a pure virtual method responsible for writing to a CStream.
GLsizei const GLchar ** string
Definition: glext.h:3919
std::string getDescription() const MRPT_OVERRIDE
Gets a short textual description of the PTG and its parameters.
#define MRPT_START
#define RAD2DEG
const GLdouble * v
Definition: glext.h:3603
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
void write(const std::string &section, const std::string &name, const data_t &value, const int name_padding_width=-1, const int value_padding_width=-1, const std::string &comment=std::string())
The "a(symptotic)-alpha PTG", as named in PTG papers.
GLuint in
Definition: glext.h:6301
#define MRPT_LOAD_HERE_CONFIG_VAR_DEGREES_NO_DEFAULT(variableName, variableType, targetVariable, configFileObject, sectionNameStr)
GLenum GLint GLint y
Definition: glext.h:3516
void internal_writeToStream(mrpt::utils::CStream &out) const MRPT_OVERRIDE
int BASE_IMPEXP sprintf(char *buf, size_t bufSize, const char *format,...) MRPT_NO_THROWS MRPT_printf_format_check(3
An OS-independent version of sprintf (Notice the bufSize param, which may be ignored in some compiler...
Definition: os.cpp:191
virtual void loadDefaultParams() MRPT_OVERRIDE
Loads a set of default parameters; provided exclusively for the PTG-configurator tool.
void readFromStream(mrpt::utils::CStream &in, int version)
Introduces a pure virtual method responsible for loading from a CStream This can not be used directly...
typedef void(APIENTRYP PFNGLBLENDCOLORPROC)(GLclampf red
GLenum GLint x
Definition: glext.h:3516
void ptgDiffDriveSteeringFunction(float alpha, float t, float x, float y, float phi, float &v, float &w) const MRPT_OVERRIDE
The main method to be implemented in derived classes: it defines the differential-driven differential...



Page generated by Doxygen 1.8.14 for MRPT 1.5.7 Git: 5902e14cc Wed Apr 24 15:04:01 2019 +0200 at lun oct 28 01:39:17 CET 2019