Main MRPT website > C++ reference for MRPT 1.9.9
CParameterizedTrajectoryGenerator.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
11 
12 #include <mrpt/utils/CStream.h>
14 #include <mrpt/system/filesystem.h>
15 #include <mrpt/system/os.h>
17 
18 using namespace mrpt::nav;
19 
21  "./reactivenav.logs";
24 
27 
29  : refDistance(.0),
30  m_alphaValuesCount(0),
31  m_score_priority(1.0),
32  m_clearance_num_points(5),
33  m_clearance_decimated_paths(15),
34  m_nav_dyn_state(),
35  m_nav_dyn_state_target_k(INVALID_PTG_PATH_INDEX),
36  m_is_initialized(false)
37 {
38 }
39 
40 void CParameterizedTrajectoryGenerator::loadDefaultParams()
41 {
42  m_alphaValuesCount = 121;
43  refDistance = 6.0;
44  m_score_priority = 1.0;
47 }
48 
50 {
51  return false;
52 }
54 {
55  return .0;
56 }
57 
59  const mrpt::utils::CConfigFileBase& cfg, const std::string& sSection)
60 {
62  num_paths, uint64_t, m_alphaValuesCount, cfg, sSection);
63  MRPT_LOAD_CONFIG_VAR_NO_DEFAULT(refDistance, double, cfg, sSection);
65  score_priority, double, m_score_priority, cfg, sSection);
67  clearance_num_points, double, m_clearance_num_points, cfg, sSection);
69  clearance_decimated_paths, double, m_clearance_decimated_paths, cfg,
70  sSection);
71 
72  // Ensure a minimum of resolution:
74 
75  // Optional params, for debugging only
77  vxi, double, m_nav_dyn_state.curVelLocal.vx, cfg, sSection);
79  vyi, double, m_nav_dyn_state.curVelLocal.vy, cfg, sSection);
81  wi, double, m_nav_dyn_state.curVelLocal.omega, cfg, sSection);
82 
84  reltrg_x, double, m_nav_dyn_state.relTarget.x, cfg, sSection);
86  reltrg_y, double, m_nav_dyn_state.relTarget.y, cfg, sSection);
88  reltrg_phi, double, m_nav_dyn_state.relTarget.phi, cfg, sSection);
89 
91  target_rel_speed, double, m_nav_dyn_state.targetRelSpeed, cfg,
92  sSection);
93 }
95  mrpt::utils::CConfigFileBase& cfg, const std::string& sSection) const
96 {
98  const int WN = 25, WV = 30;
99 
100  cfg.write(
101  sSection, "num_paths", m_alphaValuesCount, WN, WV,
102  "Number of discrete paths (`resolution`) in the PTG");
103  cfg.write(
104  sSection, "refDistance", refDistance, WN, WV,
105  "Maximum distance (meters) for building trajectories (visibility "
106  "range)");
107  cfg.write(
108  sSection, "score_priority", m_score_priority, WN, WV,
109  "When used in path planning, a multiplying factor (default=1.0) for "
110  "the scores for this PTG. Assign values <1 to PTGs with low priority.");
111  cfg.write(
112  sSection, "clearance_num_points", m_clearance_num_points, WN, WV,
113  "Number of steps for the piecewise-constant approximation of clearance "
114  "(Default=5).");
115  cfg.write(
116  sSection, "clearance_decimated_paths", m_clearance_decimated_paths, WN,
117  WV,
118  "Number of decimated paths for estimation of clearance (Default=15).");
119 
120  // Optional params, for debugging only
121  cfg.write(
122  sSection, "vxi", m_nav_dyn_state.curVelLocal.vx, WN, WV,
123  "(Only for debugging) Current robot velocity vx [m/s].");
124  cfg.write(
125  sSection, "vyi", m_nav_dyn_state.curVelLocal.vy, WN, WV,
126  "(Only for debugging) Current robot velocity vy [m/s].");
127  cfg.write(
129  WN, WV, "(Only for debugging) Current robot velocity omega [deg/s].");
130 
131  cfg.write(
132  sSection, "reltrg_x", m_nav_dyn_state.relTarget.x, WN, WV,
133  "(Only for debugging) Relative target x [m].");
134  cfg.write(
135  sSection, "reltrg_y", m_nav_dyn_state.relTarget.y, WN, WV,
136  "(Only for debugging) Relative target y [m].");
137  cfg.write(
138  sSection, "reltrg_phi",
140  "(Only for debugging) Relative target phi [deg].");
141 
142  cfg.write(
143  sSection, "target_rel_speed", m_nav_dyn_state.targetRelSpeed, WN, WV,
144  "(Only for debugging) Desired relative speed at target [0,1]");
145 
146  MRPT_END
147 }
148 
151 {
152  this->deinitialize();
153 
154  uint8_t version;
155  in >> version;
156  switch (version)
157  {
158  case 0:
159  case 1:
160  case 2:
161  case 3:
162  case 4:
164  if (version >= 1) in >> m_clearance_num_points;
165  if (version == 2)
166  {
167  bool old_use_approx_clearance;
168  in >> old_use_approx_clearance; // ignored in v>=3
169  }
170  if (version >= 4)
171  {
173  }
174  else
175  {
177  }
178  break;
179  default:
181  };
182 }
183 
185  mrpt::utils::CStream& out) const
186 {
187  const uint8_t version = 4;
188  out << version;
189 
191  << m_clearance_num_points /* v1 */;
192  out << m_clearance_decimated_paths /* v4*/;
193 }
194 
196  uint16_t k, const unsigned int num_paths)
197 {
198  ASSERT_BELOW_(k, num_paths)
199 
200  return M_PI * (-1.0 + 2.0 * (k + 0.5) / num_paths);
201 }
202 
204 {
205  return index2alpha(k, m_alphaValuesCount);
206 }
207 
209  double alpha, const unsigned int num_paths)
210 {
212  int k = mrpt::utils::round(0.5 * (num_paths * (1.0 + alpha / M_PI) - 1.0));
213  if (k < 0) k = 0;
214  if (k >= static_cast<int>(num_paths)) k = num_paths - 1;
215  return (uint16_t)k;
216 }
217 
219 {
221 }
222 
224  const uint16_t k, mrpt::opengl::CSetOfLines& gl_obj,
225  const double decimate_distance, const double max_path_distance) const
226 {
227  const size_t nPointsInPath = getPathStepCount(k);
228 
229  bool first = true;
230  // Decimate trajectories: we don't need centimeter resolution!
231  double last_added_dist = 0.0;
232  for (size_t n = 0; n < nPointsInPath; n++)
233  {
234  const double d = this->getPathDist(
235  k, n); // distance thru path "k" until timestep "n"
236 
237  // Draw the TP only until we reach the target of the "motion" segment:
238  if (max_path_distance >= 0.0 && d >= max_path_distance) break;
239 
240  if (d < last_added_dist + decimate_distance && n != 0)
241  continue; // skip: decimation
242 
243  last_added_dist = d;
244 
246  this->getPathPose(k, n, p);
247 
248  if (first)
249  {
250  first = false;
251  gl_obj.appendLine(0, 0, 0, p.x, p.y, 0);
252  }
253  else
254  gl_obj.appendLineStrip(p.x, p.y, 0);
255  }
256 }
257 
259  std::vector<double>& TP_Obstacles) const
260 {
261  TP_Obstacles.resize(m_alphaValuesCount);
262  for (size_t k = 0; k < m_alphaValuesCount; k++)
263  initTPObstacleSingle(k, TP_Obstacles[k]);
264 }
266  uint16_t k, double& TP_Obstacle_k) const
267 {
268  TP_Obstacle_k = std::min(
270  ? refDistance
271  : this->getPathDist(k, this->getPathStepCount(k) - 1));
272 }
273 
275  const std::string& ptg_name) const
276 {
277  using namespace mrpt::system;
278  using namespace std;
279 
280  const char* sPath =
282 
284  mrpt::system::createDirectory(mrpt::format("%s/PTGs", sPath));
285 
286  const string sFilTxt_x =
287  mrpt::format("%s/PTGs/PTG%s_x.txt", sPath, ptg_name.c_str());
288  const string sFilTxt_y =
289  mrpt::format("%s/PTGs/PTG%s_y.txt", sPath, ptg_name.c_str());
290  const string sFilTxt_phi =
291  mrpt::format("%s/PTGs/PTG%s_phi.txt", sPath, ptg_name.c_str());
292  const string sFilTxt_t =
293  mrpt::format("%s/PTGs/PTG%s_t.txt", sPath, ptg_name.c_str());
294  const string sFilTxt_d =
295  mrpt::format("%s/PTGs/PTG%s_d.txt", sPath, ptg_name.c_str());
296 
297  ofstream fx(sFilTxt_x.c_str());
298  if (!fx.is_open()) return false;
299  ofstream fy(sFilTxt_y.c_str());
300  if (!fy.is_open()) return false;
301  ofstream fp(sFilTxt_phi.c_str());
302  if (!fp.is_open()) return false;
303  ofstream fd(sFilTxt_d.c_str());
304  if (!fd.is_open()) return false;
305 
306  const size_t nPaths = getAlphaValuesCount();
307 
308  // Text version:
309  fx << "% PTG data file for 'x'. Each row is the trajectory for a different "
310  "'alpha' parameter value."
311  << endl;
312  fy << "% PTG data file for 'y'. Each row is the trajectory for a different "
313  "'alpha' parameter value."
314  << endl;
315  fp << "% PTG data file for 'phi'. Each row is the trajectory for a "
316  "different 'alpha' parameter value."
317  << endl;
318  fd << "% PTG data file for 'd'. Each row is the trajectory for a different "
319  "'alpha' parameter value."
320  << endl;
321 
322  vector<size_t> path_length(nPaths);
323  for (size_t k = 0; k < nPaths; k++) path_length[k] = getPathStepCount(k);
324 
325  size_t maxPoints = 0;
326  for (size_t k = 0; k < nPaths; k++)
327  maxPoints = max(maxPoints, path_length[k]);
328 
329  for (size_t k = 0; k < nPaths; k++)
330  {
331  for (size_t n = 0; n < maxPoints; n++)
332  {
333  const size_t nn = std::min(n, path_length[k] - 1);
335  this->getPathPose(k, nn, p);
336  fx << p.x << " ";
337  fy << p.y << " ";
338  fp << p.phi << " ";
339  fd << this->getPathDist(k, nn) << " ";
340  }
341  fx << endl;
342  fy << endl;
343  fp << endl;
344  fd << endl;
345  }
346 
347  return true;
348 }
349 
351 {
352  return m_is_initialized;
353 }
354 
357  const bool force_update)
358 {
359  // Make sure there is a real difference: notifying a PTG that a condition
360  // changed
361  // may imply a significant computational cost if paths need to be
362  // re-evaluated on the fly, etc.
363  // so the cost of the comparison here is totally worth:
364  if (force_update || m_nav_dyn_state != newState)
365  {
366  ASSERT_(
367  newState.targetRelSpeed >= .0 &&
368  newState.targetRelSpeed <= 1.0); // sanity check
369  m_nav_dyn_state = newState;
370 
371  // 1st) Build PTG paths without counting for target slow-down:
373 
374  this->onNewNavDynamicState();
375 
376  // 2nd) Save the special path for slow-down:
377  if (this->supportSpeedAtTarget())
378  {
379  int target_k = -1;
380  double target_norm_d;
381  // bool is_exact = // JLB removed this constraint for being too
382  // restrictive.
383  this->inverseMap_WS2TP(
385  target_k, target_norm_d, 1.0 /*large tolerance*/);
386  if (target_norm_d > 0.01 && target_norm_d < 0.99 && target_k >= 0 &&
387  target_k < m_alphaValuesCount)
388  {
389  m_nav_dyn_state_target_k = target_k;
390  this->onNewNavDynamicState(); // Recalc
391  }
392  }
393  }
394 }
395 
397  const std::string& cacheFilename, const bool verbose)
398 {
399  if (m_is_initialized) return;
400 
401  const std::string sCache =
402  !cacheFilename.empty()
403  ? cacheFilename
404  : std::string("cache_") +
406  std::string(".bin.gz");
407 
408  this->internal_initialize(sCache, verbose);
409  m_is_initialized = true;
410 }
412 {
413  if (!m_is_initialized) return;
414  this->internal_deinitialize();
415  m_is_initialized = false;
416 }
417 
419  const double ox, const double oy, const double new_tp_obs_dist,
420  double& inout_tp_obs) const
421 {
422  const bool is_obs_inside_robot_shape = isPointInsideRobotShape(ox, oy);
423  if (!is_obs_inside_robot_shape)
424  {
425  mrpt::utils::keep_min(inout_tp_obs, new_tp_obs_dist);
426  return;
427  }
428 
429  // Handle the special case of obstacles *inside* the robot at the begining
430  // of the PTG path:
431  switch (COLLISION_BEHAVIOR)
432  {
433  case COLL_BEH_STOP:
434  inout_tp_obs = .0;
435  break;
436 
437  case COLL_BEH_BACK_AWAY:
438  {
439  if (new_tp_obs_dist < getMaxRobotRadius())
440  {
441  // This means that we are getting apart of the obstacle:
442  // ignore it to allow the robot to get off the near-collision:
443  // Don't change inout_tp_obs.
444  return;
445  }
446  else
447  {
448  // This means we are already in collision and trying to get even
449  // closer
450  // to the obstacle: totally disprove this action:
451  inout_tp_obs = .0;
452  }
453  }
454  break;
455 
456  default:
457  THROW_EXCEPTION("Obstacle postprocessing enum not implemented!");
458  }
459 }
460 
462  ClearanceDiagram& cd) const
463 {
465  for (unsigned int decim_k = 0; decim_k < m_clearance_decimated_paths;
466  decim_k++)
467  {
468  const auto real_k = cd.decimated_k_to_real_k(decim_k);
469  const size_t numPathSteps = getPathStepCount(real_k);
470  const double numStepsPerIncr =
471  (numPathSteps - 1.0) / double(m_clearance_num_points);
472 
473  auto& cl_path = cd.get_path_clearance_decimated(decim_k);
474  for (double step_pointer_dbl = 0.0; step_pointer_dbl < numPathSteps;
475  step_pointer_dbl += numStepsPerIncr)
476  {
477  const size_t step = mrpt::utils::round(step_pointer_dbl);
478  const double dist_over_path = this->getPathDist(real_k, step);
479  cl_path[dist_over_path] = 1.0; // create entry in map<>
480  }
481  }
482 }
483 
485  const double ox, const double oy, ClearanceDiagram& cd) const
486 {
487  // Initialize CD on first call:
490 
491  // evaluate in derived-class: this function also keeps the minimum
492  // automatically.
493  for (uint16_t decim_k = 0; decim_k < cd.get_decimated_num_paths();
494  decim_k++)
495  {
496  const auto real_k = cd.decimated_k_to_real_k(decim_k);
498  ox, oy, real_k, cd.get_path_clearance_decimated(decim_k));
499  }
500 }
501 
503  ClearanceDiagram& cd, const std::vector<double>& TP_obstacles) const
504 {
505  // Used only when in approx mode (Removed 30/01/2017)
506 }
507 
509  const double ox, const double oy, const uint16_t k,
510  ClearanceDiagram::dist2clearance_t& inout_realdist2clearance,
511  bool treat_as_obstacle) const
512 {
513  bool had_collision = false;
514 
515  const size_t numPathSteps = getPathStepCount(k);
516  ASSERT_(numPathSteps > inout_realdist2clearance.size());
517 
518  const double numStepsPerIncr =
519  (numPathSteps - 1.0) / (inout_realdist2clearance.size());
520 
521  double step_pointer_dbl = 0.0;
522  const mrpt::math::TPoint2D og(ox, oy); // obstacle in "global" frame
523  mrpt::math::TPoint2D ol; // obstacle in robot frame
524 
525  for (auto& e : inout_realdist2clearance)
526  {
527  step_pointer_dbl += numStepsPerIncr;
528  const size_t step = mrpt::utils::round(step_pointer_dbl);
529  // const double dist_over_path = e.first;
530  double& inout_clearance = e.second;
531 
532  if (had_collision)
533  {
534  // We found a collision in a previous step along this "k" path, so
535  // it does not make sense to evaluate the clearance of a pose which
536  // is not reachable:
537  inout_clearance = .0;
538  continue;
539  }
540 
541  mrpt::math::TPose2D pose;
542  this->getPathPose(k, step, pose);
543 
544  // obstacle to robot clearance:
545  pose.inverseComposePoint(og, ol);
546  const double this_clearance =
547  treat_as_obstacle ? this->evalClearanceToRobotShape(ol.x, ol.y)
548  : ol.norm();
549  if (this_clearance <= .0 && treat_as_obstacle)
550  {
551  // Collision:
552  had_collision = true;
553  inout_clearance = .0;
554  }
555  else
556  {
557  // The obstacle is not a direct collision.
558  const double this_clearance_norm =
559  this_clearance / this->refDistance;
560 
561  // Update minimum in output structure
562  mrpt::utils::keep_min(inout_clearance, this_clearance_norm);
563  }
564  }
565 }
566 
568  : curVelLocal(0, 0, 0),
569  relTarget(20.0, 0, 0), // Default: assume a "distant" target ahead
570  targetRelSpeed(0)
571 {
572 }
573 
575  const TNavDynamicState& o) const
576 {
577  return (curVelLocal == o.curVelLocal) && (relTarget == o.relTarget) &&
578  (targetRelSpeed == o.targetRelSpeed);
579 }
580 
583 {
584  const uint8_t version = 0;
585  out << version;
586  // Data:
587  out << curVelLocal << relTarget << targetRelSpeed;
588 }
589 
592 {
593  uint8_t version;
594  in >> version;
595  switch (version)
596  {
597  case 0:
598  in >> curVelLocal >> relTarget >> targetRelSpeed;
599  break;
600  default:
602  };
603 }
double index2alpha(uint16_t k) const
Alpha value for the discrete corresponding value.
virtual bool supportSpeedAtTarget() const
Returns true if this PTG takes into account the desired velocity at target.
void initialize(const std::string &cacheFilename=std::string(), const bool verbose=true)
Must be called after setting all PTG parameters and before requesting converting obstacles to TP-Spac...
virtual bool supportVelCmdNOP() const
Returns true if it is possible to stop sending velocity commands to the robot and, still, the robot controller will be able to keep following the last sent trajectory ("NOP" velocity commands).
GLclampf GLclampf GLclampf alpha
Definition: glext.h:3525
size_t get_decimated_num_paths() const
bool createDirectory(const std::string &dirName)
Creates a directory.
Definition: filesystem.cpp:158
virtual void internal_initialize(const std::string &cacheFilename=std::string(), const bool verbose=true)=0
Must be called after setting all PTG parameters and before requesting converting obstacles to TP-Spac...
#define min(a, b)
unsigned __int16 uint16_t
Definition: rptypes.h:44
#define MRPT_LOAD_HERE_CONFIG_VAR( variableName, variableType, targetVariable, configFileObject, sectionNameStr)
IMPLEMENTS_VIRTUAL_SERIALIZABLE(CParameterizedTrajectoryGenerator, CSerializable, mrpt::nav) CParameterizedTrajectoryGenerator
std::string format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.
double x
X,Y coordinates.
void appendLineStrip(float x, float y, float z)
Appends a line whose starting point is the end point of the last line (similar to OpenGL&#39;s GL_LINE_ST...
Definition: CSetOfLines.h:93
This namespace provides a OS-independent interface to many useful functions: filenames manipulation...
Definition: math_frwds.h:30
double x
X,Y coordinates.
dist2clearance_t & get_path_clearance_decimated(size_t decim_k)
virtual void renderPathAsSimpleLine(const uint16_t k, mrpt::opengl::CSetOfLines &gl_obj, const double decimate_distance=0.1, const double max_path_distance=-1.0) const
Returns the representation of one trajectory of this PTG as a 3D OpenGL object (a simple curved line)...
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 bool isPointInsideRobotShape(const double x, const double y) const =0
Returns true if the point lies within the robot shape.
GLint * first
Definition: glext.h:3827
#define THROW_EXCEPTION(msg)
#define ASSERT_BELOW_(__A, __B)
GLenum GLsizei n
Definition: glext.h:5074
void initTPObstacles(std::vector< double > &TP_Obstacles) const
Resizes and populates the initial appropriate contents in a vector of tp-obstacles (collision-free ra...
Favor getting back from too-close (almost collision) obstacles.
virtual double maxTimeInVelCmdNOP(int path_k) const
Only for PTGs supporting supportVelCmdNOP(): this is the maximum time (in seconds) for which the path...
void updateClearancePost(ClearanceDiagram &cd, const std::vector< double > &TP_obstacles) const
void updateNavDynamicState(const TNavDynamicState &newState, const bool force_update=false)
To be invoked by the navigator before each navigation step, to let the PTG to react to changing dynam...
uint16_t m_nav_dyn_state_target_k
Update in updateNavDynamicState(), contains the path index (k) for the target.
Clearance information for one particular PTG and one set of obstacles.
STL namespace.
#define M_PI
Definition: bits.h:92
std::string fileNameStripInvalidChars(const std::string &filename, const char replacement_to_invalid_chars='_')
Replace invalid filename chars by underscores (&#39;_&#39;) or any other user-given char. ...
Definition: filesystem.cpp:327
virtual size_t getPathStepCount(uint16_t k) const =0
Access path k ([0,N-1]=>[-pi,pi] in alpha): number of discrete "steps" along the trajectory.
virtual double getPathDist(uint16_t k, uint32_t step) const =0
Access path k ([0,N-1]=>[-pi,pi] in alpha): traversed distance at discrete step step.
virtual void getPathPose(uint16_t k, uint32_t step, mrpt::math::TPose2D &p) const =0
Access path k ([0,N-1]=>[-pi,pi] in alpha): pose of the vehicle at discrete step step.
void keep_min(T &var, const K test_val)
If the second argument is below the first one, set the first argument to this lower value...
bool debugDumpInFiles(const std::string &ptg_name) const
Dump PTG trajectories in four text files: `.
virtual void internal_writeToStream(mrpt::utils::CStream &out) const
This class allows loading and storing values and vectors of different types from a configuration text...
void internal_TPObsDistancePostprocess(const double ox, const double oy, const double new_tp_obs_dist, double &inout_tp_obs) const
To be called by implementors of updateTPObstacle() and updateTPObstacleSingle() to honor the user set...
void initTPObstacleSingle(uint16_t k, double &TP_Obstacle_k) const
unsigned char uint8_t
Definition: rptypes.h:41
virtual void loadFromConfigFile(const mrpt::utils::CConfigFileBase &cfg, const std::string &sSection) override
Parameters accepted by this base class:
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.
static std::string OUTPUT_DEBUG_PATH_PREFIX
The path used as defaul output in, for example, debugDumpInFiles.
size_t decimated_k_to_real_k(size_t k) const
void appendLine(const mrpt::math::TSegment3D &sgm)
Appends a line to the set.
Definition: CSetOfLines.h:72
double RAD2DEG(const double x)
Radians to degrees.
virtual void internal_readFromStream(mrpt::utils::CStream &in)
#define MRPT_END
size_t get_actual_num_paths() const
std::map< double, double > dist2clearance_t
[TPS_distance] => normalized_clearance_for_exactly_that_robot_pose
double vx
Velocity components: X,Y (m/s)
#define MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION(__V)
For use in CSerializable implementations.
bool isInitialized() const
Returns true if initialize() has been called and there was no errors, so the PTG is ready to be queri...
mrpt::math::TTwist2D curVelLocal
Current vehicle velocity (local frame of reference)
virtual void onNewNavDynamicState()=0
Invoked when m_nav_dyn_state has changed; gives the PTG the opportunity to react and parameterize pat...
PTG_collision_behavior_t
Defines behaviors for where there is an obstacle inside the robot shape right at the beginning of a P...
void initClearanceDiagram(ClearanceDiagram &cd) const
Must be called to resize a CD to its correct size, before calling updateClearance() ...
mrpt::math::TPose2D relTarget
Current relative target location.
void resize(size_t actual_num_paths, size_t decimated_num_paths)
Initializes the container to allocate decimated_num_paths entries, as a decimated subset of a total o...
GLsizei const GLchar ** string
Definition: glext.h:4101
T wrapToPi(T a)
Modifies the given angle to translate it into the ]-pi,pi] range.
Definition: wrap2pi.h:53
uint16_t m_clearance_num_points
Number of steps for the piecewise-constant approximation of clearance from TPS distances [0...
uint16_t getAlphaValuesCount() const
Get the number of different, discrete paths in this family.
static PTG_collision_behavior_t COLLISION_BEHAVIOR
Defines the behavior when there is an obstacle inside the robot shape right at the beginning of a PTG...
double norm() const
Point norm.
Totally dissallow any movement if there is any too-close (almost collision) obstacles.
void updateClearance(const double ox, const double oy, ClearanceDiagram &cd) const
Updates the clearance diagram given one (ox,oy) obstacle point, in coordinates relative to the PTG pa...
#define MRPT_START
unsigned __int64 uint64_t
Definition: rptypes.h:50
void deinitialize()
This must be called to de-initialize the PTG if some parameter is to be changed.
#define MRPT_LOAD_HERE_CONFIG_VAR_NO_DEFAULT( variableName, variableType, targetVariable, configFileObject, sectionNameStr)
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())
#define MRPT_LOAD_HERE_CONFIG_VAR_DEGREES( variableName, variableType, targetVariable, configFileObject, sectionNameStr)
uint16_t m_clearance_decimated_paths
Number of paths for the decimated paths analysis of clearance.
virtual void evalClearanceSingleObstacle(const double ox, const double oy, const uint16_t k, ClearanceDiagram::dist2clearance_t &inout_realdist2clearance, bool treat_as_obstacle=true) const
Evals the robot clearance for each robot pose along path k, for the real distances in the key of the ...
GLuint in
Definition: glext.h:7274
Lightweight 2D pose.
#define ASSERT_(f)
int round(const T value)
Returns the closer integer (int) to x.
Definition: round.h:25
#define MRPT_LOAD_CONFIG_VAR_NO_DEFAULT( variableName, variableType, configFileObject, sectionNameStr)
virtual double evalClearanceToRobotShape(const double ox, const double oy) const =0
Evals the clearance from an obstacle (ox,oy) in coordinates relative to the robot center...
void inverseComposePoint(const TPoint2D g, TPoint2D &l) const
A set of independent lines (or segments), one line with its own start and end positions (X...
Definition: CSetOfLines.h:35
Lightweight 2D point.
TNavDynamicState m_nav_dyn_state
Updated before each nav step by.
Dynamic state that may affect the PTG path parameterization.
GLfloat GLfloat p
Definition: glext.h:6305
virtual void internal_deinitialize()=0
This must be called to de-initialize the PTG if some parameter is to be changed.
double phi
Orientation (rads)
void keep_max(T &var, const K test_val)
If the second argument is above the first one, set the first argument to this higher value...
uint16_t m_alphaValuesCount
The number of discrete values for "alpha" between -PI and +PI.
virtual double getMaxRobotRadius() const =0
Returns an approximation of the robot radius.
double omega
Angular velocity (rad/s)
virtual bool inverseMap_WS2TP(double x, double y, int &out_k, double &out_normalized_d, double tolerance_dist=0.10) const =0
Computes the closest (alpha,d) TP coordinates of the trajectory point closest to the Workspace (WS) C...
uint16_t alpha2index(double alpha) const
Discrete index value for the corresponding alpha value.
virtual std::string getDescription() const =0
Gets a short textual description of the PTG and its parameters.



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