hpp_tutorial
4.9.0
Tutorial for humanoid path planner platform.
|
The code of this tutorial can be found in src/tutorial.cc
. The compilation and installation instructions can be found in CMakeLists.txt
.
File src/tutorial_2.cc
implements class
hpp::tutorial::Planner, deriving from abstract class hpp::core::PathPlanner. In this section, we explain some specific parts of the code.
is a macro containing the forward declaration of class Planner
as well as PlannerWkPtr_t
for weak pointer to class Planner
. See hpp/util/pointer.hh
for details.
As most classes, hpp::core::PathPlanner and any derived class are manipulated via shared pointers. Users are not allowed to define variables of the type. Instead, they are required to call method create
and to store the resulting shared pointer. For this reason, the constructors are all protected.
create
calls protected method init
that is explained later on.This method runs one step of our the algorithm. The new algorithm is a basic version of PRM. Notice the compactness of the code.
Method init
takes as input a weak pointer to a new instance and stores this weak pointer as a private member. This enables any object to create a shared pointer to itself on demand using the following line of code
which is the shared pointer equivalent to this
when using simple pointers.
init
always calls the parent implementation so that the parent part of the object also stores a weak pointer to itself.Now that the new class hpp::tutorial::Planner
has been implemented, we are going to use it in a new executable. The new executable is defined by
This executable creates an instance of hpp::core::ProblemSolver,
adds the constructor of class hpp::tutorial::Planner in the map of the ProblemSolver instance with key "PRM",
creates a CORBA server with the ProblemSolver instance,
starts the CORBA server, and
process client requests forever.
The compilation and installation is done in file CMakeLists.txt
by the following lines
To run your executable and solve a problem with your path planning algorithm, you simply need to follow the same steps as in tutorial 1, except that you should start
instead of hppcorbaserver
and source script/tutorial_2.py
instead of script/tutorial_1.py
, or make sure that you add the following line before solving the problem
To implement the above executable in an external package, you should do the following steps.
src
, for instance README.md
describing the new package Doxyfile.extra.in
file cmake
code into my-hpp-project/CMakeLists.txt
, after replacing names by the names you have chosen, src/tutorial.cc
into my-hpp-project/src
Go into the project directory and initialize git. Import the cmake git sub-module The package is ready for installation. Create a build directory
configure and install
Executable hpp-tutorial-2-server
is installed and can be run from the terminal.