===== T3a-sampl - Randomized sampling-based algorithms - Probabilistic Roadmap ====== The main task is to learn the basic principles of randomized sampling-based planning. The principles are demonstrated on the multi-query planning algorithm - the Simplified Probabilistic Roadmap (sPRM). |**Due date** | December 10, 2023, 23:59 PST | |**Deadline** | January 13, 2024, 23:59 PST | |**Points** | 3 | |**Label in BRUTE** | t3a-sampl | |**Files to submit** | archive with the ''PRMPlanner.py'' file | |**Resources** | {{:courses:uir:hw:b4m36uir_23_t3_resource_pack.zip | B4M36UIR_t3_resource_pack}} | ---- ===Installation=== - Compile rapid library by ''make'' in ''environment/rapid'' library. - Install [[https://pypi.org/project/Dijkstar/ | Dijkstar ]] package to python3. pip3 install Dijkstar # or our favorite way to install the package ===Assignment=== In class ''PRMPlanner.py'' implement the Simplified Probabilistic Roadmap (sPRM) randomized sampling-based path planning algorithm according to the description and pseudocode presented in the {{:courses:uir:lectures:b4m36uir-lec09-slides.pdf |Lecture 09}}. {{:courses:uir:hw:sprm.png?350|}} The planner is invoked using the method ''plan'' and shall provide a collision free path through an environment represented by a geometrical map. The input parameters of the function ''plan'' are: - ''environment'' - Environment - geometric representation of the environment and robot together with the wrapper for RAPID collision checking library * represents robot and environment * check for collision between the robot and the environment using function ''environment.check_robot_collision(P)'' where ''P'' is ''Pose'' message. Returns ''True'' if the Robot at pose ''P'' collides with the obstacle. * contains environment dimensions in ''environment.limits_x'', ''environment.limits_y'', ''environment.limits_z'' float constants - ''start'' - [[courses:uir:hw:support:messages|Pose message]] - the start pose of the robot. - ''goal'' - [[courses:uir:hw:support:messages|Pose message]] - the desired goal pose of the robot. - ''space'' - Type of configuration space ("R2", "SE(2)", "R3", "SE(3)"). - ''number_of_samples'' - Number of samples to be generated. - ''neighborhood_radius'' - Neighborhood radius to connect samples [s]. - ''collision_step'' - Minimum step to check collisions [s]. The function returns: - the [[courses:uir:hw:support:messages|Path message]] with the found path or ''None'' when the path cannot be found. The individual poses of the path shall not be further than ''collision_step''. - the [[courses:uir:hw:support:messages|NavGraph message]] representing the underlying navigation graph constructed by the method from which the resulting path is reconstructed. For easier implementation, several functions are already implemented in the ''PRMPlanner'' class. You may utilize them in your solution. The detailed description of the recommended approach is in the next section. In class ''PRMPlanner.py'' you may change whatever you want. In evaluation, the given interfaces are fixed and the evaluation script is fixed. After downloading the resource pack, please build the [[http://gamma.cs.unc.edu/OBB/ | RAPID]] collision checking library in the ''environment/rapid'' directory using the provided ''Makefile''. The ''Environment'' class provides the wrapper for the RAPID library which is used for checking the sampled robot poses for collision with the obstacles in the environment. An example of the running sPRM can be seen in the following images. From left to right: Environment with robot and obstacles. Constructed navigation graph. Final path and its execution. ---- {{:courses:uir:hw:t3a_env.png?300|}} {{:courses:uir:hw:t3a_navgraph.png?300|}} {{:courses:uir:hw:t3a_path.png?300|}} ---- === Environment representation and RAPID collision checking library === The sPRM algorithm is demonstrated in the continuous geometric space, which is a different representation of the environment in comparison to the [[courses:uir:hw:support:messages|OccupancyGrid message]], i.e., the probabilistic occupancy grid map, used in the previous tasks. In the geometric space we need a way to evaluate the robot interference with the environment using collision checking. There are multiple collision checking libraries available, (++ e.g. | , [[https://sourceforge.net/projects/coldet/|Coldet]], [[https://pybullet.org/wordpress/ | BULLET]], [[https://developer.nvidia.com/gameworks-physx-overview | Nvidia PhysX]], [[https://github.com/flexible-collision-library/fcl/commit/ff8324929fdf76d6646d7b90c221a6a5bda438d8 | FCL]], [[http://gamma.cs.unc.edu/OBB/ | RAPID]] , [[https://github.com/jslee02/awesome-collision-detection | etc]]. They all differ in the performance, collision checking approach and precision.++ ). In UIR we are using the [[http://gamma.cs.unc.edu/OBB/ | RAPID]] collision checking library which is sufficiently precise, fast and easy to install. The provided ''Environment'' class within the resource pack contains the representation of the planning scenarios and wrapper for the RAPID library. Take a moment and think about the robot embodiment in the geometrical space. ++ More info. | The approach for occupancy grid maps is obstacle growing which works somehow similar in geometrical space. It is necessary to inflate the obstacles which may be done, e.g., by scaling up the objects or the robot.++ /* ===Approach=== The recommended approach for the Simplified Probabilistic roadmap (sPRM) implementation follows the description provided in the lecture {{:courses:uir:lectures:b4m36uir-lec08-slides.pdf |Lecture 08}}. The sPRM is a multi-query randomized sampling algorithm that constructs a navigation graph $\mathcal{G} = (V, E)$ with $V$ vertices and $E$ edges. The following steps lead to construction of the graph $\mathcal{G}$ and subsequent shortest path discovery: * $V \leftarrow$''sample_points'' from the configuration space of the robot. ++++ $\qquad\bullet\,$ Detailed description and guidance for the step (click to view)| Note, the internal representation of the vertices $V$ is not given. It has to cope with the task and it should represent the configuration space of the robot. that the sampling can be done in any way ++++ * for each vertex $v \in V$: * $U \leftarrow $''find_neighbors''$(v)$ * for each $u \in U$: * if ''collision_free''$(v,u)$ then * $E$ ''append''($(u,v)$,$(v,u)$) ++++ $\qquad\bullet\,$ Detailed description and guidance for the step (click to view)| It is necessary to correctly sample the intermittent motion. ++++ * calculate the shortest path in the resulting graph $\mathcal{G} = (V,E)$ ++++ $\qquad\bullet\,$ Detailed description and guidance for the step (click to view)| This step only requires applying any graph-planning algorithm to find the shortest path in the graph. The most interesting part here is how to determine the distance metric in the geometric space we are using. ++++ * reconstruct the path with the given granularity ++++ $\qquad\bullet\,$ Detailed description and guidance for the step (click to view)| It is only necessary to traverse goal-by-goal the path found in the previous step and apply the interpolation which has been used in the first step of the construction of the navigation graph when connecting the vertices in $V$ by edges $E$. ++++ ---- */ ===References=== [[https://en.wikipedia.org/wiki/Gimbal_lock|Gimbal lock]] [[https://en.wikipedia.org/wiki/Slerp|Slerp - spherical linear interpolation]]