To start adding an object, we need to have a planning scene; this is only possible when MoveIt! is running, so the first step is to start Gazebo, MoveIt!, the controllers, and RViz. Since the planning scene only exists in MoveIt!, RViz is required to be able to visualize objects contained in it. In order to launch all of the required modules, we need to run the following commands:
$ roslaunch rosbook_arm_gazebo rosbook_arm_empty_world.launch $ roslaunch rosbook_arm_moveit_config moveit_rviz.launch config:=true
The snippet of code then starts by instantiating the planning scene interface object, which can be used to perform actions on the planning scene itself:
moveit::planning_interface::PlanningSceneInterfacecurrent_scene; ...