MRPT  1.9.9
CPTG_DiffDrive_CCS.cpp
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | https://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2019, Individual contributors, see AUTHORS file |
6  | See: https://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See: https://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 
10 #include "nav-precomp.h" // Precomp header
11 
14 #include <mrpt/system/os.h>
15 
16 using namespace mrpt;
17 using namespace mrpt::nav;
18 using namespace mrpt::system;
19 
22 
24  const mrpt::config::CConfigFileBase& cfg, const std::string& sSection)
25 {
27 
28  MRPT_LOAD_CONFIG_VAR_NO_DEFAULT(K, double, cfg, sSection);
29 
30  // The constant curvature turning radius used in this PTG:
31  R = V_MAX / W_MAX;
32 }
34  mrpt::config::CConfigFileBase& cfg, const std::string& sSection) const
35 {
37  const int WN = 25, WV = 30;
39 
40  cfg.write(
41  sSection, "K", K, WN, WV,
42  "K=+1 forward paths; K=-1 for backwards paths.");
43 
44  MRPT_END
45 }
46 
49 {
51 
52  switch (version)
53  {
54  case 0:
55  in >> K;
56  break;
57  default:
59  };
60 }
61 
64 {
66  out << K;
67 }
68 
70 {
71  char str[100];
72  os::sprintf(str, 100, "CPTG_DiffDrive_CCS,K=%i", (int)K);
73  return std::string(str);
74 }
75 
77  float alpha, float t, float x, float y, float phi, float& v, float& w) const
78 {
79  MRPT_UNUSED_PARAM(phi);
82  float u = fabs(alpha) * 0.5f; // 0.14758362f; // u = atan(0.5)* alpha /
83  // PI;
84 
85  if (t < u * R / V_MAX)
86  {
87  // l-
88  v = -V_MAX;
89  w = W_MAX;
90  }
91  else if (t < (u + M_PI / 2) * R / V_MAX)
92  {
93  // l+ pi/2
94  v = V_MAX;
95  w = W_MAX;
96  }
97  else
98  {
99  // s+:
100  v = V_MAX;
101  w = 0;
102  }
103 
104  // Turn in the opposite direction??
105  if (alpha < 0) w *= -1;
106 
107  v *= K;
108  w *= K;
109 }
110 
111 bool CPTG_DiffDrive_CCS::PTG_IsIntoDomain(double x, double y) const
112 {
113  // If signs of K and X are different, it is into the domain:
114  if ((K * x) < 0) return true;
115 
116  if (fabs(y) >= R)
117  {
118  // Segmento de arriba:
119  return (fabs(x) <= R);
120  }
121  else
122  {
123  // The circle at (0,R):
124  return (square(x) + square(fabs(y) - R)) <= R;
125  }
126 }
127 
129 {
131  K = +1.0;
132 }
GLclampf GLclampf GLclampf alpha
Definition: glext.h:3529
#define MRPT_START
Definition: exceptions.h:241
GLdouble GLdouble t
Definition: glext.h:3695
void loadFromConfigFile(const mrpt::config::CConfigFileBase &cfg, const std::string &sSection) override
Possible values in "params" (those in CParameterizedTrajectoryGenerator, which is called internally...
uint8_t serializeGetVersion() const override
Must return the current versioning number of the object.
void loadDefaultParams() override
Loads a set of default parameters; provided exclusively for the PTG-configurator tool.
IMPLEMENTS_SERIALIZABLE(CPTG_DiffDrive_CCS, CParameterizedTrajectoryGenerator, mrpt::nav) void CPTG_DiffDrive_CCS
void internal_readFromStream(mrpt::serialization::CArchive &in) override
void serializeFrom(mrpt::serialization::CArchive &in, uint8_t serial_version) override
Pure virtual method for reading (deserializing) from an abstract archive.
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:4199
unsigned char uint8_t
Definition: rptypes.h:44
#define MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION(__V)
For use in CSerializable implementations.
Definition: exceptions.h:97
bool PTG_IsIntoDomain(double x, double y) const override
Returns the same than inverseMap_WS2TP() but without any additional cost.
T square(const T x)
Inline function for the square of a number.
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...
#define MRPT_LOAD_CONFIG_VAR_NO_DEFAULT( variableName, variableType, configFileObject, sectionNameStr)
std::string getDescription() const override
Gets a short textual description of the PTG and its parameters.
GLsizei const GLchar ** string
Definition: glext.h:4116
void loadFromConfigFile(const mrpt::config::CConfigFileBase &cfg, const std::string &sSection) override
Parameters accepted by this base class:
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 GLdouble * v
Definition: glext.h:3684
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
Virtual base class for "archives": classes abstracting I/O streams.
Definition: CArchive.h:53
const float R
#define MRPT_END
Definition: exceptions.h:245
GLuint in
Definition: glext.h:7391
void saveToConfigFile(mrpt::config::CConfigFileBase &cfg, const std::string &sSection) const override
This method saves the options to a ".ini"-like file or memory-stored string list. ...
GLenum GLint GLint y
Definition: glext.h:3542
void serializeTo(mrpt::serialization::CArchive &out) const override
Pure virtual method for writing (serializing) to an abstract archive.
A PTG for optimal paths of type "C|C,S" (as named in PTG papers).
void loadDefaultParams() override
Loads a set of default parameters; provided exclusively for the PTG-configurator tool.
GLenum GLint x
Definition: glext.h:3542
void saveToConfigFile(mrpt::config::CConfigFileBase &cfg, const std::string &sSection) const override
This method saves the options to a ".ini"-like file or memory-stored string list. ...
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...
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:191
void internal_writeToStream(mrpt::serialization::CArchive &out) const override
#define MRPT_UNUSED_PARAM(a)
Determines whether this is an X86 or AMD64 platform.
Definition: common.h:186



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: 8fe78517f Sun Jul 14 19:43:28 2019 +0200 at lun oct 28 02:10:00 CET 2019