ROS Style Guide and ros_lint¶
The ROS Scan-N-Plan application from Exercise 4.0 is complete, tested and documented. Now we want to clean up the code according to the style guide so other developers can easily understand our work.
Scan-N-Plan Application: Problem Statement¶
We have completed and tested our Scan-N-Plan program from Exercise 4.0 and we need to release the code to the public. Your goal is to ensure the code we have created conforms to the ROS C++ Style Guide.
Scan-N-Plan Application: Guidance¶
Add a build dependency on
find_package(...)command in the
find_package(catkin REQUIRED COMPONENTS ... roslint )
catkin build myworkcell_core --make-args roslint
The output of
roslintfor the ScanNPlan class from Exercise 4.0 indicates that there are several issues regarding formatting
/home/ros-industrial/ros/catkin_ws/src/myworkcell_core/src/myworkcell_node.cpp:0: No copyright message found. You should have a line: "Copyright [year] <Copyright Owner>" [legal/copyright]  /home/ros-industrial/ros/catkin_ws/src/myworkcell_core/src/myworkcell_node.cpp:9: Single-parameter constructors should be marked explicit. [runtime/explicit]  /home/ros-industrial/ros/catkin_ws/src/myworkcell_core/src/myworkcell_node.cpp:54: Lines should be <= 120 characters long [whitespace/line_length]  /home/ros-industrial/ros/catkin_ws/src/myworkcell_core/src/myworkcell_node.cpp:54: At least two spaces is best between code and comments [whitespace/comments]  /home/ros-industrial/ros/catkin_ws/src/myworkcell_core/src/myworkcell_node.cpp:54: Add #include <string> for string [build/include_what_you_use]  Done processing /home/ros-industrial/ros/catkin_ws/src/myworkcell_core/src/myworkcell_node.cpp /home/ros-industrial/ros/catkin_ws/src/myworkcell_core/src/vision_node.cpp:0: No copyright message found. You should have a line: "Copyright [year] <Copyright Owner>" [legal/copyright]  /home/ros-industrial/ros/catkin_ws/src/myworkcell_core/src/vision_node.cpp:12: Single-parameter constructors should be marked explicit. [runtime/explicit]  /home/ros-industrial/ros/catkin_ws/src/myworkcell_core/src/vision_node.cpp:23: Should have a space between // and comment [whitespace/comments]  Done processing /home/ros-industrial/ros/catkin_ws/src/myworkcell_core/src/vision_node.cpp Total errors found: 8
Once these issues are corrected, the output of
roslintshould look like this:
Done processing /home/ros-industrial/ros/catkin_ws/src/myworkcell_core/src/myworkcell_node.cpp Done processing /home/ros-industrial/ros/catkin_ws/src/myworkcell_core/src/vision_node.cpp Total errors found: 0