Skip to content

Commit

Permalink
ROS2 Styling / Linting (SteveMacenski#176)
Browse files Browse the repository at this point in the history
* linting python

* cmake lint

* linting cpplint

* linting cpplint part 2

* uncrustify part 2

* adding specific linting packages relevent here
  • Loading branch information
SteveMacenski authored Mar 5, 2020
1 parent 9389a73 commit 824ea07
Show file tree
Hide file tree
Showing 55 changed files with 592 additions and 498 deletions.
4 changes: 2 additions & 2 deletions CMake/FindCSparse.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ FIND_PATH(CSPARSE_INCLUDE_DIR NAMES cs.h
/opt/local/include/ufsparse
/usr/local/include/ufsparse
/sw/include/ufsparse
)
)

FIND_LIBRARY(CSPARSE_LIBRARY NAMES cxsparse
PATHS
/usr/lib
/usr/local/lib
/opt/local/lib
/sw/lib
)
)

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(CSPARSE DEFAULT_MSG
Expand Down
18 changes: 10 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ set(dependencies
#interactive_markers
)

set(libraries
set(libraries
lifelong_slam_toolbox
localization_slam_toolbox
sync_slam_toolbox
Expand All @@ -75,7 +75,7 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON)
add_definitions(-DQT_NO_KEYWORDS)
find_package(Boost REQUIRED system serialization filesystem thread)

include_directories(include ${EIGEN3_INCLUDE_DIRS}
include_directories(include ${EIGEN3_INCLUDE_DIRS}
${CHOLMOD_INCLUDE_DIR}
${Boost_INCLUDE_DIR}
${BOOST_INCLUDE_DIRS}
Expand Down Expand Up @@ -144,22 +144,22 @@ rosidl_target_interfaces(toolbox_common ${PROJECT_NAME} "rosidl_typesupport_cpp"
#### Mapping executibles
add_library(async_slam_toolbox src/slam_toolbox_async.cpp)
target_link_libraries(async_slam_toolbox toolbox_common kartoSlamToolbox ${Boost_LIBRARIES})
add_executable(async_slam_toolbox_node src/slam_toolbox_async_node.cpp )
add_executable(async_slam_toolbox_node src/slam_toolbox_async_node.cpp)
target_link_libraries(async_slam_toolbox_node async_slam_toolbox)

add_library(sync_slam_toolbox src/slam_toolbox_sync.cpp)
target_link_libraries(sync_slam_toolbox toolbox_common kartoSlamToolbox ${Boost_LIBRARIES})
add_executable(sync_slam_toolbox_node src/slam_toolbox_sync_node.cpp )
add_executable(sync_slam_toolbox_node src/slam_toolbox_sync_node.cpp)
target_link_libraries(sync_slam_toolbox_node sync_slam_toolbox)

add_library(localization_slam_toolbox src/slam_toolbox_localization.cpp)
target_link_libraries(localization_slam_toolbox toolbox_common kartoSlamToolbox ${Boost_LIBRARIES})
add_executable(localization_slam_toolbox_node src/slam_toolbox_localization_node.cpp )
add_executable(localization_slam_toolbox_node src/slam_toolbox_localization_node.cpp)
target_link_libraries(localization_slam_toolbox_node localization_slam_toolbox)

add_library(lifelong_slam_toolbox src/experimental/slam_toolbox_lifelong.cpp)
target_link_libraries(lifelong_slam_toolbox toolbox_common kartoSlamToolbox ${Boost_LIBRARIES})
add_executable(lifelong_slam_toolbox_node src/experimental/slam_toolbox_lifelong_node.cpp )
add_executable(lifelong_slam_toolbox_node src/experimental/slam_toolbox_lifelong_node.cpp)
target_link_libraries(lifelong_slam_toolbox_node lifelong_slam_toolbox)

#### Merging maps tool
Expand All @@ -169,6 +169,8 @@ target_link_libraries(merge_maps_kinematic kartoSlamToolbox toolbox_common)
#### testing
if(BUILD_TESTING)
find_package(ament_cmake_gtest REQUIRED)
find_package(ament_lint_auto REQUIRED)
ament_lint_auto_find_test_dependencies()
include_directories(test)
ament_add_gtest(lifelong_metrics_test test/lifelong_metrics_test.cpp)
target_link_libraries(lifelong_metrics_test lifelong_slam_toolbox)
Expand All @@ -190,11 +192,11 @@ install(DIRECTORY include/
DESTINATION include
)

install(DIRECTORY launch
install(DIRECTORY launch
DESTINATION share/${PROJECT_NAME}
)

install(DIRECTORY config
install(DIRECTORY config
DESTINATION share/${PROJECT_NAME}
)

Expand Down
19 changes: 10 additions & 9 deletions include/slam_toolbox/experimental/slam_toolbox_lifelong.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@

/* Author: Steven Macenski */

#ifndef SLAM_TOOLBOX_SLAM_TOOLBOX_LIFELONG_H_
#define SLAM_TOOLBOX_SLAM_TOOLBOX_LIFELONG_H_
#ifndef SLAM_TOOLBOX__EXPERIMENTAL__SLAM_TOOLBOX_LIFELONG_HPP_
#define SLAM_TOOLBOX__EXPERIMENTAL__SLAM_TOOLBOX_LIFELONG_HPP_

#include <memory>
#include "slam_toolbox/slam_toolbox_common.hpp"

namespace slam_toolbox
Expand All @@ -27,7 +28,7 @@ namespace slam_toolbox
class LifelongSlamToolbox : public SlamToolbox
{
public:
LifelongSlamToolbox(rclcpp::NodeOptions options);
explicit LifelongSlamToolbox(rclcpp::NodeOptions options);
~LifelongSlamToolbox() {}

// computation metrics
Expand All @@ -48,12 +49,12 @@ class LifelongSlamToolbox : public SlamToolbox
double & x_u, double & y_l, double & y_u);

protected:
virtual void laserCallback(
sensor_msgs::msg::LaserScan::ConstSharedPtr scan) override final;
virtual bool deserializePoseGraphCallback(
void laserCallback(
sensor_msgs::msg::LaserScan::ConstSharedPtr scan) override;
bool deserializePoseGraphCallback(
const std::shared_ptr<rmw_request_id_t> request_header,
const std::shared_ptr<slam_toolbox::srv::DeserializePoseGraph::Request> req,
std::shared_ptr<slam_toolbox::srv::DeserializePoseGraph::Response> resp) override final;
std::shared_ptr<slam_toolbox::srv::DeserializePoseGraph::Response> resp) override;

void evaluateNodeDepreciation(LocalizedRangeScan * range_scan);
void removeFromSlamGraph(Vertex<LocalizedRangeScan> * vertex);
Expand All @@ -75,6 +76,6 @@ class LifelongSlamToolbox : public SlamToolbox
double nearby_penalty_;
};

}
} // namespace slam_toolbox

#endif //SLAM_TOOLBOX_SLAM_TOOLBOX_LIFELONG_H_
#endif // SLAM_TOOLBOX__EXPERIMENTAL__SLAM_TOOLBOX_LIFELONG_HPP_
9 changes: 5 additions & 4 deletions include/slam_toolbox/get_pose_helper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@

/* Author: Steven Macenski */

#ifndef SLAM_TOOLBOX_POSE_UTILS_H_
#define SLAM_TOOLBOX_POSE_UTILS_H_
#ifndef SLAM_TOOLBOX__GET_POSE_HELPER_HPP_
#define SLAM_TOOLBOX__GET_POSE_HELPER_HPP_

#include <string>
#include "geometry_msgs/msg/pose_with_covariance_stamped.hpp"
#include "slam_toolbox/toolbox_types.hpp"
#include "../lib/karto_sdk/include/karto_sdk/Mapper.h"
Expand Down Expand Up @@ -63,6 +64,6 @@ class GetPoseHelper
std::string base_frame_, odom_frame_;
};

} // end namespace
} // namespace pose_utils

#endif //SLAM_TOOLBOX_POSE_UTILS_H_
#endif // SLAM_TOOLBOX__GET_POSE_HELPER_HPP_
13 changes: 8 additions & 5 deletions include/slam_toolbox/laser_utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,13 @@

/* Author: Steven Macenski */

#ifndef SLAM_TOOLBOX_LASER_UTILS_H_
#define SLAM_TOOLBOX_LASER_UTILS_H_
#ifndef SLAM_TOOLBOX__LASER_UTILS_HPP_
#define SLAM_TOOLBOX__LASER_UTILS_HPP_

#include <string>
#include <memory>
#include <map>
#include <vector>

#include "rclcpp/rclcpp.hpp"
#include "slam_toolbox/toolbox_types.hpp"
Expand Down Expand Up @@ -93,7 +96,7 @@ class LaserAssistant
class ScanHolder
{
public:
ScanHolder(std::map<std::string, laser_utils::LaserMetadata> & lasers);
explicit ScanHolder(std::map<std::string, laser_utils::LaserMetadata> & lasers);
~ScanHolder();
sensor_msgs::msg::LaserScan getCorrectedScan(const int & id);
void addScan(const sensor_msgs::msg::LaserScan scan);
Expand All @@ -103,6 +106,6 @@ class ScanHolder
std::map<std::string, laser_utils::LaserMetadata> & lasers_;
};

} // end namespace
} // namespace laser_utils

