diff --git a/CMakeLists.txt b/CMakeLists.txt index 00340b8c..c9571c66 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -92,19 +92,19 @@ if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) ) endif() -find_package(example-robot-data 4.0.9 REQUIRED) -ADD_PROJECT_DEPENDENCY(OpenMP REQUIRED) -ADD_PROJECT_DEPENDENCY(proxsuite REQUIRED) -ADD_PROJECT_DEPENDENCY(pinocchio REQUIRED) -ADD_PROJECT_DEPENDENCY(aligator REQUIRED) -ADD_PROJECT_DEPENDENCY(ndcurves REQUIRED) +include(dependencies.cmake) # Main Library file(GLOB mpc_SOURCE CONFIGURE_DEPENDS src/*.cpp) file(GLOB mpc_HEADER CONFIGURE_DEPENDS include/${PROJECT_NAME}/*.hpp) add_library(${PROJECT_NAME} SHARED ${mpc_HEADER} ${mpc_SOURCE}) -target_include_directories(${PROJECT_NAME} PUBLIC $) +target_include_directories( + ${PROJECT_NAME} + PUBLIC + $ + $ +) target_link_libraries( ${PROJECT_NAME} PUBLIC diff --git a/dependencies.cmake b/dependencies.cmake new file mode 100644 index 00000000..f2ee3cff --- /dev/null +++ b/dependencies.cmake @@ -0,0 +1,28 @@ +find_package(example-robot-data 4.0.9 REQUIRED) +ADD_PROJECT_DEPENDENCY(OpenMP REQUIRED) +ADD_PROJECT_DEPENDENCY(proxsuite REQUIRED) +ADD_PROJECT_DEPENDENCY(pinocchio REQUIRED) +ADD_PROJECT_DEPENDENCY(aligator REQUIRED) + +function(get_ndcurves) + find_package(ndcurves QUIET) + if(NOT ndcurves_FOUND) + FetchContent_Declare( + ndcurves + GIT_REPOSITORY "https://github.com/loco-3d/ndcurves" + GIT_PROGRESS True + GIT_TAG devel + SYSTEM + EXCLUDE_FROM_ALL + ) + set(PROJECT_CUSTOM_HEADER_DIR) + set(PROJECT_CUSTOM_HEADER_EXTENSION) + set(BUILD_PYTHON_INTERFACE OFF) + set(BUILD_TESTING OFF) + FetchContent_MakeAvailable(ndcurves) + add_library(ndcurves::ndcurves ALIAS ndcurves) + install(TARGETS ndcurves EXPORT ${TARGETS_EXPORT_NAME}) + endif() +endfunction() + +get_ndcurves() diff --git a/include/simple-mpc/foot-trajectory.hpp b/include/simple-mpc/foot-trajectory.hpp index a4d64ac2..916b33b1 100644 --- a/include/simple-mpc/foot-trajectory.hpp +++ b/include/simple-mpc/foot-trajectory.hpp @@ -6,8 +6,7 @@ // All rights reserved. /////////////////////////////////////////////////////////////////////////////// -#ifndef SIMPLE_MPC_FOOTTRAJ_HPP_ -#define SIMPLE_MPC_FOOTTRAJ_HPP_ +#pragma once #include "simple-mpc/fwd.hpp" #include @@ -19,14 +18,11 @@ namespace simple_mpc * @brief Foot trajectory generation */ - typedef Eigen::Vector3d point3_t; - typedef ndcurves::bezier_curve curve_translation; - typedef ndcurves::piecewise_curve piecewise_curve; + using point3_t = Eigen::Vector3d; + using piecewise_curve = ndcurves::piecewise_curve; class FootTrajectory { - /** - */ protected: std::map initial_poses_; std::map final_poses_; @@ -38,18 +34,21 @@ namespace simple_mpc size_t T_; public: - FootTrajectory() {}; - virtual ~FootTrajectory() {}; + explicit FootTrajectory() {}; FootTrajectory( const std::map & initial_poses, double swing_apex, int T_fly, int T_contact, size_t T); + virtual ~FootTrajectory() {}; void updateApex(double swing_apex) { swing_apex_ = swing_apex; } + piecewise_curve defineTranslationBezier(const point3_t & trans_init, const point3_t & trans_final); + std::vector createTrajectory( int time_to_land, point3_t & initial_trans, point3_t & final_trans, piecewise_curve trajectory_swing); + void updateTrajectory( bool update, int landing_time, @@ -63,9 +62,3 @@ namespace simple_mpc }; } // namespace simple_mpc - -/* --- Details -------------------------------------------------------------- */ -/* --- Details -------------------------------------------------------------- */ -/* --- Details -------------------------------------------------------------- */ - -#endif // SIMPLE_MPC_HPP_ diff --git a/src/foot-trajectory.cpp b/src/foot-trajectory.cpp index b5b28b94..541e8f49 100644 --- a/src/foot-trajectory.cpp +++ b/src/foot-trajectory.cpp @@ -15,6 +15,7 @@ namespace simple_mpc { + using curve_translation = ndcurves::bezier_curve; FootTrajectory::FootTrajectory( const std::map & initial_poses, double swing_apex, int T_fly, int T_contact, size_t T)