# Robot Operating System 2 (ROS2)-Based Frameworks for Increasing Robot Autonomy: A Survey
## 5 Example of Using the Framework to Increase Cobot Autonomy: A Proof of Concept
### Planning and Control Layer Implementation  
The planning layer relies on the standard planning pipeline provided by MoveIt2 and implements a basic logic, thus not requiring its division into behavior planning, trajectory planning, and manipulation. However, this is sufficient to increase the cobot's level of autonomy, allowing it to adapt its picking and placing operations to variable but static scenarios. In particular, this flexibility concerns two aspects that are handled by this layer. The first is related to the possibility of changing the position and size of the object to be grasped without the need to manually reprogram the cobot thanks to the identification of the target pose for the picking action from the information provided by the perception layer. The second concerns the avoidance of collisions with static but unknown obstacles in the robot's workspace. This is ensured by updating the _PlanningScene_ as described in the previous section and by using it for the trajectory planning of the single actions. Both aspects can be easily handled by resorting to the standard functionalities offered by MoveIt2 and described in Section 4.3. In particular, for this preliminary proof of concept, the default MoveIt2 settings were retained, which include FCL for collision detection and RRTConnect from OMPL for motion planning.  
Lastly, the control layer is devoted to enabling the execution of the planned pick and place on the real robot. Conceptually, it consists of two nodes, the _Cobot Driver_, which here fulfills the task of sending commands to the cobot, and the _End Effector Driver_ to control the gripper. For the simple gripper here adopted, which only provides a digital I/O interface that can be connected to the cobot's control box, the driver relies on that of the robot, which, among other things, provides read-and-write services to the robot's digital channels. The _End Effector Driver_ simply requests these services to send commands for opening and closing the gripper fingers in order to grasp and release the object during the pick-and-place actions. Concerning the _Cobot Driver_, as already anticipated, there is an off-the-shelf driver provided by Technan that implements the _TMSCT_ protocol to control the cobot from the outside using the _External Script_ mode. This driver not only offers other dedicated services to be requested in order to send generic commands to the robot (including a _QueetTag_ command to monitor the execution of the other commands) but also directly implements the _FollowJointTrajectory_ action supported by MoveIt. Specifically, this action server receives in the action goal the trajectory to be executed and translates the sequence of planned points into a sequence of commands of type _PVTPoint_, each of them specifying the target position, velocity, and duration of the movement that the cobot will execute, and sends them out.  
By combining the above-described perception, planning, and control layers, an ROS2 application is developed. It enables the cobot to perform a pick-and-place operation with a higher level of flexibility and autonomy. An example of the achieved results is shown in Figure 17. The two subfigures show how the cobot is able to grasp the detected object (i.e., a small black box in the gripper of the right-hand figure) by reaching the final pose (the green-colored configuration of the left-hand figure). The planning takes into account the pose and size of the object and places it in the desired pose (see the orange-colored configuration). This goal pose is reached while avoiding collisions with external objects in the environment consisting of both the initial scene (i.e., the tabletop and the camera support in light gray) and the newly detected obstacle (the large black box in the figure on the right, corresponding to the red box in the figure on the left).