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

Emergency braking #16

Open
wants to merge 7 commits into
base: main-old-sim
Choose a base branch
from
Open

Emergency braking #16

wants to merge 7 commits into from

Conversation

erinjhu
Copy link

@erinjhu erinjhu commented Mar 12, 2025

  • calculates time to collision using ranges[] from /scan and speed from /ego_racecar/odom
  • stops car if time to collision is below 1 second by publishing message to /drive

@hepromark

@erinjhu erinjhu changed the base branch from main to main-old-sim March 12, 2025 23:15
Copy link
Collaborator

@hepromark hepromark left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good initial PR! There's a concern I have about how speed is calculated, but your logic is sound

EmergencyBraking() : Node("emergency_braking_node") {
brake_pub_ = this->create_publisher<ackermann_msgs::msg::AckermannDriveStamped>("drive", 10);
scan_sub_ = this->create_subscription<sensor_msgs::msg::LaserScan>("scan", 10, std::bind(&EmergencyBraking::scan_callback, this, _1));
odom_sub_ = this->create_subscription<nav_msgs::msg::Odometry>("ego_racecar/odom", 10, std::bind(&EmergencyBraking::odom_callback, this, _1));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think relying on odom here isn't a good idea:

The ego_racecar/odom reading is only "100% accurate" in simulation, in real-life the SLAM subteam computes odom estimates. This mean that the data you're using for emergency braking may be unreliable depending on how good SLAM is, which is spooky because if something goes wrong in SLAM the emergency braking would also not work properly.

The idea is that emergency braking acts as a "standalone last resort" component which kicks in regardless of what any of the other components are saying. So I think it's a better idea to only use lidar readings.

I.e. instead of getting speed from the odom reading, you can calculate the speed using how the lidar measurements change over time.

If this doesn't make sense then you can just ping me on the server and we can hop in a call / I can clarify further! Sorry about the confusion, but this is arguably the most important part in the system so that we don't wreck our car :)) Thanks for your work!

Comment on lines +43 to +46
# Install the meshes folder
#install(DIRECTORY assets/
# DESTINATION share/${PROJECT_NAME}/assets
#)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# Install the meshes folder
#install(DIRECTORY assets/
# DESTINATION share/${PROJECT_NAME}/assets
#)

void scan_callback(const sensor_msgs::msg::LaserScan::ConstSharedPtr scan_msg) {
// calculate TTC
bool brake = false;
double threshold = 1;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

S: Make this a class constant. Itll be easier to find & tweak in the future if we need this to be more/less conservative.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants