openrave.org

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
plannerparameters.h
Go to the documentation of this file.
1 // -*- coding: utf-8 -*-
2 // Copyright (C) 2006-2012 Rosen Diankov <rosen.diankov@gmail.com>
3 //
4 // This file is part of OpenRAVE.
5 // OpenRAVE is free software: you can redistribute it and/or modify
6 // it under the terms of the GNU Lesser General Public License as published by
7 // the Free Software Foundation, either version 3 of the License, or
8 // at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU Lesser General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public License
16 // along with this program. If not, see <http://www.gnu.org/licenses/>.
20 #ifndef OPENRAVE_PLANNER_PARAMETERS_H
21 #define OPENRAVE_PLANNER_PARAMETERS_H
22 
23 #include <openrave/planningutils.h>
24 
25 namespace OpenRAVE {
26 
28 {
29 public:
30  ExplorationParameters() : _fExploreProb(0), _nExpectedDataSize(100), _bProcessingExploration(false) {
31  _vXMLParameters.push_back("exploreprob");
32  _vXMLParameters.push_back("expectedsize");
33  }
34 
37 
38 protected:
40  // save the extra data to XML
41  virtual bool serialize(std::ostream& O, int options=0) const
42  {
43  if( !PlannerParameters::serialize(O,options&~1) ) { // skip writing extra
44  return false;
45  }
46  O << "<exploreprob>" << _fExploreProb << "</exploreprob>" << std::endl;
47  O << "<expectedsize>" << _nExpectedDataSize << "</expectedsize>" << std::endl;
48  if( !(options & 1) ) {
49  O << _sExtraParameters << std::endl;
50  }
51  return !!O;
52  }
53 
54  ProcessElement startElement(const std::string& name, const AttributesList& atts)
55  {
56  if( _bProcessingExploration ) {
57  return PE_Ignore;
58  }
60  case PE_Pass: break;
61  case PE_Support: return PE_Support;
62  case PE_Ignore: return PE_Ignore;
63  }
64 
65  _bProcessingExploration = name=="exploreprob"||name=="expectedsize";
66  return _bProcessingExploration ? PE_Support : PE_Pass;
67  }
68 
69  // called at the end of every XML tag, _ss contains the data
70  virtual bool endElement(const std::string& name)
71  {
72  // _ss is an internal stringstream that holds the data of the tag
73  if( _bProcessingExploration ) {
74  if( name == "exploreprob") {
75  _ss >> _fExploreProb;
76  }
77  else if( name == "expectedsize" ) {
78  _ss >> _nExpectedDataSize;
79  }
80  else {
81  RAVELOG_WARN(str(boost::format("unknown tag %s\n")%name));
82  }
83  _bProcessingExploration = false;
84  return false;
85  }
86 
87  // give a chance for the default parameters to get processed
88  return PlannerParameters::endElement(name);
89  }
90 };
91 
93 {
94 public:
95  RAStarParameters() : fRadius(0.1f), fDistThresh(0.03f), fGoalCoeff(1), nMaxChildren(5), nMaxSampleTries(10), _bProcessingRA(false) {
96  _vXMLParameters.push_back("radius");
97  _vXMLParameters.push_back("distthresh");
98  _vXMLParameters.push_back("goalcoeff");
99  _vXMLParameters.push_back("maxchildren");
100  _vXMLParameters.push_back("maxsampletries");
101  }
102 
108 protected:
110  virtual bool serialize(std::ostream& O, int options) const
111  {
112  if( !PlannerParameters::serialize(O,options&~1) ) {
113  return false;
114  }
115  O << "<radius>" << fRadius << "</radius>" << std::endl;
116  O << "<distthresh>" << fDistThresh << "</distthresh>" << std::endl;
117  O << "<goalcoeff>" << fGoalCoeff << "</goalcoeff>" << std::endl;
118  O << "<maxchildren>" << nMaxChildren << "</maxchildren>" << std::endl;
119  O << "<maxsampletries>" << nMaxSampleTries << "</maxsampletries>" << std::endl;
120  if( !(options & 1) ) {
121  O << _sExtraParameters << std::endl;
122  }
123 
124  return !!O;
125  }
126 
127  ProcessElement startElement(const std::string& name, const AttributesList& atts)
128  {
129  if( _bProcessingRA ) {
130  return PE_Ignore;
131  }
132  switch( PlannerBase::PlannerParameters::startElement(name,atts) ) {
133  case PE_Pass: break;
134  case PE_Support: return PE_Support;
135  case PE_Ignore: return PE_Ignore;
136  }
137  _bProcessingRA = name=="radius"||name=="distthresh"||name=="goalcoeff"||name=="maxchildren"||name=="maxsampletries";
138  return _bProcessingRA ? PE_Support : PE_Pass;
139  }
140  virtual bool endElement(const std::string& name)
141  {
142  if( _bProcessingRA ) {
143  if( name == "radius") {
144  _ss >> fRadius;
145  }
146  else if( name == "distthresh") {
147  _ss >> fDistThresh;
148  }
149  else if( name == "goalcoeff") {
150  _ss >> fGoalCoeff;
151  }
152  else if( name == "maxchildren") {
153  _ss >> nMaxChildren;
154  }
155  else if( name == "maxsampletries") {
156  _ss >> nMaxSampleTries;
157  }
158  else {
159  RAVELOG_WARN(str(boost::format("unknown tag %s\n")%name));
160  }
161  _bProcessingRA = false;
162  return false;
163  }
164  // give a chance for the default parameters to get processed
165  return PlannerParameters::endElement(name);
166  }
167 };
168 
170 {
171 public:
172  GraspSetParameters(EnvironmentBasePtr penv) : _nGradientSamples(5), _fVisibiltyGraspThresh(0), _fGraspDistThresh(1.4f), _penv(penv),_bProcessingGS(false) {
173  _vXMLParameters.push_back("grasps");
174  _vXMLParameters.push_back("target");
175  _vXMLParameters.push_back("numgradsamples");
176  _vXMLParameters.push_back("visgraspthresh");
177  _vXMLParameters.push_back("graspdistthresh");
178  }
179 
180  std::vector<Transform> _vgrasps;
185 
186 protected:
189  virtual bool serialize(std::ostream& O, int options=0) const
190  {
191  if( !PlannerParameters::serialize(O,options&~1) ) {
192  return false;
193  }
194  O << "<grasps>" << _vgrasps.size() << " ";
195  for(std::vector<Transform>::const_iterator it = _vgrasps.begin(); it != _vgrasps.end(); ++it) {
196  O << *it << " ";
197  }
198  O << "</grasps>" << std::endl;
199  O << "<target>" << (!!_ptarget ? _ptarget->GetEnvironmentId() : 0) << "</target>" << std::endl;
200  O << "<numgradsamples>" << _nGradientSamples << "</numgradsamples>" << std::endl;
201  O << "<visgraspthresh>" << _fVisibiltyGraspThresh << "</visgraspthresh>" << std::endl;
202  O << "<graspdistthresh>" << _fGraspDistThresh << "</graspdistthresh>" << std::endl;
203  if( !(options & 1) ) {
204  O << _sExtraParameters << std::endl;
205  }
206  return !!O;
207  }
208 
209  ProcessElement startElement(const std::string& name, const AttributesList& atts)
210  {
211  if( _bProcessingGS ) {
212  return PE_Ignore;
213  }
214  switch( PlannerBase::PlannerParameters::startElement(name,atts) ) {
215  case PE_Pass: break;
216  case PE_Support: return PE_Support;
217  case PE_Ignore: return PE_Ignore;
218  }
219 
220  _bProcessingGS = name=="grasps"||name=="target"||name=="numgradsamples"||name=="visgraspthresh"||name=="graspdistthresh";
221  return _bProcessingGS ? PE_Support : PE_Pass;
222  }
223 
224  virtual bool endElement(const std::string& name)
225  {
226  if( _bProcessingGS ) {
227  if( name == "grasps" ) {
228  int ngrasps=0;
229  _ss >> ngrasps;
230  _vgrasps.resize(ngrasps);
231  for(std::vector<Transform>::iterator it = _vgrasps.begin(); it != _vgrasps.end(); ++it) {
232  _ss >> *it;
233  }
234  }
235  else if( name == "target" ) {
236  int id = 0;
237  _ss >> id;
238  _ptarget = _penv->GetBodyFromEnvironmentId(id);
239  }
240  else if( name == "numgradsamples" ) {
241  _ss >> _nGradientSamples;
242  }
243  else if( name == "visgraspthresh" ) {
244  _ss >> _fVisibiltyGraspThresh;
245  }
246  else if( name == "graspdistthresh") {
247  _ss >> _fGraspDistThresh;
248  }
249  else {
250  RAVELOG_WARN(str(boost::format("unknown tag %s\n")%name));
251  }
252  _bProcessingGS = false;
253  return false;
254  }
255 
256  // give a chance for the default parameters to get processed
257  return PlannerParameters::endElement(name);
258  }
259 };
260 
262 {
263 public:
264  GraspParameters(EnvironmentBasePtr penv) : PlannerBase::PlannerParameters(), fstandoff(0), ftargetroll(0), vtargetdirection(0,0,1), btransformrobot(false), breturntrajectory(false), bonlycontacttarget(true), btightgrasp(false), bavoidcontact(false), fcoarsestep(0.1f), ffinestep(0.001f), ftranslationstepmult(0.1f), fgraspingnoise(0), _penv(penv) {
265  _vXMLParameters.push_back("fstandoff");
266  _vXMLParameters.push_back("targetbody");
267  _vXMLParameters.push_back("ftargetroll");
268  _vXMLParameters.push_back("vtargetdirection");
269  _vXMLParameters.push_back("vtargetposition");
270  _vXMLParameters.push_back("vmanipulatordirection");
271  _vXMLParameters.push_back("btransformrobot");
272  _vXMLParameters.push_back("breturntrajectory");
273  _vXMLParameters.push_back("bonlycontacttarget");
274  _vXMLParameters.push_back("btightgrasp");
275  _vXMLParameters.push_back("bavoidcontact");
276  _vXMLParameters.push_back("vavoidlinkgeometry");
277  _vXMLParameters.push_back("fcoarsestep");
278  _vXMLParameters.push_back("ffinestep");
279  _vXMLParameters.push_back("ftranslationstepmult");
280  _vXMLParameters.push_back("fgraspingnoise");
281  _bProcessingGrasp = false;
282  }
283 
293  bool btightgrasp;
295  std::vector<std::string> vavoidlinkgeometry;
296 
300 
302 protected:
305  // save the extra data to XML
306  virtual bool serialize(std::ostream& O, int options=0) const
307  {
308  if( !PlannerParameters::serialize(O, options&~1) ) {
309  return false;
310  }
311  O << "<fstandoff>" << fstandoff << "</fstandoff>" << std::endl;
312  O << "<targetbody>" << (int)(!targetbody ? 0 : targetbody->GetEnvironmentId()) << "</targetbody>" << std::endl;
313  O << "<ftargetroll>" << ftargetroll << "</ftargetroll>" << std::endl;
314  O << "<vtargetdirection>" << vtargetdirection << "</vtargetdirection>" << std::endl;
315  O << "<vtargetposition>" << vtargetposition << "</vtargetposition>" << std::endl;
316  O << "<vmanipulatordirection>" << vmanipulatordirection << "</vmanipulatordirection>" << std::endl;
317  O << "<btransformrobot>" << btransformrobot << "</btransformrobot>" << std::endl;
318  O << "<breturntrajectory>" << breturntrajectory << "</breturntrajectory>" << std::endl;
319  O << "<bonlycontacttarget>" << bonlycontacttarget << "</bonlycontacttarget>" << std::endl;
320  O << "<btightgrasp>" << btightgrasp << "</btightgrasp>" << std::endl;
321  O << "<bavoidcontact>" << bavoidcontact << "</bavoidcontact>" << std::endl;
322  O << "<vavoidlinkgeometry>" << std::endl;
323  for(std::vector<std::string>::const_iterator it = vavoidlinkgeometry.begin(); it != vavoidlinkgeometry.end(); ++it) {
324  O << *it << " ";
325  }
326  O << "</vavoidlinkgeometry>" << std::endl;
327  O << "<fcoarsestep>" << fcoarsestep << "</fcoarsestep>" << std::endl;
328  O << "<ffinestep>" << ffinestep << "</ffinestep>" << std::endl;
329  O << "<ftranslationstepmult>" << ftranslationstepmult << "</ftranslationstepmult>" << std::endl;
330  O << "<fgraspingnoise>" << fgraspingnoise << "</fgraspingnoise>" << std::endl;
331  if( !(options & 1) ) {
332  O << _sExtraParameters << std::endl;
333  }
334  return !!O;
335  }
336 
337  ProcessElement startElement(const std::string& name, const AttributesList& atts)
338  {
339  if( _bProcessingGrasp ) {
340  return PE_Ignore;
341  }
342  switch( PlannerBase::PlannerParameters::startElement(name,atts) ) {
343  case PE_Pass: break;
344  case PE_Support: return PE_Support;
345  case PE_Ignore: return PE_Ignore;
346  }
347  if( name == "vavoidlinkgeometry" ) {
348  vavoidlinkgeometry.resize(0);
349  return PE_Support;
350  }
351 
352  static boost::array<std::string,16> tags = {{"fstandoff","targetbody","ftargetroll","vtargetdirection","vtargetposition","vmanipulatordirection", "btransformrobot","breturntrajectory","bonlycontacttarget","btightgrasp","bavoidcontact","vavoidlinkgeometry","fcoarsestep","ffinestep","ftranslationstepmult","fgraspingnoise"}};
353  _bProcessingGrasp = find(tags.begin(),tags.end(),name) != tags.end();
354  return _bProcessingGrasp ? PE_Support : PE_Pass;
355  }
356 
357  // called at the end of every XML tag, _ss contains the data
358  virtual bool endElement(const std::string& name)
359  {
360  // _ss is an internal stringstream that holds the data of the tag
361  if( _bProcessingGrasp ) {
362  if( name == "vavoidlinkgeometry" ) {
363  vavoidlinkgeometry = std::vector<std::string>((std::istream_iterator<std::string>(_ss)), std::istream_iterator<std::string>());
364  }
365  else if( name == "fstandoff") {
366  _ss >> fstandoff;
367  }
368  else if( name == "targetbody") {
369  int id = 0;
370  _ss >> id;
371  targetbody = _penv->GetBodyFromEnvironmentId(id);
372  }
373  else if( name == "ftargetroll") {
374  _ss >> ftargetroll;
375  }
376  else if( name == "vtargetdirection") {
377  _ss >> vtargetdirection;
378  vtargetdirection.normalize3();
379  }
380  else if( name == "vtargetposition") {
381  _ss >> vtargetposition;
382  }
383  else if( name == "vmanipulatordirection") {
384  _ss >> vmanipulatordirection;
385  }
386  else if( name == "btransformrobot") {
387  _ss >> btransformrobot;
388  }
389  else if( name == "breturntrajectory") {
390  _ss >> breturntrajectory;
391  }
392  else if( name == "bonlycontacttarget") {
393  _ss >> bonlycontacttarget;
394  }
395  else if( name == "btightgrasp" ) {
396  _ss >> btightgrasp;
397  }
398  else if( name == "bavoidcontact" ) {
399  _ss >> bavoidcontact;
400  }
401  else if( name == "fcoarsestep" ) {
402  _ss >> fcoarsestep;
403  }
404  else if( name == "ffinestep" ) {
405  _ss >> ffinestep;
406  }
407  else if( name == "fgraspingnoise" ) {
408  _ss >> fgraspingnoise;
409  }
410  else if( name == "ftranslationstepmult" ) {
411  _ss >> ftranslationstepmult;
412  }
413  else {
414  RAVELOG_WARN(str(boost::format("unknown tag %s\n")%name));
415  }
416  _bProcessingGrasp = false;
417  return false;
418  }
419 
420  // give a chance for the default parameters to get processed
421  return PlannerParameters::endElement(name);
422  }
423 };
424 
425 typedef boost::shared_ptr<GraspParameters> GraspParametersPtr;
426 typedef boost::shared_ptr<GraspParameters const> GraspParametersConstPtr;
427 
433 {
434 public:
435  TrajectoryTimingParameters() : _interpolation(""), _pointtolerance(0.2), _hastimestamps(false), _hasvelocities(false), _outputaccelchanges(true), _multidofinterp(0), _bProcessing(false) {
436  _fStepLength = 0; // reset to 0 since it is being used
437  _vXMLParameters.push_back("interpolation");
438  _vXMLParameters.push_back("hastimestamps");
439  _vXMLParameters.push_back("hasvelocities");
440  _vXMLParameters.push_back("pointtolerance");
441  _vXMLParameters.push_back("outputaccelchanges");
442  _vXMLParameters.push_back("multidofinterp");
443  }
444 
445  std::string _interpolation;
447  bool _hastimestamps, _hasvelocities;
450 
451 protected:
453  virtual bool serialize(std::ostream& O, int options=0) const
454  {
455  if( !PlannerParameters::serialize(O, options&~1) ) {
456  return false;
457  }
458  O << "<interpolation>" << _interpolation << "</interpolation>" << std::endl;
459  O << "<hastimestamps>" << _hastimestamps << "</hastimestamps>" << std::endl;
460  O << "<hasvelocities>" << _hasvelocities << "</hasvelocities>" << std::endl;
461  O << "<pointtolerance>" << _pointtolerance << "</pointtolerance>" << std::endl;
462  O << "<outputaccelchanges>" << _outputaccelchanges << "</outputaccelchanges>" << std::endl;
463  O << "<multidofinterp>" << _multidofinterp << "</multidofinterp>" << std::endl;
464  if( !(options & 1) ) {
465  O << _sExtraParameters << std::endl;
466  }
467 
468  return !!O;
469  }
470 
471  ProcessElement startElement(const std::string& name, const AttributesList& atts)
472  {
473  if( _bProcessing ) {
474  return PE_Ignore;
475  }
476  switch( PlannerBase::PlannerParameters::startElement(name,atts) ) {
477  case PE_Pass: break;
478  case PE_Support: return PE_Support;
479  case PE_Ignore: return PE_Ignore;
480  }
481 
482  _bProcessing = name=="interpolation" || name=="hastimestamps" || name=="hasvelocities" || name=="pointtolerance" || name=="outputaccelchanges" || name=="multidofinterp";
483  return _bProcessing ? PE_Support : PE_Pass;
484  }
485 
486  virtual bool endElement(const std::string& name)
487  {
488  if( _bProcessing ) {
489  if( name == "interpolation") {
490  _ss >> _interpolation;
491  }
492  else if( name == "hastimestamps" ) {
493  _ss >> _hastimestamps;
494  }
495  else if( name == "hasvelocities" ) {
496  _ss >> _hasvelocities;
497  }
498  else if( name == "pointtolerance" ) {
499  _ss >> _pointtolerance;
500  }
501  else if( name == "outputaccelchanges" ) {
502  _ss >> _outputaccelchanges;
503  }
504  else if( name == "multidofinterp" ) {
505  _ss >> _multidofinterp;
506  }
507  else {
508  RAVELOG_WARN(str(boost::format("unknown tag %s\n")%name));
509  }
510  _bProcessing = false;
511  return false;
512  }
513 
514  // give a chance for the default parameters to get processed
515  return PlannerParameters::endElement(name);
516  }
517 };
518 
519 typedef boost::shared_ptr<TrajectoryTimingParameters> TrajectoryTimingParametersPtr;
520 typedef boost::shared_ptr<TrajectoryTimingParameters const> TrajectoryTimingParametersConstPtr;
521 
523 {
524 public:
525  ConstraintTrajectoryTimingParameters() : TrajectoryTimingParameters(), maxlinkspeed(0), maxlinkaccel(0), maxmanipspeed(0), maxmanipaccel(0), mingripperdistance(0), velocitydistancethresh(0), _bCProcessing(false) {
526  _vXMLParameters.push_back("maxlinkspeed");
527  _vXMLParameters.push_back("maxlinkaccel");
528  _vXMLParameters.push_back("maxmanipspeed");
529  _vXMLParameters.push_back("maxmanipaccel");
530  _vXMLParameters.push_back("mingripperdistance");
531  _vXMLParameters.push_back("velocitydistancethresh");
532  }
533 
540 
541 protected:
543  virtual bool serialize(std::ostream& O, int options=0) const
544  {
545  if( !TrajectoryTimingParameters::serialize(O, options&~1) ) {
546  return false;
547  }
548  O << "<maxlinkspeed>" << maxlinkspeed << "</maxlinkspeed>" << std::endl;
549  O << "<maxlinkaccel>" << maxlinkaccel << "</maxlinkaccel>" << std::endl;
550  O << "<maxmanipspeed>" << maxmanipspeed << "</maxmanipspeed>" << std::endl;
551  O << "<maxmanipaccel>" << maxmanipaccel << "</maxmanipaccel>" << std::endl;
552  O << "<mingripperdistance>" << mingripperdistance << "</mingripperdistance>" << std::endl;
553  O << "<velocitydistancethresh>" << velocitydistancethresh << "</velocitydistancethresh>" << std::endl;
554  if( !(options & 1) ) {
555  O << _sExtraParameters << std::endl;
556  }
557 
558  return !!O;
559  }
560 
561  ProcessElement startElement(const std::string& name, const AttributesList& atts)
562  {
563  if( _bCProcessing ) {
564  return PE_Ignore;
565  }
566  switch( PlannerBase::PlannerParameters::startElement(name,atts) ) {
567  case PE_Pass: break;
568  case PE_Support: return PE_Support;
569  case PE_Ignore: return PE_Ignore;
570  }
571  _bCProcessing = name=="maxlinkspeed" || name =="maxlinkaccel" || name=="maxmanipspeed" || name =="maxmanipaccel" || name=="mingripperdistance" || name=="velocitydistancethresh";
572  return _bCProcessing ? PE_Support : PE_Pass;
573  }
574 
575  virtual bool endElement(const std::string& name)
576  {
577  if( _bCProcessing ) {
578  if( name == "maxlinkspeed") {
579  _ss >> maxlinkspeed;
580  }
581  else if( name == "maxlinkaccel") {
582  _ss >> maxlinkaccel;
583  }
584  else if( name == "maxmanipspeed") {
585  _ss >> maxmanipspeed;
586  }
587  else if( name == "maxmanipaccel") {
588  _ss >> maxmanipaccel;
589  }
590  else if( name == "mingripperdistance" ) {
591  _ss >> mingripperdistance;
592  }
593  else if( name == "velocitydistancethresh" ) {
594  _ss >> velocitydistancethresh;
595  }
596  else {
597  RAVELOG_WARN(str(boost::format("unknown tag %s\n")%name));
598  }
599  _bCProcessing = false;
600  return false;
601  }
602 
603  // give a chance for the default parameters to get processed
604  return PlannerParameters::endElement(name);
605  }
606 };
607 
608 typedef boost::shared_ptr<ConstraintTrajectoryTimingParameters> ConstraintTrajectoryTimingParametersPtr;
609 typedef boost::shared_ptr<ConstraintTrajectoryTimingParameters const> ConstraintTrajectoryTimingParametersConstPtr;
610 
612 {
613 public:
615  inline EnvironmentBasePtr GetEnv() const {
616  return _penv;
617  }
618 
627 
628 protected:
632 
633  virtual bool serialize(std::ostream& O, int options=0) const;
634  virtual ProcessElement startElement(const std::string& name, const AttributesList& atts);
635  virtual bool endElement(const std::string& name);
636  virtual void characters(const std::string& ch);
637 };
638 
639 typedef boost::shared_ptr<WorkspaceTrajectoryParameters> WorkspaceTrajectoryParametersPtr;
640 typedef boost::shared_ptr<WorkspaceTrajectoryParameters const> WorkspaceTrajectoryParametersConstPtr;
641 
643 {
644 public:
645  RRTParameters() : _minimumgoalpaths(1), _bProcessing(false) {
646  _vXMLParameters.push_back("minimumgoalpaths");
647  }
648 
650 
651 protected:
653  virtual bool serialize(std::ostream& O, int options=0) const
654  {
655  if( !PlannerParameters::serialize(O, options&~1) ) {
656  return false;
657  }
658  O << "<minimumgoalpaths>" << _minimumgoalpaths << "</minimumgoalpaths>" << std::endl;
659  if( !(options & 1) ) {
660  O << _sExtraParameters << std::endl;
661  }
662  return !!O;
663  }
664 
665  ProcessElement startElement(const std::string& name, const AttributesList& atts)
666  {
667  if( _bProcessing ) {
668  return PE_Ignore;
669  }
670  switch( PlannerBase::PlannerParameters::startElement(name,atts) ) {
671  case PE_Pass: break;
672  case PE_Support: return PE_Support;
673  case PE_Ignore: return PE_Ignore;
674  }
675 
676  _bProcessing = name=="minimumgoalpaths";
677  return _bProcessing ? PE_Support : PE_Pass;
678  }
679 
680  virtual bool endElement(const std::string& name)
681  {
682  if( _bProcessing ) {
683  if( name == "minimumgoalpaths") {
684  _ss >> _minimumgoalpaths;
685  }
686  else {
687  RAVELOG_WARN(str(boost::format("unknown tag %s\n")%name));
688  }
689  _bProcessing = false;
690  return false;
691  }
692 
693  // give a chance for the default parameters to get processed
694  return PlannerParameters::endElement(name);
695  }
696 };
697 
698 typedef boost::shared_ptr<RRTParameters> RRTParametersPtr;
699 
701 {
702 public:
703  BasicRRTParameters() : RRTParameters(), _fGoalBiasProb(0.05f), _bProcessing(false) {
704  _vXMLParameters.push_back("goalbias");
705  }
706 
708 
709 protected:
711  virtual bool serialize(std::ostream& O, int options=0) const
712  {
713  if( !PlannerParameters::serialize(O, options&~1) ) {
714  return false;
715  }
716  O << "<goalbias>" << _fGoalBiasProb << "</goalbias>" << std::endl;
717  if( !(options & 1) ) {
718  O << _sExtraParameters << std::endl;
719  }
720 
721  return !!O;
722  }
723 
724  ProcessElement startElement(const std::string& name, const AttributesList& atts)
725  {
726  if( _bProcessing ) {
727  return PE_Ignore;
728  }
729  switch( PlannerBase::PlannerParameters::startElement(name,atts) ) {
730  case PE_Pass: break;
731  case PE_Support: return PE_Support;
732  case PE_Ignore: return PE_Ignore;
733  }
734 
735  _bProcessing = name=="goalbias";
736  return _bProcessing ? PE_Support : PE_Pass;
737  }
738 
739  virtual bool endElement(const std::string& name)
740  {
741  if( _bProcessing ) {
742  if( name == "goalbias") {
743  _ss >> _fGoalBiasProb;
744  }
745  else {
746  RAVELOG_WARN(str(boost::format("unknown tag %s\n")%name));
747  }
748  _bProcessing = false;
749  return false;
750  }
751 
752  // give a chance for the default parameters to get processed
753  return PlannerParameters::endElement(name);
754  }
755 };
756 
757 typedef boost::shared_ptr<BasicRRTParameters> BasicRRTParametersPtr;
758 
759 } // OpenRAVE
760 
761 #endif