MRPT  1.9.9
CPTG_DiffDrive_CS.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-2018, 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>
14 
15 using namespace mrpt;
16 using namespace mrpt::nav;
17 using namespace std;
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 }
69 {
70  char str[100];
71  os::sprintf(str, 100, "CPTG_DiffDrive_CS,K=%i", (int)K);
72  return std::string(str);
73 }
74 
76  float alpha, float t, float x, float y, float phi, float& v, float& w) const
77 {
80  MRPT_UNUSED_PARAM(phi);
81  const float T = 0.847f * std::sqrt(std::abs(alpha)) * R / V_MAX;
82 
83  if (t < T)
84  {
85  // l+
86  v = V_MAX;
87  w = W_MAX * min(1.0f, 1.0f - (float)exp(-square(alpha)));
88  }
89  else
90  {
91  // s+:
92  v = V_MAX;
93  w = 0;
94  }
95 
96  // Turn in the opposite direction??
97  if (alpha < 0) w *= -1;
98 
99  v *= K;
100  w *= K;
101 }
102 
103 bool CPTG_DiffDrive_CS::PTG_IsIntoDomain(double x, double y) const
104 {
105  // If signs of K and X are different, it is not into the domain:
106  if ((K * x) < 0) return false;
107 
108  if (fabs(y) >= R)
109  {
110  // Segmento de arriba:
111  return (fabs(x) > R - 0.10f);
112  }
113  else
114  {
115  // The circle at (0,R):
116  return (square(x) + square(fabs(y) - (R + 0.10f))) > square(R);
117  }
118 }
119 
121 {
123  K = +1.0;
124 }
GLclampf GLclampf GLclampf alpha
Definition: glext.h:3525
#define MRPT_START
Definition: exceptions.h:262
GLdouble GLdouble t
Definition: glext.h:3689
bool PTG_IsIntoDomain(double x, double y) const override
Returns the same than inverseMap_WS2TP() but without any additional cost.
#define min(a, b)
virtual void loadFromConfigFile(const mrpt::config::CConfigFileBase &cfg, const std::string &sSection) override
Possible values in "params" (those in CParameterizedTrajectoryGenerator, which is called internally...
std::string getDescription() const override
Gets a short textual description of the PTG and its parameters.
void internal_readFromStream(mrpt::serialization::CArchive &in) override
STL namespace.
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:4178
unsigned char uint8_t
Definition: rptypes.h:41
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...
#define MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION(__V)
For use in CSerializable implementations.
Definition: exceptions.h:90
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...
uint8_t serializeGetVersion() const override
Must return the current versioning number of the object.
virtual 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. ...
virtual void loadFromConfigFile(const mrpt::config::CConfigFileBase &cfg, const std::string &sSection) override
Possible values in "params" (those in CParameterizedTrajectoryGenerator, which is called internally...
void serializeTo(mrpt::serialization::CArchive &out) const override
Pure virtual method for writing (serializing) to an abstract archive.
#define MRPT_LOAD_CONFIG_VAR_NO_DEFAULT( variableName, variableType, configFileObject, sectionNameStr)
void serializeFrom(mrpt::serialization::CArchive &in, uint8_t serial_version) override
Pure virtual method for reading (deserializing) from an abstract archive.
GLsizei const GLchar ** string
Definition: glext.h:4101
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:3678
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:52
const float R
void loadDefaultParams() override
Loads a set of default parameters; provided exclusively for the PTG-configurator tool.
#define MRPT_END
Definition: exceptions.h:266
GLuint in
Definition: glext.h:7274
A PTG for optimal paths of type "CS", as named in PTG papers.
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
virtual 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. ...
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:189
IMPLEMENTS_SERIALIZABLE(CPTG_DiffDrive_CS, CParameterizedTrajectoryGenerator, mrpt::nav) void CPTG_DiffDrive_CS
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: 7d5e6d718 Fri Aug 24 01:51:28 2018 +0200 at lun nov 2 08:35:50 CET 2020