Skip to content
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

Add stuck detection #19

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docker/Dockerfile.pc
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ ENV DOCKERUSER=${DOCKERUSER}
COPY bashrc /tmp/bashrc
RUN cat /tmp/bashrc >> /${DOCKERUSER}/.bashrc

RUN wget https://s3.us-west-1.amazonaws.com/download.behaviortree.dev/groot2_linux_installer/Groot2-v1.1.1-x86_64.AppImage -O /usr/bin/groot2 && \
RUN wget https://s3.us-west-1.amazonaws.com/download.behaviortree.dev/groot2_linux_installer/Groot2-v1.4.0-x86_64.AppImage -O /usr/bin/groot2 && \
chmod +x /usr/bin/groot2

USER ${DOCKERUSER}
Expand Down
3 changes: 3 additions & 0 deletions spes_move/include/spes_move/move.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ namespace spes_move
int update_rate_;
double stopping_distance_;

double angular_stuck_coeff_;
double linear_stuck_coeff_;

spes_msgs::msg::MoveState state_msg_;

rclcpp::Publisher<geometry_msgs::msg::Twist>::SharedPtr cmd_vel_pub_;
Expand Down
22 changes: 21 additions & 1 deletion spes_move/src/move.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,20 @@ namespace spes_move
break;
}

// Detect stuck
const double planned_rotation_velocity = rotation_ruckig_output_.new_velocity[0];
const double planned_translation_velocity = translation_ruckig_output_.new_velocity[0];
if (abs(last_error_x_) > abs(planned_translation_velocity * linear_stuck_coeff_) || abs(last_error_yaw_) > abs(planned_rotation_velocity * angular_stuck_coeff_)) {
stop_robot();
RCLCPP_WARN(get_logger(), "Stuck detected, stopping...");

state_msg_.error = spes_msgs::msg::MoveState::ERROR_STUCK;

state_ = spes_msgs::msg::MoveState::STATE_IDLE;
update_state_msg(tf_base_target);
state_pub_->publish(state_msg_);
}

// Stop if there is a collision
if (!command_->ignore_obstacles)
{
Expand Down Expand Up @@ -382,7 +396,7 @@ namespace spes_move
if (is_collision_ahead)
{
stop_robot();
RCLCPP_WARN(get_logger(), "Collision Ahead - Exiting Move");
RCLCPP_WARN(get_logger(), "Collision detected, stopping...");

state_msg_.error = spes_msgs::msg::MoveState::ERROR_OBSTACLE;

Expand Down Expand Up @@ -554,6 +568,9 @@ namespace spes_move
declare_parameter("linear.tolerance", rclcpp::ParameterValue(0.01));
get_parameter("linear.tolerance", default_command_->linear_properties.tolerance);

declare_parameter("linear.stuck_coeff", rclcpp::ParameterValue(0.1));
get_parameter("linear.stuck_coeff", linear_stuck_coeff_);

// Angular
declare_parameter("angular.kp", rclcpp::ParameterValue(5.0));
get_parameter("angular.kp", default_command_->angular_properties.kp);
Expand All @@ -569,6 +586,9 @@ namespace spes_move

declare_parameter("angular.tolerance", rclcpp::ParameterValue(0.03));
get_parameter("angular.tolerance", default_command_->angular_properties.tolerance);

declare_parameter("angular.stuck_coeff", rclcpp::ParameterValue(0.1));
get_parameter("angular.stuck_coeff", angular_stuck_coeff_);
}

void Move::debouncing_reset()
Expand Down