Skip to content

Commit 481ce37

Browse files
committed
joint position controller overloaded check
1 parent e4b5f3e commit 481ce37

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

mep3_controllers/src/joint_position_controller.cpp

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,15 @@ namespace mep3_controllers
2323
if (goal->max_velocity != 0)
2424
max_velocity = goal->max_velocity;
2525

26-
double tolerance = 99999;
26+
double tolerance = std::numeric_limits<double>::max();
2727
if (goal->tolerance != 0)
2828
tolerance = goal->tolerance;
2929

30-
double timeout = 99999;
30+
double timeout = std::numeric_limits<double>::max();
3131
if (goal->timeout != 0)
3232
timeout = goal->timeout;
3333

34-
double max_effort = 99999;
34+
double max_effort = std::numeric_limits<double>::max();
3535
if (goal->max_effort != 0)
3636
max_effort = goal->max_effort;
3737

@@ -157,7 +157,7 @@ namespace mep3_controllers
157157
joint->active = false;
158158
RCLCPP_ERROR(get_node()->get_logger(), "Joint %s timeout", joint->name.c_str());
159159
}
160-
else if (joint->effort_handle->get().get_value() > joint->max_effort)
160+
else if (std::isinf(joint->effort_handle->get().get_value()) || joint->effort_handle->get().get_value() > joint->max_effort)
161161
{
162162
result->set__result(mep3_msgs::action::JointPositionCommand::Goal::RESULT_OVERLOAD);
163163
joint->action_server->terminate_current(result);
@@ -193,7 +193,7 @@ namespace mep3_controllers
193193
});
194194
if (position_command_handle == command_interfaces_.end())
195195
{
196-
RCLCPP_ERROR(get_node()->get_logger(), "Unable to obtain joint command handle for %s", joint->name.c_str());
196+
RCLCPP_ERROR(get_node()->get_logger(), "Unable to obtain joint position command handle for %s", joint->name.c_str());
197197
return controller_interface::CallbackReturn::FAILURE;
198198
}
199199
joint->position_command_handle = std::ref(*position_command_handle);
@@ -208,7 +208,7 @@ namespace mep3_controllers
208208
});
209209
if (velocity_command_handle == command_interfaces_.end())
210210
{
211-
RCLCPP_ERROR(get_node()->get_logger(), "Unable to obtain joint command handle for %s", joint->name.c_str());
211+
RCLCPP_ERROR(get_node()->get_logger(), "Unable to obtain joint velocity command handle for %s", joint->name.c_str());
212212
return controller_interface::CallbackReturn::FAILURE;
213213
}
214214
joint->velocity_command_handle = std::ref(*velocity_command_handle);
@@ -223,7 +223,7 @@ namespace mep3_controllers
223223
});
224224
if (position_handle == state_interfaces_.end())
225225
{
226-
RCLCPP_ERROR(get_node()->get_logger(), "Unable to obtain joint state handle for %s", joint->name.c_str());
226+
RCLCPP_ERROR(get_node()->get_logger(), "Unable to obtain joint position state handle for %s", joint->name.c_str());
227227
return controller_interface::CallbackReturn::FAILURE;
228228
}
229229
joint->position_handle = std::ref(*position_handle);
@@ -238,10 +238,11 @@ namespace mep3_controllers
238238
});
239239
if (effort_handle == state_interfaces_.end())
240240
{
241-
RCLCPP_ERROR(get_node()->get_logger(), "Unable to obtain joint state handle for %s", joint->name.c_str());
241+
RCLCPP_ERROR(get_node()->get_logger(), "Unable to obtain joint effort state handle for %s", joint->name.c_str());
242242
return controller_interface::CallbackReturn::FAILURE;
243243
}
244244
joint->effort_handle = std::ref(*effort_handle);
245+
245246
}
246247
return controller_interface::CallbackReturn::SUCCESS;
247248
}

mep3_msgs/action/JointPositionCommand.action

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ float64 max_velocity # rad/s or m/s
88
float64 max_acceleration # rad/s^2 or m/s^2
99
float64 tolerance # rad or m
1010
float64 timeout # s
11-
float64 max_effort
11+
float64 max_effort # mA
1212
---
1313
float64 last_position
1414
float64 last_effort
1515
uint8 result
1616
---
1717
float64 position # rad or m
18-
float64 effort
18+
float64 effort # mA

0 commit comments

Comments
 (0)