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-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
11 
14 #include <mrpt/system/filesystem.h>
15 #include <mrpt/system/os.h>
17 
18 using namespace mrpt::nav;
19 
20 static std::string OUTPUT_DEBUG_PATH_PREFIX = "./reactivenav.logs";
23 
25 {
27 }
28 
31 {
33 }
34 
37 
39  : refDistance(.0),
40  m_alphaValuesCount(0),
41  m_score_priority(1.0),
42  m_clearance_num_points(5),
43  m_clearance_decimated_paths(15),
44  m_nav_dyn_state(),
45  m_nav_dyn_state_target_k(INVALID_PTG_PATH_INDEX),
46  m_is_initialized(false)
47 {
48 }
49 
50 void CParameterizedTrajectoryGenerator::loadDefaultParams()
51 {
52  m_alphaValuesCount = 121;
53  refDistance = 6.0;
54  m_score_priority = 1.0;
57 }
58 
60 {
61  return false;
62 }
64 {
65  return .0;
66 }
67 
69  const mrpt::config::CConfigFileBase& cfg, const std::string& sSection)
70 {
72  num_paths, uint64_t, m_alphaValuesCount, cfg, sSection);
73  MRPT_LOAD_CONFIG_VAR_NO_DEFAULT(refDistance, double, cfg, sSection);
75  score_priority, double, m_score_priority, cfg, sSection);
77  clearance_num_points, double, m_clearance_num_points, cfg, sSection);
79  clearance_decimated_paths, double, m_clearance_decimated_paths, cfg,
80  sSection);
81 
82  // Ensure a minimum of resolution:
85  static_cast<decltype(m_clearance_num_points)>(refDistance / 1.0));
86 
87  // Optional params, for debugging only
89  vxi, double, m_nav_dyn_state.curVelLocal.vx, cfg, sSection);
91  vyi, double, m_nav_dyn_state.curVelLocal.vy, cfg, sSection);
93  wi, double, m_nav_dyn_state.curVelLocal.omega, cfg, sSection);
94 
96  reltrg_x, double, m_nav_dyn_state.relTarget.x, cfg, sSection);
98  reltrg_y, double, m_nav_dyn_state.relTarget.y, cfg, sSection);
100  reltrg_phi, double, m_nav_dyn_state.relTarget.phi, cfg, sSection);
101 
103  target_rel_speed, double, m_nav_dyn_state.targetRelSpeed, cfg,
104  sSection);
105 }
107  mrpt::config::CConfigFileBase& cfg, const std::string& sSection) const
108 {
109  MRPT_START
110  const int WN = 25, WV = 30;
111 
112  cfg.write(
113  sSection, "num_paths", m_alphaValuesCount, WN, WV,
114  "Number of discrete paths (`resolution`) in the PTG");
115  cfg.write(
116  sSection, "refDistance", refDistance, WN, WV,
117  "Maximum distance (meters) for building trajectories (visibility "
118  "range)");
119  cfg.write(
120  sSection, "score_priority", m_score_priority, WN, WV,
121  "When used in path planning, a multiplying factor (default=1.0) for "
122  "the scores for this PTG. Assign values <1 to PTGs with low priority.");
123  cfg.write(
124  sSection, "clearance_num_points", m_clearance_num_points, WN, WV,
125  "Number of steps for the piecewise-constant approximation of clearance "
126  "(Default=5).");
127  cfg.write(
128  sSection, "clearance_decimated_paths", m_clearance_decimated_paths, WN,
129  WV,
130  "Number of decimated paths for estimation of clearance (Default=15).");
131 
132  // Optional params, for debugging only
133  cfg.write(
134  sSection, "vxi", m_nav_dyn_state.curVelLocal.vx, WN, WV,
135  "(Only for debugging) Current robot velocity vx [m/s].");
136  cfg.write(
137  sSection, "vyi", m_nav_dyn_state.curVelLocal.vy, WN, WV,
138  "(Only for debugging) Current robot velocity vy [m/s].");
139  cfg.write(
140  sSection, "wi", mrpt::RAD2DEG(m_nav_dyn_state.curVelLocal.omega), WN,
141  WV, "(Only for debugging) Current robot velocity omega [deg/s].");
142 
143  cfg.write(
144  sSection, "reltrg_x", m_nav_dyn_state.relTarget.x, WN, WV,
145  "(Only for debugging) Relative target x [m].");
146  cfg.write(
147  sSection, "reltrg_y", m_nav_dyn_state.relTarget.y, WN, WV,
148  "(Only for debugging) Relative target y [m].");
149  cfg.write(
150  sSection, "reltrg_phi", mrpt::RAD2DEG(m_nav_dyn_state.relTarget.phi),
151  WN, WV, "(Only for debugging) Relative target phi [deg].");
152 
153  cfg.write(
154  sSection, "target_rel_speed", m_nav_dyn_state.targetRelSpeed, WN, WV,
155  "(Only for debugging) Desired relative speed at target [0,1]");
156 
157  MRPT_END
158 }
159 
162 {
163  this->deinitialize();
164 
165  uint8_t version;
166  in >> version;
167  switch (version)
168  {
169  case 0:
170  case 1:
171  case 2:
172  case 3:
173  case 4:
175  if (version >= 1) in >> m_clearance_num_points;
176  if (version == 2)
177  {
178  bool old_use_approx_clearance;
179  in >> old_use_approx_clearance; // ignored in v>=3
180  }
181  if (version >= 4)
182  {
184  }
185  else
186  {
188  }
189  break;
190  default:
192  };
193 }
194 
197 {
198  const uint8_t version = 4;
199  out << version;
200 
202  << m_clearance_num_points /* v1 */;
203  out << m_clearance_decimated_paths /* v4*/;
204 }
205 
207  uint16_t k, const unsigned int num_paths)
208 {
209  ASSERT_BELOW_(k, num_paths);
210  return M_PI * (-1.0 + 2.0 * (k + 0.5) / num_paths);
211 }
212 
214 {
215  return index2alpha(k, m_alphaValuesCount);
216 }
217 
219  double alpha, const unsigned int num_paths)
220 {
222  int k = mrpt::round(0.5 * (num_paths * (1.0 + alpha / M_PI) - 1.0));
223  if (k < 0) k = 0;
224  if (k >= static_cast<int>(num_paths)) k = num_paths - 1;
225  return (uint16_t)k;
226 }
227 
229 {
231 }
232 
234  const uint16_t k, mrpt::opengl::CSetOfLines& gl_obj,
235  const double decimate_distance, const double max_path_distance) const
236 {
237  const size_t nPointsInPath = getPathStepCount(k);
238 
239  bool first = true;
240  // Decimate trajectories: we don't need centimeter resolution!
241  double last_added_dist = 0.0;
242  for (size_t n = 0; n < nPointsInPath; n++)
243  {
244  const double d = this->getPathDist(
245  k, n); // distance thru path "k" until timestep "n"
246 
247  // Draw the TP only until we reach the target of the "motion" segment:
248  if (max_path_distance >= 0.0 && d >= max_path_distance) break;
249 
250  if (d < last_added_dist + decimate_distance && n != 0)
251  continue; // skip: decimation
252 
253  last_added_dist = d;
254 
256  this->getPathPose(k, n, p);
257 
258  if (first)
259  {
260  first = false;
261  gl_obj.appendLine(0, 0, 0, p.x, p.y, 0);
262  }
263  else
264  gl_obj.appendLineStrip(p.x, p.y, 0);
265  }
266 }
267 
269  std::vector<double>& TP_Obstacles) const
270 {
271  TP_Obstacles.resize(m_alphaValuesCount);
272  for (size_t k = 0; k < m_alphaValuesCount; k++)
273  initTPObstacleSingle(k, TP_Obstacles[k]);
274 }
276  uint16_t k, double& TP_Obstacle_k) const
277 {
278  TP_Obstacle_k = std::min(
280  ? refDistance
281  : this->getPathDist(k, this->getPathStepCount(k) - 1));
282 }
283 
285  const std::string& ptg_name) const
286 {
287  using namespace mrpt::system;
288  using namespace std;
289 
290  const char* sPath =
292 
294  mrpt::system::createDirectory(mrpt::format("%s/PTGs", sPath));
295 
296  const string sFilTxt_x =
297  mrpt::format("%s/PTGs/PTG%s_x.txt", sPath, ptg_name.c_str());
298  const string sFilTxt_y =
299  mrpt::format("%s/PTGs/PTG%s_y.txt", sPath, ptg_name.c_str());
300  const string sFilTxt_phi =
301  mrpt::format("%s/PTGs/PTG%s_phi.txt", sPath, ptg_name.c_str());
302  const string sFilTxt_t =
303  mrpt::format("%s/PTGs/PTG%s_t.txt", sPath, ptg_name.c_str());
304  const string sFilTxt_d =
305  mrpt::format("%s/PTGs/PTG%s_d.txt", sPath, ptg_name.c_str());
306 
307  ofstream fx(sFilTxt_x.c_str());
308  if (!fx.is_open()) return false;
309  ofstream fy(sFilTxt_y.c_str());
310  if (!fy.is_open()) return false;
311  ofstream fp(sFilTxt_phi.c_str());
312  if (!fp.is_open()) return false;
313  ofstream fd(sFilTxt_d.c_str());
314  if (!fd.is_open()) return false;
315 
316  const size_t nPaths = getAlphaValuesCount();
317 
318  // Text version:
319  fx << "% PTG data file for 'x'. Each row is the trajectory for a different "
320  "'alpha' parameter value."
321  << endl;
322  fy << "% PTG data file for 'y'. Each row is the trajectory for a different "
323  "'alpha' parameter value."
324  << endl;
325  fp << "% PTG data file for 'phi'. Each row is the trajectory for a "
326  "different 'alpha' parameter value."
327  << endl;
328  fd << "% PTG data file for 'd'. Each row is the trajectory for a different "
329  "'alpha' parameter value."
330  << endl;
331 
332  vector<size_t> path_length(nPaths);
333  for (size_t k = 0; k < nPaths; k++) path_length[k] = getPathStepCount(k);
334 
335  size_t maxPoints = 0;
336  for (size_t k = 0; k < nPaths; k++)
337  maxPoints = max(maxPoints, path_length[k]);
338 
339  for (size_t k = 0; k < nPaths; k++)
340  {
341  for (size_t n = 0; n < maxPoints; n++)
342  {
343  const size_t nn = std::min(n, path_length[k] - 1);
345  this->getPathPose(k, nn, p);
346  fx << p.x << " ";
347  fy << p.y << " ";
348  fp << p.phi << " ";
349  fd << this->getPathDist(k, nn) << " ";
350  }
351  fx << endl;
352  fy << endl;
353  fp << endl;
354  fd << endl;
355  }
356 
357  return true;
358 }
359 
361 {
362  return m_is_initialized;
363 }
364 
367  const bool force_update)
368 {
369  // Make sure there is a real difference: notifying a PTG that a condition
370  // changed
371  // may imply a significant computational cost if paths need to be
372  // re-evaluated on the fly, etc.
373  // so the cost of the comparison here is totally worth:
374  if (force_update || m_nav_dyn_state != newState)
375  {
376  ASSERT_(
377  newState.targetRelSpeed >= .0 &&
378  newState.targetRelSpeed <= 1.0); // sanity check
379  m_nav_dyn_state = newState;
380 
381  // 1st) Build PTG paths without counting for target slow-down:
383 
384  this->onNewNavDynamicState();
385 
386  // 2nd) Save the special path for slow-down:
387  if (this->supportSpeedAtTarget())
388  {
389  int target_k = -1;
390  double target_norm_d;
391  // bool is_exact = // JLB removed this constraint for being too
392  // restrictive.
393  this->inverseMap_WS2TP(
395  target_k, target_norm_d, 1.0 /*large tolerance*/);
396  if (target_norm_d > 0.01 && target_norm_d < 0.99 && target_k >= 0 &&
397  target_k < m_alphaValuesCount)
398  {
399  m_nav_dyn_state_target_k = target_k;
400  this->onNewNavDynamicState(); // Recalc
401  }
402  }
403  }
404 }
405 
407  const std::string& cacheFilename, const bool verbose)
408 {
409  if (m_is_initialized) return;
410 
411  const std::string sCache =
412  !cacheFilename.empty()
413  ? cacheFilename
414  : std::string("cache_") +
416  std::string(".bin.gz");
417 
418  this->internal_initialize(sCache, verbose);
419  m_is_initialized = true;
420 }
422 {
423  if (!m_is_initialized) return;
424  this->internal_deinitialize();
425  m_is_initialized = false;
426 }
427 
429  const double ox, const double oy, const double new_tp_obs_dist,
430  double& inout_tp_obs) const
431 {
432  const bool is_obs_inside_robot_shape = isPointInsideRobotShape(ox, oy);
433  if (!is_obs_inside_robot_shape)
434  {
435  mrpt::keep_min(inout_tp_obs, new_tp_obs_dist);
436  return;
437  }
438 
439  // Handle the special case of obstacles *inside* the robot at the begining
440  // of the PTG path:
441  switch (COLLISION_BEHAVIOR())
442  {
443  case COLL_BEH_STOP:
444  inout_tp_obs = .0;
445  break;
446 
447  case COLL_BEH_BACK_AWAY:
448  {
449  if (new_tp_obs_dist < getMaxRobotRadius())
450  {
451  // This means that we are getting apart of the obstacle:
452  // ignore it to allow the robot to get off the near-collision:
453  // Don't change inout_tp_obs.
454  return;
455  }
456  else
457  {
458  // This means we are already in collision and trying to get even
459  // closer
460  // to the obstacle: totally disprove this action:
461  inout_tp_obs = .0;
462  }
463  }
464  break;
465 
466  default:
467  THROW_EXCEPTION("Obstacle postprocessing enum not implemented!");
468  }
469 }
470 
472  ClearanceDiagram& cd) const
473 {
475  for (unsigned int decim_k = 0; decim_k < m_clearance_decimated_paths;
476  decim_k++)
477  {
478  const auto real_k = cd.decimated_k_to_real_k(decim_k);
479  const size_t numPathSteps = getPathStepCount(real_k);
480  const double numStepsPerIncr =
481  (numPathSteps - 1.0) / double(m_clearance_num_points);
482 
483  auto& cl_path = cd.get_path_clearance_decimated(decim_k);
484  for (double step_pointer_dbl = 0.0; step_pointer_dbl < numPathSteps;
485  step_pointer_dbl += numStepsPerIncr)
486  {
487  const size_t step = mrpt::round(step_pointer_dbl);
488  const double dist_over_path = this->getPathDist(real_k, step);
489  cl_path[dist_over_path] = 1.0; // create entry in map<>
490  }
491  }
492 }
493 
495  const double ox, const double oy, ClearanceDiagram& cd) const
496 {
497  // Initialize CD on first call:
500 
501  // evaluate in derived-class: this function also keeps the minimum
502  // automatically.
503  for (uint16_t decim_k = 0; decim_k < cd.get_decimated_num_paths();
504  decim_k++)
505  {
506  const auto real_k = cd.decimated_k_to_real_k(decim_k);
508  ox, oy, real_k, cd.get_path_clearance_decimated(decim_k));
509  }
510 }
511 
513  ClearanceDiagram& cd, const std::vector<double>& TP_obstacles) const
514 {
515  // Used only when in approx mode (Removed 30/01/2017)
516 }
517 
519  const double ox, const double oy, const uint16_t k,
520  ClearanceDiagram::dist2clearance_t& inout_realdist2clearance,
521  bool treat_as_obstacle) const
522 {
523  bool had_collision = false;
524 
525  const size_t numPathSteps = getPathStepCount(k);
526  ASSERT_(numPathSteps > inout_realdist2clearance.size());
527 
528  const double numStepsPerIncr =
529  (numPathSteps - 1.0) / (inout_realdist2clearance.size());
530 
531  double step_pointer_dbl = 0.0;
532  const mrpt::math::TPoint2D og(ox, oy); // obstacle in "global" frame
533  mrpt::math::TPoint2D ol; // obstacle in robot frame
534 
535  for (auto& e : inout_realdist2clearance)
536  {
537  step_pointer_dbl += numStepsPerIncr;
538  const size_t step = mrpt::round(step_pointer_dbl);
539  // const double dist_over_path = e.first;
540  double& inout_clearance = e.second;
541 
542  if (had_collision)
543  {
544  // We found a collision in a previous step along this "k" path, so
545  // it does not make sense to evaluate the clearance of a pose which
546  // is not reachable:
547  inout_clearance = .0;
548  continue;
549  }
550 
551  mrpt::math::TPose2D pose;
552  this->getPathPose(k, step, pose);
553 
554  // obstacle to robot clearance:
555  ol = pose.inverseComposePoint(og);
556  const double this_clearance =
557  treat_as_obstacle ? this->evalClearanceToRobotShape(ol.x, ol.y)
558  : ol.norm();
559  if (this_clearance <= .0 && treat_as_obstacle)
560  {
561  // Collision:
562  had_collision = true;
563  inout_clearance = .0;
564  }
565  else
566  {
567  // The obstacle is not a direct collision.
568  const double this_clearance_norm =
569  this_clearance / this->refDistance;
570 
571  // Update minimum in output structure
572  mrpt::keep_min(inout_clearance, this_clearance_norm);
573  }
574  }
575 }
576 
578  : curVelLocal(0, 0, 0),
579  relTarget(20.0, 0, 0), // Default: assume a "distant" target ahead
580  targetRelSpeed(0)
581 {
582 }
583 
585  const TNavDynamicState& o) const
586 {
587  return (curVelLocal == o.curVelLocal) && (relTarget == o.relTarget) &&
588  (targetRelSpeed == o.targetRelSpeed);
589 }
590 
593 {
594  const uint8_t version = 0;
595  out << version;
596  // Data:
597  out << curVelLocal << relTarget << targetRelSpeed;
598 }
599 
602 {
603  uint8_t version;
604  in >> version;
605  switch (version)
606  {
607  case 0:
608  in >> curVelLocal >> relTarget >> targetRelSpeed;
609  break;
610  default:
612  };
613 }
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.
#define MRPT_LOAD_HERE_CONFIG_VAR_DEGREES( variableName, variableType, targetVariable, configFileObject, sectionNameStr)
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
std::map< double, double > dist2clearance_t
[TPS_distance] => normalized_clearance_for_exactly_that_robot_pose
virtual void internal_writeToStream(mrpt::serialization::CArchive &out) const
size_t get_decimated_num_paths() const
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...
bool createDirectory(const std::string &dirName)
Creates a directory.
Definition: filesystem.cpp:158
#define MRPT_START
Definition: exceptions.h:262
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
IMPLEMENTS_VIRTUAL_SERIALIZABLE(CParameterizedTrajectoryGenerator, CSerializable, mrpt::nav) CParameterizedTrajectoryGenerator
double RAD2DEG(const double x)
Radians to degrees.
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. ...
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:88
double x
X,Y coordinates.
#define THROW_EXCEPTION(msg)
Definition: exceptions.h:41
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)...
#define ASSERT_BELOW_(__A, __B)
Definition: exceptions.h:165
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
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.
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:328
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.
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...
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.
bool debugDumpInFiles(const std::string &ptg_name) const
Dump PTG trajectories in four text files: `.
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
#define MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION(__V)
For use in CSerializable implementations.
Definition: exceptions.h:90
#define ASSERT_(f)
Defines an assertion mechanism.
Definition: exceptions.h:113
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...
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:68
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...
size_t get_actual_num_paths() const
double vx
Velocity components: X,Y (m/s)
mrpt::math::TPoint2D inverseComposePoint(const TPoint2D g) const
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...
static std::string OUTPUT_DEBUG_PATH_PREFIX
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.
#define MRPT_LOAD_CONFIG_VAR_NO_DEFAULT( variableName, variableType, configFileObject, sectionNameStr)
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:51
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())
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.
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...
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.
Virtual base class for "archives": classes abstracting I/O streams.
Definition: CArchive.h:52
virtual void loadFromConfigFile(const mrpt::config::CConfigFileBase &cfg, const std::string &sSection) override
Parameters accepted by this base class:
uint16_t m_clearance_decimated_paths
Number of paths for the decimated paths analysis of clearance.
std::string format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.
Definition: format.cpp:16
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 ...
#define MRPT_END
Definition: exceptions.h:266
virtual void internal_readFromStream(mrpt::serialization::CArchive &in)
GLuint in
Definition: glext.h:7274
Lightweight 2D pose.
static std::string & OUTPUT_DEBUG_PATH_PREFIX()
The path used as defaul output in, for example, debugDumpInFiles.
#define MRPT_LOAD_HERE_CONFIG_VAR( variableName, variableType, targetVariable, 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...
A set of independent lines (or segments), one line with its own start and end positions (X...
Definition: CSetOfLines.h:31
#define MRPT_LOAD_HERE_CONFIG_VAR_NO_DEFAULT( variableName, variableType, targetVariable, configFileObject, sectionNameStr)
Lightweight 2D point.
TNavDynamicState m_nav_dyn_state
Updated before each nav step by.
static PTG_collision_behavior_t COLLISION_BEHAVIOR
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)
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.
int round(const T value)
Returns the closer integer (int) to x.
Definition: round.h:23



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