-
Notifications
You must be signed in to change notification settings - Fork 153
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
Velocity Command Ignored Checking #321
Changes from 6 commits
cb5f286
924c598
21d738c
589e118
bb6eb9a
87f7c05
5517f16
caed98a
faa8654
e566020
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 | ||||
---|---|---|---|---|---|---|
|
@@ -72,6 +72,7 @@ AbstractControllerExecution::AbstractControllerExecution( | |||||
private_nh.param("dist_tolerance", dist_tolerance_, 0.1); | ||||||
private_nh.param("angle_tolerance", angle_tolerance_, M_PI / 18.0); | ||||||
private_nh.param("tf_timeout", tf_timeout_, 1.0); | ||||||
private_nh.param("cmd_vel_ignored_tolerance", cmd_vel_ignored_tolerance_, 5.0); | ||||||
|
||||||
// dynamically reconfigurable parameters | ||||||
reconfigure(config); | ||||||
|
@@ -185,6 +186,47 @@ void AbstractControllerExecution::setVelocityCmd(const geometry_msgs::TwistStamp | |||||
// TODO so there should be no loss of information in the feedback stream | ||||||
} | ||||||
|
||||||
bool AbstractControllerExecution::checkCmdVelIgnored(const geometry_msgs::Twist& cmd_vel) | ||||||
{ | ||||||
// check if the velocity ignore check is enabled or not | ||||||
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
|
||||||
if (cmd_vel_ignored_tolerance_ <= 0.0) | ||||||
{ | ||||||
return false; | ||||||
} | ||||||
|
||||||
const bool robot_stopped = robot_info_.isRobotStopped(1e-3, 1e-3); | ||||||
|
||||||
// compute linear and angular velocity magnitude | ||||||
const double cmd_linear = std::hypot(cmd_vel.linear.x, cmd_vel.linear.y); | ||||||
const double cmd_angular = std::abs(cmd_vel.angular.z); | ||||||
|
||||||
const bool cmd_is_zero = (cmd_linear < 0.01 && cmd_angular < 0.01); | ||||||
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. S: maybe use 1e-3 here too? 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. I tested without the brackets and it was working fine. So I removed it. |
||||||
|
||||||
// no need to check | ||||||
if (!robot_stopped || cmd_is_zero) | ||||||
{ | ||||||
first_ignored_time_ = ros::Time::now(); | ||||||
return false; | ||||||
} | ||||||
|
||||||
// check if robot ignores the cmd_vel | ||||||
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. F: comment is wrong. you already know that the robot is ignoring |
||||||
const double ignored_duration = (ros::Time::now() - first_ignored_time_).toSec(); | ||||||
ROS_WARN_THROTTLE(1, | ||||||
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. S: maybe this should go after the error (line 234) so you don't show both WARN and ERROR together |
||||||
"Robot is ignoring velocity command for %.2f seconds. (Commanded velocity: x=%.2f, " | ||||||
"y=%.2f, w=%.2f)", | ||||||
ignored_duration, cmd_vel.linear.x, cmd_vel.linear.y, cmd_vel.angular.z); | ||||||
|
||||||
if (ignored_duration > cmd_vel_ignored_tolerance_) | ||||||
{ | ||||||
// the robot is ignoring the velocity command more the threshold time | ||||||
siferati marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
ROS_ERROR("Robot is ignoring velocity command for more than the tolerance time: %.2f seconds", | ||||||
cmd_vel_ignored_tolerance_); | ||||||
return true; // return true | ||||||
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
|
||||||
} | ||||||
|
||||||
return false; | ||||||
} | ||||||
|
||||||
geometry_msgs::TwistStamped AbstractControllerExecution::getVelocityCmd() const | ||||||
{ | ||||||
boost::lock_guard<boost::mutex> guard(vel_cmd_mtx_); | ||||||
|
@@ -278,7 +320,9 @@ void AbstractControllerExecution::run() | |||||
last_valid_cmd_time_ = ros::Time(); | ||||||
int retries = 0; | ||||||
int seq = 0; | ||||||
first_ignored_time_ = ros::Time::now(); | ||||||
|
||||||
|
||||||
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. extra line? |
||||||
try | ||||||
{ | ||||||
while (moving_ && ros::ok()) | ||||||
|
@@ -376,6 +420,12 @@ void AbstractControllerExecution::run() | |||||
vel_pub_.publish(cmd_vel_stamped.twist); | ||||||
last_valid_cmd_time_ = ros::Time::now(); | ||||||
retries = 0; | ||||||
// check if robot is ignoring velocity command | ||||||
if (checkCmdVelIgnored(cmd_vel_stamped.twist)) | ||||||
{ | ||||||
setState(ROBOT_DISABLED); | ||||||
moving_ = false; | ||||||
} | ||||||
} | ||||||
else if (outcome_ == mbf_msgs::ExePathResult::CANCELED) | ||||||
{ | ||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -310,6 +310,14 @@ void ControllerAction::runImpl(GoalHandle &goal_handle, AbstractControllerExecut | |
goal_handle.setAborted(result, result.message); | ||
break; | ||
|
||
case AbstractControllerExecution::ROBOT_DISABLED: | ||
ROS_FATAL_STREAM_NAMED(name_, "Robot ignored velocity commands for more than tolerance 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. F: You will have almost the same error log twice |
||
controller_active = false; | ||
fillExePathResult(mbf_msgs::ExePathResult::ROBOT_STUCK, | ||
"Robot ignored velocity commands for more than tolerance time!", result); | ||
goal_handle.setAborted(result, result.message); | ||
break; | ||
|
||
default: | ||
std::stringstream ss; | ||
ss << "Internal error: Unknown state in a move base flex controller execution with the number: " | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.