Skip to content

Commit cb115c6

Browse files
committed
remove the joint range limiter header and reuse it from the joint saturation limiter + merge them into a single library
1 parent 694da1e commit cb115c6

File tree

5 files changed

+15
-123
lines changed

5 files changed

+15
-123
lines changed

joint_limits/CMakeLists.txt

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ target_compile_definitions(joint_limiter_interface PRIVATE "JOINT_LIMITS_BUILDIN
4545

4646
add_library(joint_saturation_limiter SHARED
4747
src/joint_saturation_limiter.cpp
48+
src/joint_range_limiter.cpp
4849
)
4950
target_compile_features(joint_saturation_limiter PUBLIC cxx_std_17)
5051
target_include_directories(joint_saturation_limiter PUBLIC
@@ -56,19 +57,6 @@ ament_target_dependencies(joint_saturation_limiter PUBLIC ${THIS_PACKAGE_INCLUDE
5657
# which is appropriate when building the dll but not consuming it.
5758
target_compile_definitions(joint_saturation_limiter PRIVATE "JOINT_LIMITS_BUILDING_DLL")
5859

59-
add_library(joint_range_limiter SHARED
60-
src/joint_range_limiter.cpp
61-
)
62-
target_compile_features(joint_range_limiter PUBLIC cxx_std_17)
63-
target_include_directories(joint_range_limiter PUBLIC
64-
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
65-
$<INSTALL_INTERFACE:include/joint_limits>
66-
)
67-
ament_target_dependencies(joint_range_limiter PUBLIC ${THIS_PACKAGE_INCLUDE_DEPENDS})
68-
# Causes the visibility macros to use dllexport rather than dllimport,
69-
# which is appropriate when building the dll but not consuming it.
70-
target_compile_definitions(joint_range_limiter PRIVATE "JOINT_LIMITS_BUILDING_DLL")
71-
7260
pluginlib_export_plugin_description_file(joint_limits joint_limiters.xml)
7361

7462
if(BUILD_TESTING)
@@ -116,7 +104,6 @@ install(TARGETS
116104
joint_limits
117105
joint_limiter_interface
118106
joint_saturation_limiter
119-
joint_range_limiter
120107
EXPORT export_joint_limits
121108
ARCHIVE DESTINATION lib
122109
LIBRARY DESTINATION lib

joint_limits/include/joint_limits/joint_range_limiter.hpp

Lines changed: 0 additions & 96 deletions
This file was deleted.

joint_limits/include/joint_limits/joint_saturation_limiter.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,9 @@ class JointSaturationLimiter : public JointLimiterInterface<LimitsType, JointLim
4949
JOINT_LIMITS_PUBLIC bool on_init() override { return true; }
5050

5151
JOINT_LIMITS_PUBLIC bool on_configure(
52-
const JointLimitsStateDataType & /*current_joint_states*/) override
52+
const JointLimitsStateDataType & current_joint_states) override
5353
{
54+
prev_command_ = current_joint_states;
5455
return true;
5556
}
5657

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

7677
private:
7778
rclcpp::Clock::SharedPtr clock_;
79+
JointLimitsStateDataType prev_command_;
7880
};
7981

8082
template <typename LimitsType, typename JointLimitsStateDataType>

joint_limits/joint_limiters.xml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,8 @@
77
Simple joint limiter using clamping approach. Warning: clamping can cause discontinuities.
88
</description>
99
</class>
10-
</library>
11-
<library path="joint_range_limiter">
12-
<class name="joint_limits/JointRangeLimiter"
13-
type="JointInterfacesRangeLimiter"
10+
<class name="joint_limits/JointInterfacesSaturationLimiter"
11+
type="JointInterfacesSaturationLimiter"
1412
base_class_type="joint_limits::JointLimiterInterface&lt;joint_limits::JointLimits, joint_limits::JointControlInterfacesData&gt;">
1513
<description>
1614
Simple joint range limiter using clamping approach with the parsed limits.

joint_limits/src/joint_range_limiter.cpp

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
/// \author Sai Kishor Kothakota
1616

17-
#include "joint_limits/joint_range_limiter.hpp"
17+
#include "joint_limits/joint_saturation_limiter.hpp"
1818

1919
#include <algorithm>
2020
#include "joint_limits/joint_limiter_struct.hpp"
@@ -119,21 +119,22 @@ namespace joint_limits
119119
{
120120

121121
template <>
122-
bool JointRangeLimiter<JointLimits, JointControlInterfacesData>::on_init()
122+
bool JointSaturationLimiter<JointLimits, JointControlInterfacesData>::on_init()
123123
{
124124
const bool result = (number_of_joints_ != 1);
125125
if (!result && has_logging_interface())
126126
{
127127
RCLCPP_ERROR(
128128
node_logging_itf_->get_logger(),
129-
"JointLimiter: The JointRangeLimiter expects the number of joints to be 1, but given : %zu",
129+
"JointLimiter: The JointSaturationLimiter expects the number of joints to be 1, but given : "
130+
"%zu",
130131
number_of_joints_);
131132
}
132133
return result;
133134
}
134135

135136
template <>
136-
bool JointRangeLimiter<JointLimits, JointControlInterfacesData>::on_enforce(
137+
bool JointSaturationLimiter<JointLimits, JointControlInterfacesData>::on_enforce(
137138
JointControlInterfacesData & actual, JointControlInterfacesData & desired,
138139
const rclcpp::Duration & dt)
139140
{
@@ -225,10 +226,10 @@ bool JointRangeLimiter<JointLimits, JointControlInterfacesData>::on_enforce(
225226

226227
// typedefs are needed here to avoid issues with macro expansion. ref:
227228
// https://stackoverflow.com/a/8942986
228-
typedef joint_limits::JointRangeLimiter<
229+
typedef joint_limits::JointSaturationLimiter<
229230
joint_limits::JointLimits, joint_limits::JointControlInterfacesData>
230-
JointInterfacesRangeLimiter;
231+
JointInterfacesSaturationLimiter;
231232
typedef joint_limits::JointLimiterInterface<
232233
joint_limits::JointLimits, joint_limits::JointControlInterfacesData>
233-
JointInterfacesRangeLimiterBase;
234-
PLUGINLIB_EXPORT_CLASS(JointInterfacesRangeLimiter, JointInterfacesRangeLimiterBase)
234+
JointInterfacesSaturationLLimiterBase;
235+
PLUGINLIB_EXPORT_CLASS(JointInterfacesSaturationLimiter, JointInterfacesSaturationLLimiterBase)

0 commit comments

Comments
 (0)