Sophie

Sophie

distrib > Fedora > 14 > x86_64 > media > updates > by-pkgid > e7618febbb9cbed15bb79e326774c050 > files > 1308

ompl-devel-0.9.5-1.fc14.i686.rpm

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml; charset=UTF-8"/>
<title>OMPL: Representing goals in OMPL</title>
<meta name="author" content="Ioan A. Șucan, Mark Moll, Lydia E. Kavraki">
<link rel="stylesheet" href="../css/screen.css" type="text/css" media="screen, projection">
<link rel="stylesheet" href="../css/print.css" type="text/css" media="print">
<!--[if lt IE 7]>
<script type="text/javascript" src="../js/jquery/jquery.js"></script>
<script type="text/javascript" src="../js/jquery/jquery.dropdown.js"></script>
<![endif]-->
<script type="text/javaScript" src="search/search.js"></script>
<script type="text/javascript">
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-9156598-2']);
  _gaq.push(['_trackPageview']);
  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();
</script>
</head>
<body onload='searchBox.OnSelectItem(0);'>
<script type="text/javascript"><!--
var searchBox = new SearchBox("searchBox", "search",false,'Search API');
--></script>
<div class="navigation" id="top">
  <div class="tabs" id="ompltitle">
    <ul class="tablist">
      <li>The Open Motion Planning Library</li>
      <li id="searchli">
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search API" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)"
               onblur="searchBox.OnSearchFieldFocus(false)"
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>

  <ul id="nav" class="dropdown">
    <li class="first"><a href="index.html">Home</a></li>
    <li><a href="download.html">Download</a></li>
    <li><a href="documentation.html">Documentation</a></li>
    <li><span class="dir">Code API</span>
      <ul>
        <li><a href="api_overview.html">API Overview</a></li>
        <li><a href="namespaces.html">Namespaces</a></li>
        <li><a href="annotated.html">Classes</a></li>
        <li><a href="files.html">Files</a></li>
        <li><a href="dirs.html">Directories</a></li>
      </ul>
    </li>
    <li><span class="dir">Community</span>
      <ul>
        <li><a href="developers.html">Developers</a></li>
        <li><a href="thirdparty.html">Contributions</a></li>
        <li><a href="education.html">Education</a></li>
        <li><a href="gallery.html">Gallery</a></li>
      </ul>
    </li>
    <li><span class="dir">About</span>
      <ul>
        <li><a href="license.html">License</a></li>
        <li><a href="citations.html">Citations</a></li>
        <li><a href="acknowledgements.html">Acknowledgments</a></li>
        <li><a href="contact.html">Contact Us</a></li>
      </ul>
    </li>
  </ul>
</div>

<!--- window showing the filter options -->
<div id="MSearchSelectWindow"
  onmouseover="return searchBox.OnSearchSelectShow()"
  onmouseout="return searchBox.OnSearchSelectHide()"
  onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Namespaces</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>Typedefs</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&#160;</span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark">&#160;</span>Enumerator</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
  <iframe src="" frameborder="0"name="MSearchResults" id="MSearchResults"></iframe>
</div>

<div class="container">
  <div class="span-22 push-2 first last">
  <div>
<!-- Generated by Doxygen 1.7.4 -->
<script type="text/javascript"><!--
var searchBox = new SearchBox("searchBox", "search",false,'Search');
--></script>
</div>
<div class="header">
  <div class="headertitle">
