moveit / moveit2

:robot: MoveIt for ROS 2
https://moveit.ai/
BSD 3-Clause "New" or "Revised" License
1.11k stars 537 forks source link

restructure C++ namespaces #1122

Open v4hn opened 2 years ago

v4hn commented 2 years ago

We have quite a lot of namespaces in our code bases. I'm not saying this is bad, but we could definitely rethink some of them and adapt them to make more sense.

The main question is whether we want to have a moveit namespace for everything. We do not at the moment, but I would definitely support it. Instead we have a moveit::core namespace for the Joint/LinkModel, RobotModel and RobotState classes, but a planning_scene namespace for the PlanningScene (which is arguably as much core as the prior classes).

The PlanningSceneMonitor (the core structure to maintain a scene) is in planning_scene_monitor, together with CurrentStateMonitor, LockedPlanningSceneRO/RW and the TrajectoryMonitor. I would argue that moveit::monitor:: might be a better term here (and whether LockedPlanningScene* should even exist is a different matter).

These are just some examples, the following grep gives a rather good insight into the current mess:

❯ grep -rh '^namespace' | sort -u
namespace
namespace AllowedCollision
namespace BodyTypes
namespace boost
namespace bp = boost::python;
namespace cached_ik_kinematics_plugin
namespace cb = collision_detection_bullet;
namespace chomp
namespace chomp_interface
namespace collision_detection
namespace collision_detection_bullet
namespace constraint_sampler_manager_loader
namespace constraint_samplers
namespace converter
namespace core
namespace default_planner_request_adapters
namespace detail
namespace details
namespace DiscretizationMethods
namespace displays
namespace distance_field
namespace DistanceRequestTypes
namespace dynamics_solver
namespace EigenSTL
namespace enc = sensor_msgs::image_encodings;
namespace fcl
namespace fs = boost::filesystem;
namespace ikfast
namespace IKFAST_NAMESPACE
namespace IKFAST_NAMESPACE {
namespace InteractionStyle
namespace interactive_markers
namespace joint_limits
namespace joint_limits_interface
namespace KDL
namespace kdl_kinematics_plugin
namespace kinematic_constraints
namespace KinematicErrors
namespace kinematics
namespace kinematics_cache
namespace kinematics_cache_ros
namespace kinematics_constraint_aware
namespace kinematics_metrics
namespace kinematics_plugin_loader
namespace lma_kinematics_plugin
namespace mesh_filter
namespace mesh_filter_test
namespace move_group
namespace moveit
namespace moveit_benchmarks
namespace moveit_controller_manager
namespace moveit_controller_manager_example
namespace moveit_cpp
namespace moveit_fake_controller_manager
namespace moveit::hybrid_planning
namespace moveit_hybrid_planning
namespace moveit_ros_benchmarks
namespace moveit_ros_control_interface
namespace moveit_rviz_plugin
namespace moveit_sensor_manager
namespace moveit_servo
namespace moveit_setup_assistant
namespace moveit_simple_controller_manager
namespace moveit_warehouse
namespace mpi = moveit::planning_interface;
namespace names
namespace _NAMESPACE_
namespace ob = ompl::base;
namespace occupancy_map_monitor
namespace octomap
namespace og = ompl::geometric;
namespace Ogre
namespace ompl_interface
namespace ompl_interface_testing
namespace online_signal_smoothing
namespace ot = ompl::tools;
namespace pick_place
namespace pilz_extensions_tests
namespace pilz_industrial_motion_planner
namespace pilz_industrial_motion_planner_testutils
namespace plan_execution
namespace planning_interface
namespace planning_pipeline
namespace planning_request_adapter
namespace planning_scene
namespace planning_scene_monitor
namespace po = boost::program_options;
namespace point_containment_filter
namespace pr2_arm_kinematics
namespace prbt_manipulator
namespace properties
namespace pt = boost::property_tree;
namespace pybind11
namespace py_bindings_tools
namespace py = pybind11;
namespace python
namespace rclcpp
namespace rdf_loader
namespace robot
namespace robot_interaction
namespace robot_model_loader
namespace robot_trajectory
namespace rviz
namespace rviz_common
namespace rviz_default_plugins
namespace rviz_rendering
namespace sbpl_interface
namespace sbpl_interface
namespace sbpl_interface_ros
namespace semantic_world
namespace shapes
namespace srv_kinematics_plugin
namespace testing
namespace test_moveit_controller_manager
namespace testutils
namespace tf2_ros
namespace tools
namespace trajectory_execution_manager
namespace trajectory_processing
namespace trajopt_interface
namespace Ui
namespace util
namespace XmlRpc
henningkayser commented 2 years ago

phew, now you are opening a can of worms. "Yes" to introducing moveit as a general namespace. We could definitely do some cleanup here looking at the grepped list. I like the idea of grouping the monitors, but then we could maybe just go with moveit::ros to indicate that these are ros runtime components. moveit::ros::interface could then include the client interface parts (somewhat long, though). Likewise, I think it wouldn't be a bad idea to group plugins in moveit::plugins.