-
Notifications
You must be signed in to change notification settings - Fork 88
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
safety_limiter: enable omni-directional safety brake #646
Changes from 2 commits
65db3c4
946f546
3c290c2
cd7958e
365d711
e1179fe
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 | ||||
---|---|---|---|---|---|---|
|
@@ -609,6 +609,86 @@ TEST_F(SafetyLimiterTest, SafetyLimitMaxVelocitiesValues) | |||||
} | ||||||
} | ||||||
|
||||||
TEST_F(SafetyLimiterTest, SafetyLimitOmniDirectional) | ||||||
{ | ||||||
ros::Rate wait(20.0); | ||||||
const double vel = 1.5; | ||||||
const double threshold_angle = std::atan2(1.0, 0.1); | ||||||
for (double angle = -M_PI; angle < M_PI; angle += M_PI / 8) | ||||||
{ | ||||||
for (int i = 0; i < 10 && ros::ok(); ++i) | ||||||
{ | ||||||
publishSinglePointPointcloud2(2.0, 0, 0, "base_link", ros::Time::now()); | ||||||
publishWatchdogReset(); | ||||||
publishTwist(0, 0); | ||||||
wait.sleep(); | ||||||
ros::spinOnce(); | ||||||
} | ||||||
|
||||||
double obstacle_x = 0.5 * std::cos(angle); | ||||||
double obstacle_y = 0.5 * std::sin(angle); | ||||||
if ((M_PI - threshold_angle) < std::abs(angle)) | ||||||
{ | ||||||
// Moving backward | ||||||
obstacle_x += -2.0; | ||||||
} | ||||||
else if (threshold_angle < std::abs(angle)) | ||||||
{ | ||||||
if (angle > 0) | ||||||
{ | ||||||
// Moving left | ||||||
obstacle_x += -1.0; | ||||||
obstacle_y += 0.1; | ||||||
} | ||||||
else | ||||||
{ | ||||||
// Moving right | ||||||
obstacle_x += -1.0; | ||||||
obstacle_y += -0.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. I think writing absolute values for each direction is easier to read. 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. Done |
||||||
// Otherwise moving forward. | ||||||
|
||||||
// 1.0 m/ss, obstacle at 0.5 m: limited to 1.0 m/s | ||||||
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
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. Done |
||||||
bool received = false; | ||||||
bool en = false; | ||||||
|
||||||
for (int i = 0; i < 10 && ros::ok(); ++i) | ||||||
{ | ||||||
if (i > 5) | ||||||
en = true; | ||||||
publishSinglePointPointcloud2(obstacle_x, obstacle_y, 0, "base_link", ros::Time::now()); | ||||||
publishWatchdogReset(); | ||||||
publishTwist(vel * std::cos(angle), 0, vel * std::sin(angle)); | ||||||
broadcastTF("odom", "base_link", 0.0, 0.0); | ||||||
|
||||||
wait.sleep(); | ||||||
ros::spinOnce(); | ||||||
if (en && cmd_vel_) | ||||||
{ | ||||||
received = true; | ||||||
const double current_speed = std::hypot(cmd_vel_->linear.x, cmd_vel_->linear.y); | ||||||
ASSERT_NEAR(current_speed, 1.0, 1e-1) | ||||||
<< " Angle: " << angle << " i: " << i | ||||||
<< " vel: (" << cmd_vel_->linear.x << "," << cmd_vel_->linear.y << ")"; | ||||||
ASSERT_FLOAT_EQ(std::atan2(cmd_vel_->linear.y, cmd_vel_->linear.x), angle) | ||||||
<< " Angle: " << angle << " i: " << i | ||||||
<< " vel: (" << cmd_vel_->linear.x << "," << cmd_vel_->linear.y << ")"; | ||||||
} | ||||||
} | ||||||
ASSERT_TRUE(hasDiag()); | ||||||
EXPECT_EQ(diagnostic_msgs::DiagnosticStatus::OK, diag_->status[0].level) | ||||||
<< "message: " << diag_->status[0].message; | ||||||
|
||||||
ASSERT_TRUE(hasStatus()); | ||||||
EXPECT_TRUE(status_->is_cloud_available); | ||||||
EXPECT_FALSE(status_->has_watchdog_timed_out); | ||||||
EXPECT_EQ(status_->stuck_started_since, ros::Time(0)); | ||||||
|
||||||
ASSERT_TRUE(received); | ||||||
} | ||||||
} | ||||||
|
||||||
int main(int argc, char** argv) | ||||||
{ | ||||||
testing::InitGoogleTest(&argc, argv); | ||||||
|
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.
Is it safe when
out.linear = { x: 0, y: 0 }
? (divide by zero)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.
Fixed