#endif //SLAM_TOOLBOX_LASER_UTILS_H_
#endif // SLAM_TOOLBOX__LASER_UTILS_HPP_
31 changes: 19 additions & 12 deletions include/slam_toolbox/loop_closure_assistant.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,20 @@

/* Author: Steven Macenski */

#ifndef SLAM_TOOLBOX_LOOP_CLOSURE_ASSISTANT_H_
#define SLAM_TOOLBOX_LOOP_CLOSURE_ASSISTANT_H_
#ifndef SLAM_TOOLBOX__LOOP_CLOSURE_ASSISTANT_HPP_
#define SLAM_TOOLBOX__LOOP_CLOSURE_ASSISTANT_HPP_

#include <functional>
#include <boost/thread.hpp>
#include <string>
#include <functional>
#include <memory>
#include <map>

#include "tf2_ros/transform_broadcaster.h"
#include "tf2/utils.h"
#include "rclcpp/rclcpp.hpp"
// #include "interactive_markers/interactive_marker_server.h"
// #include "interactive_markers/menu_handler.h"
#include "tf2_ros/transform_broadcaster.h"
#include "tf2/utils.h"

#include "slam_toolbox/toolbox_types.hpp"
#include "slam_toolbox/laser_utils.hpp"
Expand All @@ -38,7 +40,7 @@ namespace loop_closure_assistant

