Skip to content
This repository has been archived by the owner on Jul 8, 2024. It is now read-only.

Commit

Permalink
Remove unused fmtlib prints and formatters (#94)
Browse files Browse the repository at this point in the history
The optimizer doesn't use fmtlib for anything, so it was removed.
  • Loading branch information
calcmogul authored Feb 17, 2024
1 parent ce27588 commit 89dfa03
Show file tree
Hide file tree
Showing 45 changed files with 21 additions and 796 deletions.
30 changes: 7 additions & 23 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -91,24 +91,6 @@ cmake_dependent_option(

include(FetchContent)

# fmt dependency
fetchcontent_declare(
fmt
GIT_REPOSITORY https://github.com/fmtlib/fmt.git
GIT_TAG 10.2.1
)
fetchcontent_makeavailable(fmt)

if(
${OPTIMIZER_BACKEND} STREQUAL "casadi"
AND ${CMAKE_SYSTEM_NAME} STREQUAL "Linux"
AND ${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU"
)
target_compile_definitions(fmt PRIVATE _GLIBCXX_USE_CXX11_ABI=0)
endif()

target_link_libraries(TrajoptLib PUBLIC fmt::fmt)

if(BUILD_TESTING)
# Catch2 dependency
fetchcontent_declare(
Expand Down Expand Up @@ -151,13 +133,15 @@ if(${OPTIMIZER_BACKEND} STREQUAL "casadi")
install(FILES ${CASADI_INSTALL_LIBS} DESTINATION ${CASADI_INSTALL_DEST})
elseif(${OPTIMIZER_BACKEND} STREQUAL "sleipnir")
message(STATUS "Using Sleipnir optimizer")
include(FetchSleipnir)
fetch_sleipnir()
fetchcontent_declare(
Sleipnir
GIT_REPOSITORY https://github.com/SleipnirGroup/Sleipnir.git
# main on 2024-02-16
GIT_TAG 71994a021395711cc3992603d1a226e2118a3a0a
)
fetchcontent_makeavailable(Sleipnir)
target_compile_definitions(TrajoptLib PRIVATE OPTIMIZER_BACKEND_SLEIPNIR)
target_link_libraries(TrajoptLib PRIVATE Sleipnir)

# Install Sleipnir manually because EXCLUDE_FROM_ALL was used during import
install(TARGETS Sleipnir)
endif()

target_include_directories(
Expand Down
20 changes: 0 additions & 20 deletions cmake/modules/FetchSleipnir.cmake

This file was deleted.

11 changes: 0 additions & 11 deletions cmake/modules/TrajoptLibCompilerFlags.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,6 @@ macro(trajoptlib_compiler_flags target)
PRIVATE _GLIBCXX_USE_CXX11_ABI=0
)
endif()

# Disable warning false positives in fmt
if(
${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU"
AND ${CMAKE_CXX_COMPILER_VERSION} VERSION_GREATER_EQUAL "13"
)
target_compile_options(
${target}
PRIVATE -Wno-dangling-reference -Wno-stringop-overflow
)
endif()
else()
target_compile_options(
${target}
Expand Down
11 changes: 2 additions & 9 deletions examples/Swerve/src/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#include <numbers>
#include <vector>

#include <fmt/core.h>
#include <trajopt/IncompatibleTrajectoryException.h>
#include <trajopt/OptimalTrajectoryGenerator.h>
#include <trajopt/constraint/Constraint.h>
Expand Down Expand Up @@ -42,12 +41,6 @@ int main() {
path.ControlIntervalCounts({4});

// SOLVE
try {
SwerveSolution solution = OptimalTrajectoryGenerator::Generate(path);
fmt::print("[{}]\n", fmt::join(path.CalculateInitialGuess().x, ","));
fmt::print("{}\n", solution);
// fmt::print("{}\n", HolonomicTrajectory(solution));
} catch (const std::exception& e) {
fmt::print("{}", e.what());
}
[[maybe_unused]] SwerveSolution solution =
OptimalTrajectoryGenerator::Generate(path);
}
13 changes: 0 additions & 13 deletions include/trajopt/constraint/AngularVelocityConstraint.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,8 @@

#pragma once

#include <optional>

#include "trajopt/SymbolExports.h"
#include "trajopt/set/IntervalSet1d.h"
#include "trajopt/solution/SolutionChecking.h"

namespace trajopt {

Expand All @@ -16,16 +13,6 @@ namespace trajopt {
struct TRAJOPT_DLLEXPORT AngularVelocityConstraint {
/// The angular velocity bounds.
IntervalSet1d angularVelocityBound;

/**
* Returns an error if the angular velocity is outside the bounds.
*
* @param angularVelocity The angular velocity.
* @param tolerances The tolerances considered to satisfy the constraint.
*/
std::optional<SolutionError> CheckAngularVelocity(
double angularVelocity,
const SolutionTolerances& tolerances) const noexcept;
};

} // namespace trajopt
16 changes: 0 additions & 16 deletions include/trajopt/constraint/Constraint.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,13 @@

#pragma once

#include <optional>
#include <variant>

#include "trajopt/SymbolExports.h"
#include "trajopt/constraint/AngularVelocityConstraint.h"
#include "trajopt/constraint/HeadingConstraint.h"
#include "trajopt/constraint/LinePointConstraint.h"
#include "trajopt/constraint/PointLineConstraint.h"
#include "trajopt/constraint/PointPointConstraint.h"
#include "trajopt/constraint/TranslationConstraint.h"
#include "trajopt/solution/SolutionChecking.h"

namespace trajopt {

Expand Down Expand Up @@ -52,16 +48,4 @@ using Constraint =
std::variant<TranslationConstraint, HeadingConstraint, LinePointConstraint,
PointLineConstraint, PointPointConstraint>;

/**
* Returns an error if the state doesn't satisfy the constraint.
*
* @param x The x coordinate.
* @param y The y coordinate.
* @param heading The heading.
* @param tolerances The tolerances considered to satisfy the constraint.
*/
std::optional<SolutionError> CheckState(
const Constraint& constraint, double x, double y, double heading,
const SolutionTolerances& tolerances) noexcept;

} // namespace trajopt
12 changes: 0 additions & 12 deletions include/trajopt/constraint/HeadingConstraint.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,8 @@

#pragma once

#include <optional>

#include "trajopt/SymbolExports.h"
#include "trajopt/set/IntervalSet1d.h"
#include "trajopt/solution/SolutionChecking.h"

namespace trajopt {

Expand All @@ -16,15 +13,6 @@ namespace trajopt {
struct TRAJOPT_DLLEXPORT HeadingConstraint {
/// The heading bound.
IntervalSet1d headingBound;

/**
* Returns an error if the given heading isn't in the heading region.
*
* @param theta The heading.
* @param tolerances The tolerances considered to satisfy the constraint.
*/
std::optional<SolutionError> CheckHeading(
double theta, const SolutionTolerances& tolerances) const noexcept;
};

} // namespace trajopt
13 changes: 0 additions & 13 deletions include/trajopt/constraint/TranslationConstraint.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,8 @@

#pragma once

#include <optional>

#include "trajopt/SymbolExports.h"
#include "trajopt/set/Set2d.h"
#include "trajopt/solution/SolutionChecking.h"

namespace trajopt {

Expand All @@ -16,16 +13,6 @@ namespace trajopt {
struct TRAJOPT_DLLEXPORT TranslationConstraint {
/// Translation bound.
Set2d translationBound;

/**
* Returns an error if the given position doesn't satisfy the constraint.
*
* @param x The position's x component.
* @param y The position's y component.
* @param tolerances The tolerances considered to satisfy the constraint.
*/
std::optional<SolutionError> CheckTranslation(
double x, double y, const SolutionTolerances& tolerances) const noexcept;
};

} // namespace trajopt
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,8 @@

#pragma once

#include <optional>

#include <fmt/format.h>

#include "trajopt/SymbolExports.h"
#include "trajopt/constraint/Constraint.h"
#include "trajopt/set/IntervalSet1d.h"
#include "trajopt/solution/SolutionChecking.h"

namespace trajopt {

Expand All @@ -20,31 +14,5 @@ struct TRAJOPT_DLLEXPORT DifferentialCentripetalAccelerationConstraint {
/// Acceleration bound.
IntervalSet1d accelerationBound;
};
} // namespace trajopt

/**
* Formatter for DifferentialCentripetalAccelerationConstraint.
*/
//! @cond Doxygen_Suppress
template <>
struct fmt::formatter<trajopt::DifferentialCentripetalAccelerationConstraint> {
//! @endcond
/**
* Format string parser.
*
* @param ctx Format string context.
*/
constexpr auto parse(fmt::format_parse_context& ctx) { return ctx.begin(); }

/**
* Writes out a formatted DifferentialCentripetalAccelerationConstraint.
*
* @param constraint DifferentialCentripetalAccelerationConstraint instance.
* @param ctx Format string context.
*/
auto format([[maybe_unused]] const trajopt::
DifferentialCentripetalAccelerationConstraint& constraint,
fmt::format_context& ctx) const {
return fmt::format_to(ctx.out(), "diff centrip acceleration bound");
}
};
} // namespace trajopt
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,10 @@

#pragma once

#include <variant>

#include "trajopt/SymbolExports.h"
#include "trajopt/constraint/AngularVelocityConstraint.h"
#include "trajopt/constraint/Constraint.h"
#include "trajopt/constraint/differential/DifferentialCentripetalAccelerationConstraint.h"
#include "trajopt/constraint/differential/DifferentialTangentialVelocityConstraint.h"
#include "trajopt/solution/SolutionChecking.h"
#include "trajopt/util/AppendVariant.h"

namespace trajopt {
Expand All @@ -18,4 +14,5 @@ using DifferentialConstraint =
decltype(_append_variant(Constraint{}, AngularVelocityConstraint{},
DifferentialTangentialVelocityConstraint{},
DifferentialCentripetalAccelerationConstraint{}));

} // namespace trajopt
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,8 @@

#pragma once

#include <optional>

#include "trajopt/SymbolExports.h"
#include "trajopt/constraint/Constraint.h"
#include "trajopt/set/IntervalSet1d.h"
#include "trajopt/solution/SolutionChecking.h"

namespace trajopt {

Expand All @@ -18,4 +14,5 @@ struct TRAJOPT_DLLEXPORT DifferentialTangentialVelocityConstraint {
/// Velocity bound.
IntervalSet1d velocityBound;
};

} // namespace trajopt
25 changes: 1 addition & 24 deletions include/trajopt/constraint/holonomic/HolonomicConstraint.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,14 @@

#pragma once

#include <variant>

#include "trajopt/SymbolExports.h"
#include "trajopt/constraint/AngularVelocityConstraint.h"
#include "trajopt/constraint/Constraint.h"
#include "trajopt/constraint/holonomic/HolonomicVelocityConstraint.h"
#include "trajopt/solution/SolutionChecking.h"
#include "trajopt/util/AppendVariant.h"

namespace trajopt {

using HolonomicConstraint = decltype(_append_variant(
Constraint{}, AngularVelocityConstraint{}, HolonomicVelocityConstraint{}));

/**
* Returns an error if the given state doesn't satisfy the constraint.
*
* @param x The x coordinate.
* @param y The y coordinate.
* @param heading The heading.
* @param velocityX The velocity's x component.
* @param velocityY The velocity's y component.
* @param angularVelocity The angular velocity.
* @param accelerationX The acceleration's x component.
* @param accelerationY The acceleration's y component.
* @param angularAcceleration The angular acceleration.
* @param tolerances The tolerances considered to satisfy the constraint.
*/
std::optional<SolutionError> CheckState(
const HolonomicConstraint& constraint, double x, double y, double heading,
double velocityX, double velocityY, double angularVelocity,
double accelerationX, double accelerationY, double angularAcceleration,
const SolutionTolerances& tolerances) noexcept;

} // namespace trajopt
14 changes: 0 additions & 14 deletions include/trajopt/constraint/holonomic/HolonomicVelocityConstraint.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,9 @@

#pragma once

#include <optional>

#include "trajopt/SymbolExports.h"
#include "trajopt/constraint/Constraint.h"
#include "trajopt/set/Set2d.h"
#include "trajopt/solution/SolutionChecking.h"

namespace trajopt {

Expand All @@ -20,17 +17,6 @@ struct TRAJOPT_DLLEXPORT HolonomicVelocityConstraint {

/// Coordinate system.
CoordinateSystem coordinateSystem;

/**
* Returns an error if the given velocity doesn't satisfy the constraint.
*
* @param velocityX The velocity's x component.
* @param velocityY The velocity's y component.
* @param tolerances The tolerances considered to satisfy the constraint.
*/
std::optional<SolutionError> CheckVelocity(
double velocityX, double velocityY,
const SolutionTolerances& tolerances) const noexcept;
};

} // namespace trajopt
1 change: 1 addition & 0 deletions include/trajopt/drivetrain/DifferentialDrivetrain.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,5 @@ struct TRAJOPT_DLLEXPORT DifferentialDrivetrain {
/// the right driverail
DifferentialDriverail right;
};

} // namespace trajopt
Loading

0 comments on commit 89dfa03

Please sign in to comment.