Main MRPT website > C++ reference for MRPT 1.9.9
CPTG_DiffDrive_CC.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 
27  MRPT_LOAD_CONFIG_VAR_NO_DEFAULT(K, double, cfg, sSection);
28 
29  // The constant curvature turning radius used in this PTG:
30  R = V_MAX / W_MAX;
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, "K", K, WN, WV,
41  "K=+1 forward paths; K=-1 for backwards paths.");
42 
43  MRPT_END
44 }
45 
47 {
49 
50  switch (version)
51  {
52  case 0:
53  in >> K;
54  break;
55  default:
57  };
58 }
59 
61  mrpt::utils::CStream& out, int* version) const
62 {
63  if (version)
64  {
65  *version = 0;
66  return;
67  }
68 
70  out << K;
71 }
72 
74 {
75  char str[100];
76  os::sprintf(str, 100, "CPTG_DiffDrive_CC,K=%i", (int)K);
77  return std::string(str);
78 }
79 
81  float alpha, float t, float x, float y, float phi, float& v, float& w) const
82 {
83  MRPT_UNUSED_PARAM(phi);
86  float u = fabs(alpha) * 0.5f; /// 6.0f;
87 
88  if (t < u * R / V_MAX)
89  {
90  // l-
91  v = -V_MAX;
92  w = W_MAX;
93  }
94  else if (t < (u + M_PI * 0.5f) * R / V_MAX)
95  {
96  // l+
97  v = V_MAX;
98  w = W_MAX;
99  }
100  else
101  {
102  // END:
103  v = w = 0;
104  }
105 
106  // Turn in the opposite direction??
107  if (alpha < 0) w *= -1;
108 
109  v *= K;
110  w *= K;
111 }
112 
113 bool CPTG_DiffDrive_CC::PTG_IsIntoDomain(double x, double y) const
114 {
115  // Aprox domain: The circle at (0,R):
116  return (square(x) + square(fabs(y) - R)) <= R;
117 }
118 
120 {
122  K = +1.0;
123 }
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. ...
GLclampf GLclampf GLclampf alpha
Definition: glext.h:3525
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values, timewatch, extensions to STL.
GLdouble GLdouble t
Definition: glext.h:3689
This namespace provides a OS-independent interface to many useful functions: filenames manipulation...
Definition: math_frwds.h:30
std::string getDescription() const override
Gets a short textual description of the PTG and its parameters.
bool PTG_IsIntoDomain(double x, double y) const override
Returns the same than inverseMap_WS2TP() but without any additional cost.
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 internal_readFromStream(mrpt::utils::CStream &in) override
IMPLEMENTS_SERIALIZABLE(CPTG_DiffDrive_CC, CParameterizedTrajectoryGenerator, mrpt::nav) void CPTG_DiffDrive_CC
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. ...
#define M_PI
Definition: bits.h:92
void loadDefaultParams() override
Loads a set of default parameters; provided exclusively for the PTG-configurator tool.
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:4178
This class allows loading and storing values and vectors of different types from a configuration text...
void writeToStream(mrpt::utils::CStream &out, int *getVersion) const override
Introduces a pure virtual method responsible for writing to a CStream.
T square(const T x)
Inline function for the square of a number.
Definition: bits.h:55
This base class is used to provide a unified interface to files,memory buffers,..Please see the deriv...
Definition: CStream.h:41
This is the base class for any user-defined PTG.
virtual void loadFromConfigFile(const mrpt::utils::CConfigFileBase &cfg, const std::string &sSection) override
Possible values in "params" (those in CParameterizedTrajectoryGenerator, which is called internally...
A PTG for optimal paths of type "C|C" , as named in PTG papers.
#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.
GLsizei const GLchar ** string
Definition: glext.h:4101
#define MRPT_START
const GLdouble * v
Definition: glext.h:3678
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
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())
const float R
virtual void loadFromConfigFile(const mrpt::utils::CConfigFileBase &cfg, const std::string &sSection) override
Possible values in "params" (those in CParameterizedTrajectoryGenerator, which is called internally...
GLuint in
Definition: glext.h:7274
void internal_writeToStream(mrpt::utils::CStream &out) const override
#define MRPT_LOAD_CONFIG_VAR_NO_DEFAULT( variableName, variableType, configFileObject, sectionNameStr)
GLenum GLint GLint y
Definition: glext.h:3538
virtual void loadDefaultParams() override
Loads a set of default parameters; provided exclusively for the PTG-configurator tool.
GLenum GLint x
Definition: glext.h:3538
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...
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



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: ae4571287 Thu Nov 23 00:06:53 2017 +0100 at dom oct 27 23:51:55 CET 2019