-
Notifications
You must be signed in to change notification settings - Fork 393
Implement realtime-safe stall detection for parallel gripper controller #1855
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -159,7 +159,7 @@ void GripperActionController::accepted_callback( | |||||
pre_alloc_result_->reached_goal = false; | ||||||
pre_alloc_result_->stalled = false; | ||||||
|
||||||
last_movement_time_ = get_node()->now(); | ||||||
last_movement_time_.set(get_node()->now()); | ||||||
rt_goal->execute(); | ||||||
rt_active_goal_.set([rt_goal](RealtimeGoalHandlePtr & stored_value) { stored_value = rt_goal; }); | ||||||
|
||||||
|
@@ -216,7 +216,7 @@ void GripperActionController::check_for_success( | |||||
double current_velocity) | ||||||
{ | ||||||
RealtimeGoalHandlePtr active_goal; | ||||||
rt_active_goal_.get([&](const RealtimeGoalHandlePtr & goal) { active_goal = goal; }); | ||||||
rt_active_goal_.try_get([&](const RealtimeGoalHandlePtr & goal) { active_goal = goal; }); | ||||||
if (!active_goal) | ||||||
{ | ||||||
return; | ||||||
|
@@ -230,34 +230,41 @@ void GripperActionController::check_for_success( | |||||
pre_alloc_result_->stalled = false; | ||||||
RCLCPP_DEBUG(get_node()->get_logger(), "Successfully moved to goal."); | ||||||
active_goal->setSucceeded(pre_alloc_result_); | ||||||
rt_active_goal_.set([](RealtimeGoalHandlePtr & stored_value) | ||||||
{ stored_value = RealtimeGoalHandlePtr(); }); | ||||||
rt_active_goal_.try_set([](RealtimeGoalHandlePtr & stored_value) | ||||||
{ stored_value = RealtimeGoalHandlePtr(); }); | ||||||
} | ||||||
else | ||||||
{ | ||||||
if (fabs(current_velocity) > params_.stall_velocity_threshold) | ||||||
{ | ||||||
last_movement_time_ = time; | ||||||
last_movement_time_.try_set(time); | ||||||
ashwinsushil marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
} | ||||||
else if ((time - last_movement_time_).seconds() > params_.stall_timeout) | ||||||
else | ||||||
{ | ||||||
pre_alloc_result_->state.effort[0] = computed_command_; | ||||||
pre_alloc_result_->state.position[0] = current_position; | ||||||
pre_alloc_result_->reached_goal = false; | ||||||
pre_alloc_result_->stalled = true; | ||||||
|
||||||
if (params_.allow_stalling) | ||||||
auto last_time_opt = last_movement_time_.try_get(); | ||||||
ashwinsushil marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
if ( | ||||||
last_time_opt.has_value() && | ||||||
(time - last_time_opt.value()).seconds() > params_.stall_timeout) | ||||||
{ | ||||||
RCLCPP_DEBUG(get_node()->get_logger(), "Stall detected moving to goal. Returning success."); | ||||||
active_goal->setSucceeded(pre_alloc_result_); | ||||||
pre_alloc_result_->state.effort[0] = computed_command_; | ||||||
pre_alloc_result_->state.position[0] = current_position; | ||||||
pre_alloc_result_->reached_goal = false; | ||||||
pre_alloc_result_->stalled = true; | ||||||
|
||||||
if (params_.allow_stalling) | ||||||
{ | ||||||
RCLCPP_DEBUG( | ||||||
get_node()->get_logger(), "Stall detected moving to goal. Returning success."); | ||||||
active_goal->setSucceeded(pre_alloc_result_); | ||||||
} | ||||||
else | ||||||
{ | ||||||
RCLCPP_DEBUG(get_node()->get_logger(), "Stall detected moving to goal. Aborting action!"); | ||||||
active_goal->setAborted(pre_alloc_result_); | ||||||
} | ||||||
rt_active_goal_.try_set([](RealtimeGoalHandlePtr & stored_value) | ||||||
{ stored_value = RealtimeGoalHandlePtr(); }); | ||||||
} | ||||||
else | ||||||
{ | ||||||
RCLCPP_DEBUG(get_node()->get_logger(), "Stall detected moving to goal. Aborting action!"); | ||||||
active_goal->setAborted(pre_alloc_result_); | ||||||
} | ||||||
rt_active_goal_.set([](RealtimeGoalHandlePtr & stored_value) | ||||||
{ stored_value = RealtimeGoalHandlePtr(); }); | ||||||
} | ||||||
} | ||||||
} | ||||||
|
@@ -378,6 +385,8 @@ controller_interface::CallbackReturn GripperActionController::on_activate( | |||||
pre_alloc_result_->reached_goal = false; | ||||||
pre_alloc_result_->stalled = false; | ||||||
|
||||||
last_movement_time_.try_set(rclcpp::Time(0, 0, RCL_ROS_TIME)); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Sorry, it's just this one. Initializing with ROS time is still a valid time, better set an invalid type There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @saikishor Of course! No worries. I'll commit this suggestion real quick. May I ask what’s the main reason for this change? You don’t want the time to be valid in |
||||||
|
||||||
// Action interface | ||||||
action_server_ = rclcpp_action::create_server<control_msgs::action::ParallelGripperCommand>( | ||||||
get_node(), "~/gripper_cmd", | ||||||
|
Uh oh!
There was an error while loading. Please reload this page.