// TODO(stevemacenski): Need interactive markers ported to ROS2

using namespace ::toolbox_types;
using namespace ::toolbox_types; // NOLINT

class LoopClosureAssistant
{
Expand All @@ -49,13 +51,18 @@ class LoopClosureAssistant
ProcessType & processor_type);

// void clearMovedNodes();
// void processInteractiveFeedback(const visualization_msgs::InteractiveMarkerFeedbackConstPtr& feedback);
// void processInteractiveFeedback(
// const visualization_msgs::InteractiveMarkerFeedbackConstPtr& feedback);
void publishGraph();

private:
// bool manualLoopClosureCallback(slam_toolbox::LoopClosure::Request& req, slam_toolbox::LoopClosure::Response& resp);
// bool clearChangesCallback(slam_toolbox::Clear::Request& req, slam_toolbox::Clear::Response& resp);
// bool interactiveModeCallback(slam_toolbox::ToggleInteractive::Request &req, slam_toolbox::ToggleInteractive::Response &resp);
// bool manualLoopClosureCallback(
// slam_toolbox::LoopClosure::Request& req, slam_toolbox::LoopClosure::Response& resp);
// bool clearChangesCallback(
// slam_toolbox::Clear::Request& req, slam_toolbox::Clear::Response& resp);
// bool interactiveModeCallback(
// slam_toolbox::ToggleInteractive::Request &req,
// slam_toolbox::ToggleInteractive::Response &resp);
// void moveNode(const int& id, const Eigen::Vector3d& pose);
// void addMovedNodes(const int& id, Eigen::Vector3d vec);

Expand All @@ -77,6 +84,6 @@ class LoopClosureAssistant
ProcessType & processor_type_;
};

} // end namespace
} // namespace loop_closure_assistant

#endif //SLAM_TOOLBOX_LOOP_CLOSURE_ASSISTANT_H_
#endif // SLAM_TOOLBOX__LOOP_CLOSURE_ASSISTANT_HPP_
9 changes: 5 additions & 4 deletions include/slam_toolbox/map_saver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@

/* Author: Steven Macenski */

#ifndef SLAM_TOOLBOX_MAP_SAVER_H_
#define SLAM_TOOLBOX_MAP_SAVER_H_
#ifndef SLAM_TOOLBOX__MAP_SAVER_HPP_
#define SLAM_TOOLBOX__MAP_SAVER_HPP_

#include <string>
#include <memory>
#include <chrono>
#include "rclcpp/rclcpp.hpp"
#include "slam_toolbox/toolbox_msgs.hpp"
Expand Down Expand Up @@ -47,6 +48,6 @@ class MapSaver
bool received_map_;
};

} // end namespace
} // namespace map_saver

#endif //SLAM_TOOLBOX_MAP_SAVER_H_
#endif // SLAM_TOOLBOX__MAP_SAVER_HPP_
24 changes: 12 additions & 12 deletions include/slam_toolbox/merge_maps_kinematic.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,21 @@

/* Author: Steven Macenski */

#ifndef SLAM_TOOLBOX_MERGE_MAPS_KINEMATIC_H_
#define SLAM_TOOLBOX_MERGE_MAPS_KINEMATIC_H_
#ifndef SLAM_TOOLBOX__MERGE_MAPS_KINEMATIC_HPP_
#define SLAM_TOOLBOX__MERGE_MAPS_KINEMATIC_HPP_