<div class="title">Representing goals in OMPL </div>  </div>
</div>
<div class="contents">
<div class="textblock"><h2><a class="anchor" id="settingGoalRegion"></a>
Setting the goal</h2>
<p>The most general representation of a goal is <a class="el" href="classompl_1_1base_1_1Goal.html" title="Abstract definition of goals. Will contain solutions, if found.">ompl::base::Goal</a>. This class contains a pure virtual method, <a class="el" href="classompl_1_1base_1_1Goal.html#a02ba4ba487714cd4e8f67c9d4164d0ec" title="Return true if the state satisfies the goal constraints.">ompl::base::Goal::isSatisfied()</a>, which takes a state as argument and returns a boolean indicating whether that state is a goal or not. No other information about the goal is given. This function can include arbitrary code deciding what is in the goal region and what is not. </p>
<div class="fragment"><pre class="fragment"><span class="keyword">class </span>MyArbitraryGoal : <span class="keyword">public</span> ompl::base::Goal
{
<span class="keyword">public</span>:
    MyArbitraryGoal(<span class="keyword">const</span> SpaceInformationPtr &amp;si) : ompl::base::Goal(si)
    {
    }

    <span class="keyword">virtual</span> <span class="keywordtype">bool</span> isSatisfied(<span class="keyword">const</span> State *st)<span class="keyword"> const</span>
<span class="keyword">    </span>{
        <span class="comment">// perform any operations and return a truth value</span>
    }
};
</pre></div><p>While this is a very general definition, it is often the case more information is known about the goal. This information is helpful for planners and the user should specify this information when available. Here are types of information planners can use:</p>
<ul>
<li>If an approximation of distance to the goal is available, not necessarily a metric, this information can be given to the planner by also providing an implementation of <a class="el" href="classompl_1_1base_1_1Goal.html#a02ba4ba487714cd4e8f67c9d4164d0ec" title="Return true if the state satisfies the goal constraints.">ompl::base::Goal::isSatisfied()</a> (the version that takes a <a class="el" href="classompl_1_1base_1_1State.html" title="Definition of an abstract state.">ompl::base::State</a>* and a double* as arguments). By default, the implementation of this function simply sets the distance to the maximum value a double can hold. <div class="fragment"><pre class="fragment"><span class="keyword">class </span>MyArbitraryGoal : <span class="keyword">public</span> ompl::base::Goal
{
<span class="keyword">public</span>:
    MyArbitraryGoal(<span class="keyword">const</span> SpaceInformationPtr &amp;si) : ompl::base::Goal(si)
    {
    }

    <span class="keyword">virtual</span> <span class="keywordtype">bool</span> isSatisfied(<span class="keyword">const</span> State *st)<span class="keyword"> const</span>
<span class="keyword">        </span>{
        perform_any_operations();
        <span class="keywordflow">return</span> truth value;
    }

    <span class="keyword">virtual</span> <span class="keywordtype">bool</span> isSatisfied(<span class="keyword">const</span> State *st, <span class="keywordtype">double</span> *distance)<span class="keyword"> const</span>
<span class="keyword">        </span>{
        <span class="keywordtype">bool</span> result = isSatisfied(st);

        <span class="keywordflow">if</span> (distance != NULL)
        {
            <span class="keywordflow">if</span> (state_clearly_out_of_goal_region(st))
                    {
                *distance = std::numeric_limits&lt;double&gt;::max();
            }
            <span class="keywordflow">else</span>
            {
                <span class="keywordflow">if</span> (state_near_goal(st))
                    *distance = 1;
                <span class="keywordflow">else</span>
                    *distance = 100;
            }
        }
        <span class="keywordflow">return</span> result;
    }
};
</pre></div></li>
</ul>
<ul>
<li>It is often the case that when distance to goal approximations are available, the condition for a state being in the goal region is that that distance is less than a specified threshold. If this is indeed the case, <a class="el" href="classompl_1_1base_1_1GoalRegion.html" title="Definition of a goal region.">ompl::base::GoalRegion</a> (which inherits from <a class="el" href="classompl_1_1base_1_1Goal.html" title="Abstract definition of goals. Will contain solutions, if found.">ompl::base::Goal</a>) should be used. The additional function <a class="el" href="classompl_1_1base_1_1GoalRegion.html#a4c7a9ab388d762c76711790af0ba53ea" title="Compute the distance to the goal (heuristic). This function is the one used in computing the distance...">ompl::base::GoalRegion::distanceGoal()</a> needs to be implemented. However, all the versions of <a class="el" href="classompl_1_1base_1_1Goal.html#a02ba4ba487714cd4e8f67c9d4164d0ec" title="Return true if the state satisfies the goal constraints.">ompl::base::Goal::isSatisfied()</a> are implemented in terms of this new function and a specified threshold (which is equal to the machine epsilon, by default). <div class="fragment"><pre class="fragment"><span class="keyword">class </span>MyGoalRegion : <span class="keyword">public</span> ompl::base::GoalRegion
{
<span class="keyword">public</span>:
    MyGoalRegion(<span class="keyword">const</span> SpaceInformationPtr &amp;si) : ompl::base::GoalRegion(si)
    {
        setThreshold(0.1);
    }

    <span class="keyword">virtual</span> <span class="keywordtype">double</span> distanceGoal(<span class="keyword">const</span> State *st)<span class="keyword"> const</span>
<span class="keyword">        </span>{
        <span class="comment">// perform any operations and return a double indicating the distance to the goal</span>
    }
};
</pre></div></li>
</ul>
<ul>
<li>For bi-directional planners to work, they need to know states in the goal region. If a means to sample the goal region is available, <a class="el" href="classompl_1_1base_1_1GoalSampleableRegion.html" title="Abstract definition of a goal region that can be sampled.">ompl::base::GoalSampleableRegion</a> should be used. This class, which inherits from <a class="el" href="classompl_1_1base_1_1GoalRegion.html" title="Definition of a goal region.">ompl::base::GoalRegion</a>, defines two additional functions: <a class="el" href="classompl_1_1base_1_1GoalSampleableRegion.html#a11c9d2c4d9d5ddbeb8c30e531d1efc5f" title="Sample a state in the goal region.">ompl::base::GoalSampleableRegion::sampleGoal()</a> and <a class="el" href="classompl_1_1base_1_1GoalSampleableRegion.html#a155c0de80eb09a969d6f3dce2093fdc5" title="Return the maximum number of samples that can be asked for before repeating.">ompl::base::GoalSampleableRegion::maxSampleCount()</a>. These functions allow the planners to sample goals and to tell how many different samples can be obtained in the goal region at most, respectively. Keep in mind that <a class="el" href="classompl_1_1base_1_1GoalRegion.html#a4c7a9ab388d762c76711790af0ba53ea" title="Compute the distance to the goal (heuristic). This function is the one used in computing the distance...">ompl::base::GoalRegion::distanceGoal()</a> still needs to be implemented.<br/>
 At this point, it is interesting to remark that bi-directional planners do not need to check whether a state is in the goal region, since they start with such states, so calls to <a class="el" href="classompl_1_1base_1_1Goal.html#a02ba4ba487714cd4e8f67c9d4164d0ec" title="Return true if the state satisfies the goal constraints.">ompl::base::Goal::isSatisfied()</a> are not made. Instead, when the trees are connected, a call is made to <a class="el" href="classompl_1_1base_1_1Goal.html#a5d5285908b7e09d61577279f35e47175" title="Since there can be multiple starting states (and multiple goal states) it is possible certain pairs a...">ompl::base::Goal::isStartGoalPairValid()</a>. This function, which by default always returns true, tells the planner whether a particular start state should be considered as forming a valid path if connected to a particular goal state. Typically, changing this function is not needed. There are a few implementations of <a class="el" href="classompl_1_1base_1_1GoalSampleableRegion.html" title="Abstract definition of a goal region that can be sampled.">ompl::base::GoalSampleableRegion</a> available, for convenience:<ul>
