Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ROS2 mobility: (part of) planner_qp #733

Open
wants to merge 10 commits into
base: ros2
Choose a base branch
from
29 changes: 0 additions & 29 deletions mobility/planner_qp/CMakeLists.txt

This file was deleted.

55 changes: 34 additions & 21 deletions mobility/planner_qp/traj_opt_basic/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,25 @@
# License for the specific language governing permissions and limitations
# under the License.

cmake_minimum_required(VERSION 3.0)
cmake_minimum_required(VERSION 3.5)
project(traj_opt_basic)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -Wall -Wno-deprecated-declarations -Werror=return-type")

find_package(catkin REQUIRED COMPONENTS
)
# Default to C++14
if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 14)
endif()
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -O3 -fPIC -Wno-deprecated-declarations -Werror=return-type" )

find_package(ament_cmake REQUIRED)

find_package(rclcpp REQUIRED)
find_package(Eigen3 REQUIRED)
find_package(Boost REQUIRED)

catkin_package(
INCLUDE_DIRS include
LIBRARIES
traj_opt_basic
)

###########
## Build ##
###########

# Specify additional locations of header files
include_directories(
include
Expand All @@ -42,27 +42,40 @@ include_directories(
${Boost_INCLUDE_DIRS}
)

add_library(traj_opt_basic
add_library(${PROJECT_NAME} SHARED
src/msg_traj.cpp
src/polynomial_basis.cpp
src/trajectory.cpp)
add_dependencies(traj_opt_basic ${catkin_EXPORTED_TARGETS})
target_link_libraries(traj_opt_basic ${catkin_LIBRARIES})
src/trajectory.cpp
)
# target_link_libraries(${PROJECT_NAME} ${QT_LIBRARIES})
target_compile_definitions(${PROJECT_NAME}
PRIVATE "COMPOSITION_BUILDING_DLL")
ament_target_dependencies(${PROJECT_NAME} rclcpp)
# ament_export_targets(${PROJECT_NAME} HAS_LIBRARY_TARGET)

#############
## Install ##
#############

ament_export_dependencies(
)

ament_export_include_directories(include)

# Mark libraries for installation
install(TARGETS ${PROJECT_NAME}
ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
RUNTIME DESTINATION ${CATKIN_GLOBAL_BIN_DESTINATION}
install(TARGETS ${PROJECT_NAME}
EXPORT ${PROJECT_NAME}
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin
INCLUDES DESTINATION include
)

# Mark cpp header files for installation
install(DIRECTORY include/${PROJECT_NAME}/
DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION}
install(DIRECTORY include/${PROJECT_NAME}
DESTINATION include
FILES_MATCHING PATTERN "*.h"
PATTERN ".svn" EXCLUDE
)
)

ament_package()
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class Basis {

// evaluates ith element of basis at x where x is normalized to 0 to 1
virtual decimal_t evaluate(decimal_t x, uint i) const = 0;
// innerproduct bewtween ith and jth basis functions
// innerproduct between ith and jth basis functions
virtual decimal_t innerproduct(uint i, uint j) const = 0;

virtual uint dim();
Expand Down
18 changes: 13 additions & 5 deletions mobility/planner_qp/traj_opt_basic/package.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0"?>
<package format="2">
<package format="3">
<name>traj_opt_basic</name>
<version>0.0.1</version>
<version>0.0.0</version>
<description>
The traj_opt_basic package
</description>
Expand All @@ -14,7 +14,15 @@
<maintainer email="[email protected]">
Astrobee Flight Software
</maintainer>
<buildtool_depend>catkin</buildtool_depend>
<build_depend>catkin_simple</build_depend>
<depend>eigen3</depend>

<build_depend>ament_cmake</build_depend>
<build_depend>rclcpp</build_depend>
<build_depend>eigen3</build_depend>

<exec_depend>rclcpp</exec_depend>
<exec_depend>eigen3</exec_depend>

<export>
<build_type>ament_cmake</build_type>
</export>
</package>
47 changes: 30 additions & 17 deletions mobility/planner_qp/traj_opt_msgs/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,29 +15,42 @@
# License for the specific language governing permissions and limitations
# under the License.

cmake_minimum_required(VERSION 3.0)
cmake_minimum_required(VERSION 3.5)

project(traj_opt_msgs)

find_package(catkin REQUIRED COMPONENTS
message_generation
std_msgs
)
# Default to C++14
if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 14)
endif()
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wpedantic")
endif()

find_package(ament_cmake REQUIRED)
find_package(builtin_interfaces REQUIRED)
find_package(std_msgs REQUIRED)
find_package(ff_util REQUIRED)
find_package(rosidl_default_generators REQUIRED)

# Generate messages in the 'msg' folder
add_message_files(
FILES
Polynomial.msg
SolverInfo.msg
Spline.msg
Trajectory.msg
)
file(GLOB MSG_FILES msg/*.msg)
foreach(SRC ${MSG_FILES})
get_filename_component(NAME ${SRC} NAME)
list(APPEND MSG_FILE_NAMES "msg/${NAME}")
endforeach()

generate_messages(
DEPENDENCIES std_msgs
)
rosidl_generate_interfaces(${PROJECT_NAME}
${MSG_FILE_NAMES}

catkin_package(
LIBRARIES
DEPENDENCIES
builtin_interfaces
std_msgs
ff_util

ADD_LINTER_TESTS
)

ament_export_dependencies(rosidl_default_runtime)

ament_package()
2 changes: 1 addition & 1 deletion mobility/planner_qp/traj_opt_msgs/msg/Trajectory.msg
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#
# Trajectory message used by the QP planner.

Header header
std_msgs/Header header
int32 dimensions
string[] dimension_names
traj_opt_msgs/Spline[] data
25 changes: 19 additions & 6 deletions mobility/planner_qp/traj_opt_msgs/package.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0"?>
<package format="2">
<package format="3">
<name>traj_opt_msgs</name>
<version>0.0.1</version>
<version>0.0.0</version>
<description>
The traj_opt_msgs package
</description>
Expand All @@ -14,8 +14,21 @@
<maintainer email="[email protected]">
Astrobee Flight Software
</maintainer>
<buildtool_depend>catkin</buildtool_depend>
<build_depend>catkin_simple</build_depend>
<depend>message_generation</depend>
<depend>std_msgs</depend>

<buildtool_depend>ament_cmake</buildtool_depend>
<build_depend>rosidl_default_generators</build_depend>
<build_depend>builtin_interfaces</build_depend>
<build_depend>std_msgs</build_depend>

<exec_depend>rosidl_default_generators</exec_depend>
<exec_depend>builtin_interfaces</exec_depend>
<exec_depend>std_msgs</exec_depend>

<test_depend>ament_lint_common</test_depend>

<member_of_group>rosidl_interface_packages</member_of_group>

<export>
<build_type>ament_cmake</build_type>
</export>
</package>
52 changes: 33 additions & 19 deletions mobility/planner_qp/traj_opt_pro/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,13 @@
# License for the specific language governing permissions and limitations
# under the License.

cmake_minimum_required(VERSION 3.0)

cmake_minimum_required(VERSION 3.5)
project(traj_opt_pro)

# Default to C++14
if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 14)
endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -Wall -Wno-deprecated-declarations -Werror=return-type")

############################ Optional Build Params #############################
Expand All @@ -39,21 +43,25 @@ if(INTEL_MKL)
endif()

## Find catkin macros and libraries
find_package(catkin2 REQUIRED COMPONENTS
traj_opt_basic
)
find_package(ament_cmake REQUIRED)

find_package(rclcpp REQUIRED)
find_package(traj_opt_basic REQUIRED)
# find_package(catkin2 REQUIRED COMPONENTS
# traj_opt_basic
# )

find_package(Eigen3 REQUIRED)

# Find OpenCV
LIST(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/../../../cmake")
find_package(OpenCV331 REQUIRED)

catkin_package(
INCLUDE_DIRS include
LIBRARIES
traj_opt_pro fancy_custom_backend ${OpenCV_LIBRARIES}
)
# catkin_package(
# INCLUDE_DIRS include
# LIBRARIES
# traj_opt_pro fancy_custom_backend ${OpenCV_LIBRARIES}
# )


###########
Expand All @@ -65,40 +73,46 @@ include_directories(
${catkin_INCLUDE_DIRS}
${EIGEN3_INCLUDE_DIR}
${OpenCV_INCLUDE_DIR}
${traj_opt_basic_INCLUDE_DIRS}
)

# Add libraries
add_library(traj_opt_pro
add_library(${PROJECT_NAME} SHARED
src/polynomial_basis.cpp
src/trajectory_solver.cpp)

if(BUILD_GUROBI)
add_library(gurobi_backend
src/gurobi_solver.cpp
src/gurobi_trajectory.cpp )
target_link_libraries(gurobi_backend traj_opt_pro ${GUROBI_LIBRARIES})
target_link_libraries(gurobi_backend ${PROJECT_NAME} ${GUROBI_LIBRARIES})
endif()

add_library(fancy_custom_backend
src/nonlinear_polynomial.cpp
src/nonlinear_solver.cpp
src/nonlinear_trajectory.cpp)
target_link_libraries(fancy_custom_backend traj_opt_pro ${OpenCV_LIBRARIES})
target_compile_definitions(${PROJECT_NAME}
PRIVATE "COMPOSITION_BUILDING_DLL")
target_link_libraries(fancy_custom_backend ${PROJECT_NAME} ${OpenCV_LIBRARIES} ${traj_opt_basic_LIBRARIES})
ament_target_dependencies(${PROJECT_NAME} traj_opt_basic)

#############
## Install ##
#############

# Mark libraries for installation
install(TARGETS ${PROJECT_NAME} fancy_custom_backend
ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
RUNTIME DESTINATION ${CATKIN_GLOBAL_BIN_DESTINATION}
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin
)

# Mark cpp header files for installation
install(DIRECTORY include/${PROJECT_NAME}/
DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION}
install(DIRECTORY include/${PROJECT_NAME}
DESTINATION include
FILES_MATCHING PATTERN "*.h"
PATTERN ".svn" EXCLUDE
)
)

ament_package()
Loading