Skip to content

Commit 4e9b20f

Browse files
committed
remove the enforce methods of the double vector as it can be handled now by types
1 parent 93a0572 commit 4e9b20f

File tree

6 files changed

+1
-145
lines changed

6 files changed

+1
-145
lines changed

joint_limits/include/joint_limits/joint_limiter_interface.hpp

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -206,19 +206,6 @@ class JointLimiterInterface
206206
return on_enforce(current_joint_states, desired_joint_states, dt);
207207
}
208208

209-
/** \brief Enforce joint limits to desired joint state for single physical quantity.
210-
*
211-
* Generic enforce method that calls implementation-specific `on_enforce` method.
212-
*
213-
* \param[in,out] desired_joint_states joint state that should be adjusted to obey the limits.
214-
* \returns true if limits are enforced, otherwise false.
215-
*/
216-
JOINT_LIMITS_PUBLIC virtual bool enforce(std::vector<double> & desired_joint_states)
217-
{
218-
joint_limits_ = *(updated_limits_.readFromRT());
219-
return on_enforce(desired_joint_states);
220-
}
221-
222209
protected:
223210
/** \brief Method is realized by an implementation.
224211
*
@@ -249,18 +236,6 @@ class JointLimiterInterface
249236
JointLimitsStateDataType & current_joint_states,
250237
JointLimitsStateDataType & desired_joint_states, const rclcpp::Duration & dt) = 0;
251238

252-
/** \brief Method is realized by an implementation.
253-
*
254-
* Filter-specific implementation of the joint limits enforce algorithm for single physical
255-
* quantity.
256-
* This method might use "effort" limits since they are often used as wild-card.
257-
* Check the documentation of the exact implementation for more details.
258-
*
259-
* \param[in,out] desired_joint_states joint state that should be adjusted to obey the limits.
260-
* \returns true if limits are enforced, otherwise false.
261-
*/
262-
JOINT_LIMITS_PUBLIC virtual bool on_enforce(std::vector<double> & desired_joint_states) = 0;
263-
264239
/** \brief Checks if the logging interface is set.
265240
* \returns true if the logging interface is available, otherwise false.
266241
*/

joint_limits/include/joint_limits/joint_range_limiter.hpp

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -75,17 +75,6 @@ class JointRangeLimiter : public JointLimiterInterface<LimitsType, JointLimitsSt
7575
JointLimitsStateDataType & actual, JointLimitsStateDataType & desired,
7676
const rclcpp::Duration & dt) override;
7777

78-
/** \brief Enforce joint limits to desired arbitrary physical quantity.
79-
* Additional, commonly used method for enforcing limits by clamping desired input value.
80-
* The limit is defined in effort limits of the `joint::limits/JointLimit` structure.
81-
*
82-
* If `has_effort_limits` is set to false, the limits will be not enforced to a joint.
83-
*
84-
* \param[in,out] desired_joint_states physical quantity that should be adjusted to obey the
85-
* limits. \returns true if limits are enforced, otherwise false.
86-
*/
87-
JOINT_LIMITS_PUBLIC bool on_enforce(std::vector<double> & /*desired_joint_states*/) override;
88-
8978
private:
9079
rclcpp::Clock::SharedPtr clock_;
9180
JointLimitsStateDataType prev_command_;

joint_limits/include/joint_limits/joint_saturation_limiter.hpp

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -73,17 +73,6 @@ class JointSaturationLimiter : public JointLimiterInterface<LimitsType, JointLim
7373
JointLimitsStateDataType & current_joint_states,
7474
JointLimitsStateDataType & desired_joint_states, const rclcpp::Duration & dt) override;
7575

76-
/** \brief Enforce joint limits to desired arbitrary physical quantity.
77-
* Additional, commonly used method for enforcing limits by clamping desired input value.
78-
* The limit is defined in effort limits of the `joint::limits/JointLimit` structure.
79-
*
80-
* If `has_effort_limits` is set to false, the limits will be not enforced to a joint.
81-
*
82-
* \param[in,out] desired_joint_states physical quantity that should be adjusted to obey the
83-
* limits. \returns true if limits are enforced, otherwise false.
84-
*/
85-
JOINT_LIMITS_PUBLIC bool on_enforce(std::vector<double> & desired_joint_states) override;
86-
8776
private:
8877
rclcpp::Clock::SharedPtr clock_;
8978
};

joint_limits/src/joint_range_limiter.cpp

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -132,19 +132,6 @@ bool JointRangeLimiter<JointLimits, JointControlInterfacesData>::on_init()
132132
return result;
133133
}
134134