<li><a class="el" href="classompl_1_1base_1_1GoalState.html" title="Definition of a goal state.">ompl::base::GoalState</a> (inherits from <a class="el" href="classompl_1_1base_1_1GoalSampleableRegion.html" title="Abstract definition of a goal region that can be sampled.">ompl::base::GoalSampleableRegion</a>) stores one state as the goal. Sampling the goal state will always return this state and the distance to the goal is implemented by calling <a class="el" href="classompl_1_1base_1_1StateSpace.html#acb781becdcdf8770d61c218632c71bd5" title="Computes distance to between two states. This function satisfies the properties of a metric and its r...">ompl::base::StateSpace::distance()</a> between the stored goal state and the state passed to <a class="el" href="classompl_1_1base_1_1GoalRegion.html#a4c7a9ab388d762c76711790af0ba53ea" title="Compute the distance to the goal (heuristic). This function is the one used in computing the distance...">ompl::base::GoalRegion::distanceGoal()</a>.</li>
<li><a class="el" href="classompl_1_1base_1_1GoalStates.html" title="Definition of a set of goal states.">ompl::base::GoalStates</a> (inherits from <a class="el" href="classompl_1_1base_1_1GoalSampleableRegion.html" title="Abstract definition of a goal region that can be sampled.">ompl::base::GoalSampleableRegion</a>) is a generalization of <a class="el" href="classompl_1_1base_1_1GoalState.html" title="Definition of a goal state.">ompl::base::GoalState</a>. An array of goal states is stored. Sampling goals will cycle through the stored states. The implementation <a class="el" href="classompl_1_1base_1_1GoalRegion.html#a4c7a9ab388d762c76711790af0ba53ea" title="Compute the distance to the goal (heuristic). This function is the one used in computing the distance...">ompl::base::GoalRegion::distanceGoal()</a> will return the minimum distance between the state passed as argument and the stored states. This computation is performed in linear time (in terms of number of stored states), so it may become costly for a large number of states.</li>
<li><a class="el" href="classompl_1_1base_1_1GoalLazySamples.html" title="Definition of a goal region that can be sampled, but the sampling process can be slow. This class allows sampling the happen in a separate thread, and the number of goals may increase, as the planner is running, in a thread-safe manner.">ompl::base::GoalLazySamples</a> (inherits from <a class="el" href="classompl_1_1base_1_1GoalStates.html" title="Definition of a set of goal states.">ompl::base::GoalStates</a>). In case sampling of states is a time consuming process, this version of a goal allows the sampling process to take place in a separate thread, while the planner is running. As new states are found, they are added to the array of stored states. This is useful for example when performing inverse kinematics for an arm. The inverse kinematics computations can be performed while the planner is running. As more states are found, they become available to the planner.</li>
</ul>
</li>
</ul>
<h2><a class="anchor" id="usingGoalRegion"></a>
Using the goal region</h2>
<p>Planners cast the specified goal representation into the minimal representation they can use. For uni-directional planners, <a class="el" href="classompl_1_1base_1_1Goal.html" title="Abstract definition of goals. Will contain solutions, if found.">ompl::base::Goal</a> is fine. For bi-directional planners however, this needs to be <a class="el" href="classompl_1_1base_1_1GoalSampleableRegion.html" title="Abstract definition of a goal region that can be sampled.">ompl::base::GoalSampleableRegion</a>.</p>
<p>If the planner can use the goal specification, it will compute a motion plan. If successful, the found path is stored in the goal region. Flags indicating whether the solution was approximate are also set. The user can query all the information the planner has set using accessors from <a class="el" href="classompl_1_1base_1_1Goal.html" title="Abstract definition of goals. Will contain solutions, if found.">ompl::base::Goal</a>.</p>
<p>Planners that include the notion of path length, and attempt to find solution paths that are shorter, also make use of a third version of <a class="el" href="classompl_1_1base_1_1Goal.html#a02ba4ba487714cd4e8f67c9d4164d0ec" title="Return true if the state satisfies the goal constraints.">ompl::base::Goal::isSatisfied()</a>, the one that takes a path length as argument as well. This version decides whether a maximum path length is met. The user can set this maximum length by calling <a class="el" href="classompl_1_1base_1_1Goal.html#a19445b2688918bf9e402f3f9472a63df" title="Set the maximum length allowed for a solution path. This value is checked only in the version of isSa...">ompl::base::Goal::setMaximumPathLength()</a>. </p>
</div></div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Namespaces</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>Typedefs</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&#160;</span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark">&#160;</span>Enumerator</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

</div>

<div class="footer span-22 push-2 last">
  <a href="http://www.kavrakilab.org">Physical and Biological Computing Group</a> &bull;
  <a href="http://www.cs.rice.edu">Department of Computer Science</a> &bull;
  <a href="http://www.rice.edu">Rice University</a><br>
  <div class="gray">Generated on Sun Oct 9 2011 23:04:41 by&#160;<a href="http://www.doxygen.org/index.html">doxygen</a> 1.7.4</div>
</div>
</div>
</body>
</html>