#include <boost/thread.hpp>
#include <sys/stat.h>
#include <unistd.h>
#include <string>
#include <map>
#include <memory>
#include <vector>
#include <sys/stat.h>
#include <unistd.h>
#include <fstream>
#include <boost/thread.hpp>

#include "rclcpp/rclcpp.hpp"
//#include "interactive_markers/interactive_marker_server.h"
//#include "interactive_markers/menu_handler.h"
// #include "interactive_markers/interactive_marker_server.h"
// #include "interactive_markers/menu_handler.h"
#include "tf2_ros/transform_broadcaster.h"
#include "tf2_ros/transform_listener.h"
#include "tf2_ros/message_filter.h"
Expand All @@ -44,8 +44,8 @@
#include "slam_toolbox/laser_utils.hpp"
#include "slam_toolbox/visualization_utils.hpp"

using namespace toolbox_types;
using namespace karto;
using namespace toolbox_types; // NOLINT
using namespace karto; // NOLINT

class MergeMapsKinematic : public rclcpp::Node
{
Expand Down Expand Up @@ -75,7 +75,7 @@ class MergeMapsKinematic : public rclcpp::Node
nav_msgs::srv::GetMap::Response & map);
void transformScan(LocalizedRangeScansIt iter, tf2::Transform & submap_correction);

//apply transformation to correct pose
// apply transformation to correct pose
karto::Pose2 applyCorrection(const karto::Pose2 & pose, const tf2::Transform & submap_correction);
karto::Vector2<kt_double> applyCorrection(
const karto::Vector2<kt_double> & pose,
Expand All @@ -87,7 +87,7 @@ class MergeMapsKinematic : public rclcpp::Node
std::shared_ptr<rclcpp::Service<slam_toolbox::srv::MergeMaps>> ssMap_;
std::shared_ptr<rclcpp::Service<slam_toolbox::srv::AddSubmap>> ssSubmap_;

//karto bookkeeping
// karto bookkeeping
std::map<std::string, laser_utils::LaserMetadata> lasers_;
std::vector<std::unique_ptr<karto::Dataset>> dataset_vec_;

Expand All @@ -105,4 +105,4 @@ class MergeMapsKinematic : public rclcpp::Node
int num_submaps_;
};

#endif //SLAM_TOOLBOX_MERGE_MAPS_KINEMATIC_H_
#endif // SLAM_TOOLBOX__MERGE_MAPS_KINEMATIC_HPP_
10 changes: 5 additions & 5 deletions include/slam_toolbox/serialization.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@

/* Author: Steven Macenski */

#ifndef SLAM_TOOLBOX_SERIALIZATION_H_
#define SLAM_TOOLBOX_SERIALIZATION_H_
#ifndef SLAM_TOOLBOX__SERIALIZATION_HPP_
#define SLAM_TOOLBOX__SERIALIZATION_HPP_

#include <sys/stat.h>
#include <vector>
#include <string>
#include <sys/stat.h>
#include "rclcpp/rclcpp.hpp"
#include "../lib/karto_sdk/include/karto_sdk/Mapper.h"

Expand Down Expand Up @@ -75,6 +75,6 @@ inline bool read(
return false;
}

} // end namespace
} // namespace serialization

#endif //SLAM_TOOLBOX_SERIALIZATION_H_
#endif // SLAM_TOOLBOX__SERIALIZATION_HPP_
11 changes: 6 additions & 5 deletions include/slam_toolbox/slam_mapper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,18 @@

/* Author: Steven Macenski */

#ifndef SLAM_TOOLBOX_SLAM_MAPPER_H_
#define SLAM_TOOLBOX_SLAM_MAPPER_H_
#ifndef SLAM_TOOLBOX__SLAM_MAPPER_HPP_
#define SLAM_TOOLBOX__SLAM_MAPPER_HPP_

#include <memory>
#include "rclcpp/rclcpp.hpp"
#include "tf2/utils.h"
#include "slam_toolbox/toolbox_types.hpp"

namespace mapper_utils
{

using namespace ::karto;
using namespace ::karto; // NOLINT

class SMapper
{
Expand Down Expand Up @@ -59,6 +60,6 @@ class SMapper
std::unique_ptr<karto::Mapper> mapper_;
};

} // end namespace
} // namespace mapper_utils

#endif //SLAM_TOOLBOX_SLAM_MAPPER_H_
#endif // SLAM_TOOLBOX__SLAM_MAPPER_HPP_
Loading

0 comments on commit 824ea07

Please sign in to comment.