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

feat(autoware_overlay_rviz_plugin)!: removed the blinking function of turn_signal #10319

Open
wants to merge 1 commit 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
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,6 @@ class TurnSignalsDisplay
int current_turn_signal_; // Internal variable to store turn signal state
int current_hazard_lights_; // Internal variable to store hazard lights state
QImage coloredImage(const QImage & source, const QColor & color);

std::chrono::steady_clock::time_point last_toggle_time_;
bool blink_on_ = false;
const std::chrono::milliseconds blink_interval_{500}; // Blink interval in milliseconds
Copy link
Contributor

@xmfcx xmfcx Mar 21, 2025

Choose a reason for hiding this comment

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

Also when you make the update, please also make this blink interval 250.
500 means it will blink at 1 Hz.
But it can be up to 2 Hz for most vehicles.
https://www.youtube.com/watch?v=iK2K9e_tcdI
At least in this video, I calculated it to be 180 clicks per minute https://www.beatsperminuteonline.com/ with this site.
Which makes 3 ticks per second, so we can set this blink_interval_ to 333 to make it 1.5Hz

};

} // namespace autoware_overlay_rviz_plugin
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@

TurnSignalsDisplay::TurnSignalsDisplay() : current_turn_signal_(0)
{
last_toggle_time_ = std::chrono::steady_clock::now();

// Load the arrow image
std::string package_path =
ament_index_cpp::get_package_share_directory("autoware_overlay_rviz_plugin");
Expand Down Expand Up @@ -87,28 +85,16 @@
(current_turn_signal_ == autoware_vehicle_msgs::msg::TurnIndicatorsReport::ENABLE_RIGHT ||
current_hazard_lights_ == autoware_vehicle_msgs::msg::HazardLightsReport::ENABLE);

// Color the arrows based on the state of the turn signals and hazard lights by having them blink
// on and off
if (this->blink_on_) {
if (leftActive) {
scaledLeftArrow = coloredImage(scaledLeftArrow, color);
}
if (rightActive) {
scaledRightArrow = coloredImage(scaledRightArrow, color);
}
if (leftActive) {
scaledLeftArrow = coloredImage(scaledLeftArrow, color);

Check warning on line 89 in visualization/autoware_overlay_rviz_plugin/autoware_overlay_rviz_plugin/src/turn_signals_display.cpp

View check run for this annotation

Codecov / codecov/patch

visualization/autoware_overlay_rviz_plugin/autoware_overlay_rviz_plugin/src/turn_signals_display.cpp#L89

Added line #L89 was not covered by tests
}
if (rightActive) {
scaledRightArrow = coloredImage(scaledRightArrow, color);

Check warning on line 92 in visualization/autoware_overlay_rviz_plugin/autoware_overlay_rviz_plugin/src/turn_signals_display.cpp

View check run for this annotation

Codecov / codecov/patch

visualization/autoware_overlay_rviz_plugin/autoware_overlay_rviz_plugin/src/turn_signals_display.cpp#L92

Added line #L92 was not covered by tests
}

// Draw the arrows
painter.drawImage(QPointF(leftArrowXPos, arrowYPos), scaledLeftArrow);
painter.drawImage(QPointF(rightArrowXPos, arrowYPos), scaledRightArrow);

auto now = std::chrono::steady_clock::now();
if (
std::chrono::duration_cast<std::chrono::milliseconds>(now - last_toggle_time_) >=
blink_interval_) {
blink_on_ = !blink_on_; // Toggle the blink state
last_toggle_time_ = now;
}
}

QImage TurnSignalsDisplay::coloredImage(const QImage & source, const QColor & color)
Expand Down
Loading