<commit_before>*********************
Manual Initialization
*********************

Manual initialization encapsulates all initialisation and handling of
EXOTica within C++ or Python code, with no external XML files. This could
be preferred if your project has been finalized or if you prefer to have all your EXOTica code in one place.

In this tutorial, we will use the `example of manual initialization <https://github.com/ipab-slmc/exotica/blob/master/exotica_examples/src/generic.cpp>`__ for
the UnconstrainedEndPoseProblem found in the ``exotica_examples`` package:

.. code-block:: c++

    #include <exotica_core/exotica_core.h>

    // Manual initialization requires dependency on specific solvers and task maps:
    #include <exotica_ik_solver/ik_solver_initializer.h>
    #include <task_map/eff_frame_initializer.h>

    using namespace exotica;

    void run()
    {
        Server::InitRos(std::shared_ptr<ros::NodeHandle>(new ros::NodeHandle("~")));

        // Scene using joint group 'arm'
        SceneInitializer scene("MyScene", "arm", false, "", "{exotica_examples}/resources/robots/lwr_simplified.urdf", "{exotica_examples}/resources/robots/lwr_simplified.srdf");
        // End-effector task map with two position frames
        EffFrameInitializer map("Position", false,
                    {FrameInitializer("lwr_arm_6_link", Eigen::VectorTransform(0, 0, 0, 0.7071067811865476, -4.3297802811774664e-17, 0.7071067811865475, 4.3297802811774664e-17))});
        // Create a task using the map above (goal will be specified later)
        Eigen::VectorXd W(7);
        W << 7, 6, 5, 4, 3, 2, 1;

        UnconstrainedEndPoseProblemInitializer problem("MyProblem", scene, false, {map}, W);
        IKSolverInitializer solver("MySolver");
        solver.C = 1e-3;
        solver.MaxIterations = 1;
        solver.MaxStep = 0.1;
    ...

.. rubric:: CODE EXPLAINED

Initializer Headers
===================

At the top of the script, two initialiser header files are included: one
for the ``exotica_ik_solver/ik_solver_initializer.h`` and one for
``exotica_core_task_maps/eff_position_initializer.h``. These are generated from the ``.in`` files during the compilation/build phase.

When initializing manually, the appropriate initializers must be
included for both the task map and the solver. These are stored in the
``exotations`` directory under ``task_maps`` and ``solvers``
respectively.

Currently available solvers are:

.. code-block:: c++

    #include <exotica_ompl_solver/ompl_solver_initializer.h>
    #include <exotica_aico_solver/aico_solver_initializer.h>
    #include <exotica_ik_solver/ik_solver_initializer.h>

Once we have included the correct initializers, we must initialise:
* ``scene`` 
* ``map`` 
* ``problem`` <commit_msg>[doc] updated for new manual initialization Python example<commit_after>*********************
Manual Initialization
*********************

Manual initialization encapsulates all initialisation and handling of
EXOTica within C++ or Python code, with no external XML files. This could
be preferred if your project has been finalized or if you prefer to have all your EXOTica code in one place.

An `example of manual initialization <https://github.com/ipab-slmc/exotica/blob/master/exotica_examples/scripts/example_ik_manual_initialization>`__  in Python can be found in the ``scripts`` directory of the ``exotica_examples`` package. In this tutorial, we will use the `example of manual initialization <https://github.com/ipab-slmc/exotica/blob/master/exotica_examples/src/generic.cpp>`__ for the UnconstrainedEndPoseProblem written in C++, found in the ``src`` directory of the ``exotica_examples`` package:

.. code-block:: c++

    #include <exotica_core/exotica_core.h>

    // Manual initialization requires dependency on specific solvers and task maps:
    #include <exotica_ik_solver/ik_solver_initializer.h>
    #include <task_map/eff_frame_initializer.h>

    using namespace exotica;

    void run()
    {
        Server::InitRos(std::shared_ptr<ros::NodeHandle>(new ros::NodeHandle("~")));

        // Scene using joint group 'arm'
        SceneInitializer scene("MyScene", "arm", false, "", "{exotica_examples}/resources/robots/lwr_simplified.urdf", "{exotica_examples}/resources/robots/lwr_simplified.srdf");
        // End-effector task map with two position frames
        EffFrameInitializer map("Position", false,
                    {FrameInitializer("lwr_arm_6_link", Eigen::VectorTransform(0, 0, 0, 0.7071067811865476, -4.3297802811774664e-17, 0.7071067811865475, 4.3297802811774664e-17))});
        // Create a task using the map above (goal will be specified later)
        Eigen::VectorXd W(7);
        W << 7, 6, 5, 4, 3, 2, 1;

        UnconstrainedEndPoseProblemInitializer problem("MyProblem", scene, false, {map}, W);
        IKSolverInitializer solver("MySolver");
        solver.C = 1e-3;
        solver.MaxIterations = 1;
        solver.MaxStep = 0.1;
    ...
    
.. rubric:: CODE EXPLAINED

Initializer Headers
===================

At the top of the script, two initialiser header files are included: one
for the ``exotica_ik_solver/ik_solver_initializer.h`` and one for
``exotica_core_task_maps/eff_position_initializer.h``. These are generated from the ``.in`` files during the compilation/build phase.

When initializing manually, the appropriate initializers must be
included for both the task map and the solver. These are stored in the
``exotations`` directory under ``task_maps`` and ``solvers``
respectively.

Currently available solvers are:

.. code-block:: c++

    #include <exotica_ompl_solver/ompl_solver_initializer.h>
    #include <exotica_aico_solver/aico_solver_initializer.h>
    #include <exotica_ik_solver/ik_solver_initializer.h>

Once we have included the correct initializers, we must initialise:
* ``scene`` 
* ``map`` 
* ``problem`` 
{'fraction_non_alphanumeric': 0.12134677832849086, 'fraction_numerical': 0.030422150059818836, 'mean_word_length': 4.295927601809955, 'pattern_counts': {'":': 0, '<': 24, '<?xml version=': 0, '>': 20, 'https://': 3, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2540513', 'n_tokens_mistral': 1962, 'n_tokens_neox': 1771, 'n_words': 523}