Skip to content

Commit 3cbce6c

Browse files
committed
feat: add cpp utils and ssa function
1 parent 3241674 commit 3cbce6c

File tree

4 files changed

+68
-0
lines changed

4 files changed

+68
-0
lines changed

CMakeLists.txt

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
cmake_minimum_required(VERSION 3.8)
2+
project(vortex_utils)
3+
4+
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
5+
add_compile_options(-Wall -Wextra -Wpedantic)
6+
endif()
7+
8+
find_package(ament_cmake REQUIRED)
9+
10+
include_directories(include)
11+
12+
add_library(${PROJECT_NAME} src/cpp_utils.cpp)
13+
14+
ament_export_targets(${PROJECT_NAME} HAS_LIBRARY_TARGET)
15+
16+
install(
17+
DIRECTORY include/
18+
DESTINATION include
19+
)
20+
21+
install(
22+
TARGETS ${PROJECT_NAME}
23+
EXPORT ${PROJECT_NAME}
24+
ARCHIVE DESTINATION lib
25+
LIBRARY DESTINATION lib
26+
RUNTIME DESTINATION bin
27+
INCLUDES DESTINATION include
28+
)
29+
30+
ament_export_dependencies()
31+
ament_export_include_directories(include)
32+
ament_export_libraries(${PROJECT_NAME})
33+
34+
ament_package()

include/vortex_utils/cpp_utils.hpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#ifndef VORTEX_UTILS_HPP
2+
#define VORTEX_UTILS_HPP
3+
4+
#include <cmath>
5+
6+
namespace vortex_utils
7+
{
8+
// @brief Function to calculate the smallest signed angle between two angles
9+
double ssa(const double angle);
10+
} // namespace vortex_utils
11+
12+
#endif // VORTEX_UTILS_HPP

package.xml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?xml version="1.0"?>
2+
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
3+
<package format="3">
4+
<name>vortex_utils</name>
5+
<version>0.0.0</version>
6+
<description>Package containing utility functions and data structures.</description>
7+
<maintainer email="andeshog@stud.ntnu.no">andeshog</maintainer>
8+
<license>MIT</license>
9+
10+
<buildtool_depend>ament_cmake</buildtool_depend>
11+
12+
<export>
13+
<build_type>ament_cmake</build_type>
14+
</export>
15+
</package>

src/cpp_utils.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#include "vortex_utils/cpp_utils.hpp"
2+
3+
double vortex_utils::ssa(const double angle)
4+
{
5+
double angle_ssa = fmod(angle + M_PI, 2 * M_PI) - M_PI;
6+
return angle_ssa;
7+
}

0 commit comments

Comments
 (0)