Main MRPT website > C++ reference for MRPT 1.9.9
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 
21 
23  const mrpt::utils::CConfigFileBase& cfg, const std::string& sSection)
24 {
26 
28  cte_a0v_deg, double, cte_a0v, cfg, sSection);
30  cte_a0w_deg, double, cte_a0w, cfg, sSection);
31 }
33  mrpt::utils::CConfigFileBase& cfg, const std::string& sSection) const
34 {
36  const int WN = 25, WV = 30;
38 
39  cfg.write(
40  sSection, "cte_a0v_deg", mrpt::utils::RAD2DEG(cte_a0v), WN, WV,
41  "Contant for vel profile [deg].");
42  cfg.write(
43  sSection, "cte_a0w_deg", mrpt::utils::RAD2DEG(cte_a0v), WN, WV,
44  "Contant for omega profile [deg].");
45 
46  MRPT_END
47 }
48 
50 {
51  char str[100];
53  str, 100, "CPTG_DiffDrive_alpha,av=%udeg,aw=%udeg",
54  (int)RAD2DEG(cte_a0v), (int)RAD2DEG(cte_a0w));
55  return std::string(str);
56 }
57 
59 {
61 
62  switch (version)
63  {
64  case 0:
65  in >> cte_a0v >> cte_a0w;
66  break;
67  default:
69  };
70 }
71 
73  mrpt::utils::CStream& out, int* version) const
74 {
75  if (version)
76  {
77  *version = 0;
78  return;
79  }
80 
82  out << cte_a0v << cte_a0w;
83 }
84 /*---------------------------------------------------------------
85  ptgDiffDriveSteeringFunction
86  ---------------------------------------------------------------*/
88  float alpha, float t, float x, float y, float phi, float& v, float& w) const
89 {
93  float At_a = alpha - phi;
94 
95  while (At_a > M_PI) At_a -= (float)M_2PI;
96  while (At_a < -M_PI) At_a += (float)M_2PI;
97 
98  v = V_MAX * exp(-square(At_a / cte_a0v));
99  w = W_MAX * (-0.5f + (1 / (1 + exp(-At_a / cte_a0w))));
100 }
101 
103 {
105 
106  cte_a0v = mrpt::utils::DEG2RAD(45.0);
107  cte_a0w = mrpt::utils::DEG2RAD(45.0);
108 }
#define MRPT_LOAD_HERE_CONFIG_VAR_DEGREES_NO_DEFAULT( variableName, variableType, targetVariable, configFileObject, sectionNameStr)
IMPLEMENTS_SERIALIZABLE(CPTG_DiffDrive_alpha, CParameterizedTrajectoryGenerator, mrpt::nav) void CPTG_DiffDrive_alpha
#define RAD2DEG
Definition: bits.h:115
#define M_PI
Definition: bits.h:92
void internal_writeToStream(mrpt::utils::CStream &out) const override
void internal_readFromStream(mrpt::utils::CStream &in) override
virtual void loadDefaultParams() override
Loads a set of default parameters; provided exclusively for the PTG-configurator tool.
virtual void saveToConfigFile(mrpt::utils::CConfigFileBase &cfg, const std::string &sSection) const override
This method saves the options to a ".ini"-like file or memory-stored string list.
virtual void loadFromConfigFile(const mrpt::utils::CConfigFileBase &cfg, const std::string &sSection) override
Possible values in "params" (those in CParameterizedTrajectoryGenerator, which is called internally,...
The "a(symptotic)-alpha PTG", as named in PTG papers.
std::string getDescription() const override
Gets a short textual description of the PTG and its parameters.
void readFromStream(mrpt::utils::CStream &in, int version) override
Introduces a pure virtual method responsible for loading from a CStream This can not be used directly...
void writeToStream(mrpt::utils::CStream &out, int *getVersion) const override
Introduces a pure virtual method responsible for writing to a CStream.
virtual void saveToConfigFile(mrpt::utils::CConfigFileBase &cfg, const std::string &sSection) const override
This method saves the options to a ".ini"-like file or memory-stored string list.
virtual void loadFromConfigFile(const mrpt::utils::CConfigFileBase &cfg, const std::string &sSection) override
Possible values in "params" (those in CParameterizedTrajectoryGenerator, which is called internally,...
void ptgDiffDriveSteeringFunction(float alpha, float t, float x, float y, float phi, float &v, float &w) const override
The main method to be implemented in derived classes: it defines the differential-driven differential...
void loadDefaultParams() override
Loads a set of default parameters; provided exclusively for the PTG-configurator tool.
This is the base class for any user-defined PTG.
This class allows loading and storing values and vectors of different types from a configuration text...
void write(const std::string &section, const std::string &name, enum_t value, const int name_padding_width=-1, const int value_padding_width=-1, const std::string &comment=std::string())
This base class is used to provide a unified interface to files,memory buffers,..Please see the deriv...
Definition: CStream.h:42
GLdouble GLdouble t
Definition: glext.h:3689
const GLdouble * v
Definition: glext.h:3678
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:4178
GLclampf GLclampf GLclampf alpha
Definition: glext.h:3525
GLenum GLint GLint y
Definition: glext.h:3538
GLuint in
Definition: glext.h:7274
GLenum GLint x
Definition: glext.h:3538
GLsizei const GLchar ** string
Definition: glext.h:4101
int sprintf(char *buf, size_t bufSize, const char *format,...) noexcept 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:188
#define MRPT_START
Definition: mrpt_macros.h:425
#define M_2PI
Definition: mrpt_macros.h:437
#define MRPT_END
Definition: mrpt_macros.h:429
#define MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION(__V)
For use in CSerializable implementations.
Definition: mrpt_macros.h:181
#define MRPT_UNUSED_PARAM(a)
Can be used to avoid "not used parameters" warnings from the compiler.
Definition: mrpt_macros.h:365
T square(const T x)
Inline function for the square of a number.
Definition: bits.h:55
This namespace provides a OS-independent interface to many useful functions: filenames manipulation,...
Definition: math_frwds.h:31
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values,...
double DEG2RAD(const double x)
Degrees to radians.
Definition: bits.h:96
double RAD2DEG(const double x)
Radians to degrees.
Definition: bits.h:102
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.



Page generated by Doxygen 1.9.1 for MRPT 1.9.9 Git: 63ea9d1f1 Thu Nov 23 00:06:53 2017 +0100 at mar 26 may 2026 12:19:29 CEST