Skip to content

Commit 788d1d5

Browse files
committed
Clarified the different planning methods in the documentation.
1 parent 798fdc9 commit 788d1d5

File tree

1 file changed

+39
-17
lines changed

1 file changed

+39
-17
lines changed

README.md

Lines changed: 39 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,25 @@ two subclasses:
2727

2828
Each planner has one or more *planning methods*, annotated with either the
2929
`@LockedPlanningMethod` or `@ClonedPlanningMethod decorator, that look like
30-
ordinary functions. However, unlike an ordinary function, calling a planning
31-
method either locks the robot environment or clones the robot's environment
32-
into a *planning environment* associated with the planner. Planning occurs in
33-
the locked or cloned environment to allow PrPy to run multiple planners in
34-
parallel and to paralellize planning and execution. In general, locked
35-
planning methods are used for calls that will terminate extremely quickly,
36-
while cloned planning methods are used for calls that might take a significant
37-
amount of time.
30+
ordinary functions. Using these decorators makes other PrPy components
31+
aware that these methods exist and follow a particular specification that
32+
allows them to be composed with other PrPy objects automatically. For
33+
example, `MetaPlanner`s will report that they can perform planning methods
34+
that their child motion planners have enumerated via `@PlanningMethod`
35+
decorators.
36+
37+
`@PlanningMethod` decorators also make sure that calls to planning code are
38+
executed in a thread-safe manner. In the case of `@LockedPlanningMethod`,
39+
this is enforced by locking the calling environment until the planning method
40+
has completed. In the case of `@ClonedPlanningMethod`, this is enforced by
41+
cloning the calling environment, and calling the wrapped method with references
42+
to the cloned environment. The result of the method is then copied back to the
43+
calling environment. `@ClonedPlanningMethod`s can be used to run multiple
44+
planners in parallel and to parallelize planning and execution.
45+
46+
In general, **locked** planning methods are used for calls that will terminate
47+
extremely quickly, while **cloned** planning methods are used for calls that
48+
might take a significant amount of time.
3849

3950
For example, the following code will use OMPL to plan `robot`'s active DOFs
4051
from their current values to to the `goal_config` configuration:
@@ -117,23 +128,34 @@ of these methods accept planner-specific keyword arguments.
117128

118129
Implementing a custom planner requires extending the `BasePlanner` class and
119130
decorating one or more methods with the `@LockedPlanningMethod` or
120-
`@ClonedPlanningMethod` decorator. Extending the `BasePlanner` class constructs
121-
the planning environment `self.env` and allows PrPy to identify your planner
122-
as a base planner class, as opposed to a meta-planner. The `@*PlanningMethod`
131+
`@ClonedPlanningMethod` decorator.
132+
133+
Extending the `BasePlanner` class allows PrPy to identify your planner as a
134+
base planner class, as opposed to a meta-planner. The `@PlanningMethod`
123135
decorators handle environment cloning or locking and allows meta-planners to
124136
query the list of planning methods that the planner supports (e.g. to generate
125137
docstrings).
126138

139+
Each instance of a `BasePlanner`-derived class constructs a planning
140+
environment `self.env`. This environment is uniquely associated with each
141+
instance of the planner and is what will be used in `@ClonedPlanningMethod`
142+
calls. Since this environment is persistent and unique, it can also be used
143+
as a place to cache data or pre-load plugins for planners that have heavyweight
144+
initialization steps. However, because of this, each planning instance can
145+
only execute one `@ClonedPlanningMethod` at a time. It can still execute
146+
arbitrary `@LockedPlanningMethod` calls, as long as they are referring to
147+
robots in different environments.
148+
127149
Please obey the following guidelines:
128150

129-
- Assume that the environment is locked during the entire call.
151+
- Assume that the planning environment is locked during the entire call.
130152
- Subclass constructors **must** call `BasePlanner.__init__`.
131-
- Each `@*PlanningMethod` **must** accept the first argument `robot`, which is a
132-
robot in the cloned environment.
133-
- Each `@*PlanningMethod` **must** accept `**kwargs` to ignore arguments that
153+
- Each `@PlanningMethod` **must** accept the first argument `robot`, which is a
154+
robot in the environment it should be using to perform planning.
155+
- Each `@PlanningMethod` **must** accept `**kwargs` to ignore arguments that
134156
are not supported by the planner.
135-
- Each `@*PlanningMethod` **must** return a `Trajectory` which was created in
136-
the cloned environment.
157+
- Each `@PlanningMethod` **must** return a `Trajectory` which was created in
158+
the same environment as the robot it was passed (e.g. `robot.GetEnv()`).
137159
- When possible, use one of the defacto-standard `@*PlanningMethod` names listed
138160
below.
139161
- Raise a `PlanningError` to indicate an expected, but fatal, error (e.g.

0 commit comments

Comments
 (0)