135-
template <>
136-
bool JointRangeLimiter<JointLimits, JointControlInterfacesData>::on_enforce(std::vector<double> &)
137-
{
138-
if (has_logging_interface())
139-
{
140-
RCLCPP_WARN(
141-
node_logging_itf_->get_logger(),
142-
"JointRangeLimiter::on_enforce"
143-
"(std::vector<double> & desired_joint_states) is not needed for this limiter.");
144-
}
145-
return false;
146-
}
147-
148135
template <>
149136
bool JointRangeLimiter<JointLimits, JointControlInterfacesData>::on_enforce(
150137
JointControlInterfacesData & actual, JointControlInterfacesData & desired,

joint_limits/src/joint_saturation_limiter.cpp

Lines changed: 1 addition & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -427,55 +427,13 @@ bool JointSaturationLimiter<JointLimits, trajectory_msgs::msg::JointTrajectoryPo
427427
return limits_enforced;
428428
}
429429

430-
template <>
431-
bool JointSaturationLimiter<JointLimits, trajectory_msgs::msg::JointTrajectoryPoint>::on_enforce(
432-
std::vector<double> & desired_joint_states)
433-
{
434-
std::vector<std::string> limited_joints_effort;
435-
bool limits_enforced = false;
436-
437-
bool has_cmd = (desired_joint_states.size() == number_of_joints_);
438-
if (!has_cmd)
439-
{
440-
return false;
441-
}
442-
443-
for (size_t index = 0; index < number_of_joints_; ++index)
444-
{
445-
if (joint_limits_[index].has_effort_limits)
446-
{
447-
double max_effort = joint_limits_[index].max_effort;
448-
if (std::fabs(desired_joint_states[index]) > max_effort)
449-
{
450-
desired_joint_states[index] = std::copysign(max_effort, desired_joint_states[index]);
451-
limited_joints_effort.emplace_back(joint_names_[index]);
452-
limits_enforced = true;
453-
}
454-
}
455-
}
456-
457-
if (limited_joints_effort.size() > 0)
458-
{
459-
std::ostringstream ostr;
460-
for (auto jnt : limited_joints_effort)
461-
{
462-
ostr << jnt << " ";
463-
}
464-
ostr << "\b \b"; // erase last character
465-
RCLCPP_WARN_STREAM_THROTTLE(
466-
node_logging_itf_->get_logger(), *clock_, ROS_LOG_THROTTLE_PERIOD,
467-
"Joint(s) [" << ostr.str().c_str() << "] would exceed effort limits, limiting");
468-
}
469-
470-
return limits_enforced;
471-
}
472-
473430
} // namespace joint_limits
474431

475432
#include "pluginlib/class_list_macros.hpp"
476433

477434
// typedefs are needed here to avoid issues with macro expansion. ref:
478435
// https://stackoverflow.com/a/8942986
436+
typedef std::map<int, int> int_map;
479437
typedef joint_limits::JointSaturationLimiter<
480438
joint_limits::JointLimits, trajectory_msgs::msg::JointTrajectoryPoint>
481439
JointSaturationLimiterTrajectoryPoint;

joint_limits/test/test_joint_saturation_limiter.cpp

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -517,48 +517,6 @@ TEST_F(JointSaturationLimiterTest, when_deceleration_exceeded_with_no_maxdec_exp
517517
}
518518
}
519519

520-
TEST_F(JointSaturationLimiterTest, when_there_are_effort_limits_expect_them_to_be_applyed)
521-
{
522-
SetupNode("joint_saturation_limiter");
523-
Load();
524-
525-
if (joint_limiter_)
526-
{
527-
Init();
528-
Configure();
529-
530-
// value not over limit
531-
desired_joint_states_.effort[0] = 15.0;
532-
ASSERT_FALSE(joint_limiter_->enforce(desired_joint_states_.effort));
533-
534-
// value over limit
535-
desired_joint_states_.effort[0] = 21.0;
536-
ASSERT_TRUE(joint_limiter_->enforce(desired_joint_states_.effort));
537-
ASSERT_EQ(desired_joint_states_.effort[0], 20.0);
538-
}
539-
}
540-
541-
TEST_F(JointSaturationLimiterTest, when_there_are_no_effort_limits_expect_them_not_applyed)
542-
{
543-
SetupNode("joint_saturation_limiter");
544-
Load();
545-
546-
if (joint_limiter_)
547-
{
548-
Init("foo_joint_no_effort");
549-
Configure();
550-
551-
// value not over limit
552-
desired_joint_states_.effort[0] = 15.0;
553-
ASSERT_FALSE(joint_limiter_->enforce(desired_joint_states_.effort));
554-
555-
// value over limit
556-
desired_joint_states_.effort[0] = 21.0;
557-
ASSERT_FALSE(joint_limiter_->enforce(desired_joint_states_.effort));
558-
ASSERT_EQ(desired_joint_states_.effort[0], 21.0);
559-
}
560-
}
561-
562520
int main(int argc, char ** argv)
563521
{
564522
::testing::InitGoogleTest(&argc, argv);

0 commit comments

Comments
 (0)