# Robot Operating System 2 (ROS2)-Based Frameworks for Increasing Robot Autonomy: A Survey
## Planning Scene Monitor
### Trajectory Planning  
In ROS2, the trajectory planning module, which is responsible for planning a feasible global trajectory to move the robot from a starting point to a goal pose, can be implemented by leveraging MoveIt 2, the direct porting in ROS2 of the previous version MoveIt [102]. It is a set of ROS packages that constitute a motion planning framework that provides APIs and graphical tools to help solve standard problems relating to motion planning, collision avoidance, and also manipulation. Its main strength lies in providing both off-the-shelf solutions that implement state-of-the-art algorithms and a general framework that can be customized by developing its own algorithms. The core of this framework is the node _move_group_, responsible for pulling all the individual subcomponents together and for interfacing them with the external world, encompassing, on the one hand, the cobot and additional sensors (i.e., perception, recognition, and motion control modules) and, on the other hand, those requiring MoveIt services/actions, i.e., the user, through a dedicated GUI on RViz2, or the rest of the ROS application (e.g., behavior planning module) through dedicated interface packages. A simplified schematic of MoveIt2 architecture is shown in the Figure 10, illustrating how MoveIt services (i.e., user interface) can be called, how the framework acquires the state of the robot and environment and requests plan execution to the robot controllers (i.e., robot interface), and some of its main subcomponents. Concerning the latter, we can observe the _Planning Scene Monitor_ described in the previous section, the _Collision Detection_, which is responsible for the robot's self-collision and environment collision checks, and the _Planning Interface_, which takes charge of the motion plan request to move the robot from a start pose to a different one (expressed in joint space or operational space) and responds with a motion plan result that satisfies all the imposed constraints. Both the _Collision Detection_ and the _Planning Interface_ components rely on external libraries to implement collision detectors and motion planners. Specifically, MoveIt provides default libraries that allow the framework to be easily and quickly tested, which can be easily customized and/or replaced, making MoveIt highly adaptable. The default motion planning library is OMPL (Open Motion Planning Library), implementing many state-of-the-art sampling-based algorithms such as RRT (Rapidly Exploring Random Tree), PRM (Probabilistic Roadmap Method), EST (Expansive Space Trees), and KPIECE (Kinodynamic Motion Planning by Interior-Exterior Cell Exploration) [108; 109]. Other available planners are CHOMP (Covariant Hamiltonian Optimization for Motion Planning) [110], STOMP (Stochastic Trajectory Optimization for Motion Planning) [111], and Pilz Industrial Motion Planner. Concerning collision detectors, the default is FCL (Flexible Collision Library) [112], while an available alternative if continuous collision detection is required is the Bullet library [113]. Finally, it should be noted that, while modification of the motion planner is relatively straightforward, especially if working with OMPL, replacement of the collision detector requires modification and recompilation of MoveIt2 packages. Figure 9: Example of image processing with OpenCV. In conclusion, ROS2 through MoveIt2 offers a powerful framework for motion planning that, besides being highly modular and customizable, even in its standard implementation, offers advanced features such as planning to avoid collisions with the external environment perceived by an exteroceptive sensor like a depth camera. As an example of this, Figure 11b shows how MoveIt2 plans a feasible trajectory (in gray a snapshot) from a start state (in green) to a goal state (in orange) in an environment reconstructed in the form of an OctoMap from the point cloud acquired by a camera (the red voxel) mounted on an external support above the table.