Skip to content

Commit

Permalink
remove the joint range limiter header and reuse it from the joint sat…
Browse files Browse the repository at this point in the history
…uration limiter + merge them into a single library
  • Loading branch information
saikishor committed Apr 16, 2024
1 parent 694da1e commit cb115c6
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 123 deletions.
15 changes: 1 addition & 14 deletions joint_limits/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ target_compile_definitions(joint_limiter_interface PRIVATE "JOINT_LIMITS_BUILDIN

add_library(joint_saturation_limiter SHARED
src/joint_saturation_limiter.cpp
src/joint_range_limiter.cpp
)
target_compile_features(joint_saturation_limiter PUBLIC cxx_std_17)
target_include_directories(joint_saturation_limiter PUBLIC
Expand All @@ -56,19 +57,6 @@ ament_target_dependencies(joint_saturation_limiter PUBLIC ${THIS_PACKAGE_INCLUDE
# which is appropriate when building the dll but not consuming it.
target_compile_definitions(joint_saturation_limiter PRIVATE "JOINT_LIMITS_BUILDING_DLL")

add_library(joint_range_limiter SHARED
src/joint_range_limiter.cpp
)
target_compile_features(joint_range_limiter PUBLIC cxx_std_17)
target_include_directories(joint_range_limiter PUBLIC
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include/joint_limits>
)
ament_target_dependencies(joint_range_limiter PUBLIC ${THIS_PACKAGE_INCLUDE_DEPENDS})
# Causes the visibility macros to use dllexport rather than dllimport,
# which is appropriate when building the dll but not consuming it.
target_compile_definitions(joint_range_limiter PRIVATE "JOINT_LIMITS_BUILDING_DLL")

pluginlib_export_plugin_description_file(joint_limits joint_limiters.xml)

if(BUILD_TESTING)
Expand Down Expand Up @@ -116,7 +104,6 @@ install(TARGETS
joint_limits
joint_limiter_interface
joint_saturation_limiter
joint_range_limiter
EXPORT export_joint_limits
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
Expand Down
96 changes: 0 additions & 96 deletions joint_limits/include/joint_limits/joint_range_limiter.hpp

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,9 @@ class JointSaturationLimiter : public JointLimiterInterface<LimitsType, JointLim
JOINT_LIMITS_PUBLIC bool on_init() override { return true; }

JOINT_LIMITS_PUBLIC bool on_configure(
const JointLimitsStateDataType & /*current_joint_states*/) override
const JointLimitsStateDataType & current_joint_states) override
{
prev_command_ = current_joint_states;
return true;
}

Expand All @@ -75,6 +76,7 @@ class JointSaturationLimiter : public JointLimiterInterface<LimitsType, JointLim

private:
rclcpp::Clock::SharedPtr clock_;
JointLimitsStateDataType prev_command_;
};

template <typename LimitsType, typename JointLimitsStateDataType>
Expand Down
6 changes: 2 additions & 4 deletions joint_limits/joint_limiters.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@
Simple joint limiter using clamping approach. Warning: clamping can cause discontinuities.
</description>
</class>
</library>
<library path="joint_range_limiter">
<class name="joint_limits/JointRangeLimiter"
type="JointInterfacesRangeLimiter"
<class name="joint_limits/JointInterfacesSaturationLimiter"
type="JointInterfacesSaturationLimiter"
base_class_type="joint_limits::JointLimiterInterface&lt;joint_limits::JointLimits, joint_limits::JointControlInterfacesData&gt;">
<description>
Simple joint range limiter using clamping approach with the parsed limits.
Expand Down
17 changes: 9 additions & 8 deletions joint_limits/src/joint_range_limiter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

/// \author Sai Kishor Kothakota

#include "joint_limits/joint_range_limiter.hpp"
#include "joint_limits/joint_saturation_limiter.hpp"

#include <algorithm>
#include "joint_limits/joint_limiter_struct.hpp"
Expand Down Expand Up @@ -119,21 +119,22 @@ namespace joint_limits
{

template <>
bool JointRangeLimiter<JointLimits, JointControlInterfacesData>::on_init()
bool JointSaturationLimiter<JointLimits, JointControlInterfacesData>::on_init()
{
const bool result = (number_of_joints_ != 1);
if (!result && has_logging_interface())
{
RCLCPP_ERROR(
node_logging_itf_->get_logger(),
"JointLimiter: The JointRangeLimiter expects the number of joints to be 1, but given : %zu",
"JointLimiter: The JointSaturationLimiter expects the number of joints to be 1, but given : "
"%zu",
number_of_joints_);
}
return result;
}

template <>
bool JointRangeLimiter<JointLimits, JointControlInterfacesData>::on_enforce(
bool JointSaturationLimiter<JointLimits, JointControlInterfacesData>::on_enforce(
JointControlInterfacesData & actual, JointControlInterfacesData & desired,
const rclcpp::Duration & dt)
{
Expand Down Expand Up @@ -225,10 +226,10 @@ bool JointRangeLimiter<JointLimits, JointControlInterfacesData>::on_enforce(

// typedefs are needed here to avoid issues with macro expansion. ref:
// https://stackoverflow.com/a/8942986
typedef joint_limits::JointRangeLimiter<
typedef joint_limits::JointSaturationLimiter<
joint_limits::JointLimits, joint_limits::JointControlInterfacesData>
JointInterfacesRangeLimiter;
JointInterfacesSaturationLimiter;
typedef joint_limits::JointLimiterInterface<
joint_limits::JointLimits, joint_limits::JointControlInterfacesData>
JointInterfacesRangeLimiterBase;
PLUGINLIB_EXPORT_CLASS(JointInterfacesRangeLimiter, JointInterfacesRangeLimiterBase)
JointInterfacesSaturationLLimiterBase;
PLUGINLIB_EXPORT_CLASS(JointInterfacesSaturationLimiter, JointInterfacesSaturationLLimiterBase)

0 comments on commit cb115c6

Please sign in to comment.