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: update autoware state panel #7036

Merged
merged 66 commits into from
May 21, 2024
Merged

feat: update autoware state panel #7036

merged 66 commits into from
May 21, 2024

Conversation

KhalilSelyan
Copy link
Contributor

@KhalilSelyan KhalilSelyan commented May 16, 2024

Description

This PR updates the Autoware state panel RViz plugin with new custom components to enhance its appearance and functionality, aligning it with the newly set up RViz dark mode.

Related links

Screenshot Demo

image

Tests performed

  • Manual testing of the new components in RViz to ensure compatibility and proper display in dark mode.

Effects on system behavior

  • Improved visual consistency with the RViz dark mode.
  • Enhanced user experience with updated and more intuitive custom components.

Pre-review checklist for the PR author

The PR author must check the checkboxes below when creating the PR.

In-review checklist for the PR reviewers

The PR reviewers must check the checkboxes below before approval.

  • The PR follows the pull request guidelines.
  • The PR has been properly tested.
  • The PR has been reviewed by the code owners.

Post-review checklist for the PR author

The PR author must check the checkboxes below before merging.

  • There are no open discussions or they are tracked via tickets.
  • The PR is ready for merge.

After all checkboxes are checked, anyone who has write access can merge the PR.

Signed-off-by: KhalilSelyan <[email protected]>
Signed-off-by: KhalilSelyan <[email protected]>
Signed-off-by: KhalilSelyan <[email protected]>
Signed-off-by: KhalilSelyan <[email protected]>
@KhalilSelyan KhalilSelyan added the type:ui-ux User interface, user experience, graphical user interfaces. label May 16, 2024
@KhalilSelyan KhalilSelyan requested review from yukkysaito and xmfcx May 16, 2024 08:39
@KhalilSelyan KhalilSelyan self-assigned this May 16, 2024
@xmfcx
Copy link
Contributor

xmfcx commented May 20, 2024

Could you put all the colors we used to a header file and include it in required files?

We have material colors and they all have names. This will make styling easier for the future.

The material theme builder supports exporting themes:

2024-05-20_12-36

I've exported our theme: M3.json

Ideally we would read from this json and fill in the variables as it loads. But having them preset is good too.

I've used the following prompt: https://chatgpt.com/share/13727ef6-e4ca-4ca2-bc2a-0a6438bff542

You can directly use the final material_colors.hpp struct MaterialColors and inline MaterialColors default_colors; parts from the chat link. (Remove the json related parts, that's for future reference)

@KhalilSelyan
Copy link
Contributor Author

KhalilSelyan commented May 20, 2024

@xmfcx All bugs, and suggestions have been dealt with. debugging the switch toggle was the hardest but the fix was a simple if statement at the end. if there any discrepancies please let me know, if you would like to change colors as needed the material_colors.hpp is where all components now get their colors. so it should much simpler to edit now 👍🏼

Screenshot from 2024-05-20 20-53-54

image

@xmfcx
Copy link
Contributor

xmfcx commented May 20, 2024

brave_N5jCBBBNp0

Thanks, it looks great, the disabled colors of these buttons need to be fixed too. (Both disabled button and text colors)

KhalilSelyan and others added 3 commits May 21, 2024 14:00
@xmfcx
Copy link
Contributor

xmfcx commented May 21, 2024

autoware_state_panel.hpp

Click to expand
  // Diagnostic

  // QLabel * diagnostic_label_ptr_{nullptr};
  // QVBoxLayout * diagnostic_layout_{nullptr};
  // std::unordered_map<std::string, QLabel *> statusLabels;

  // rclcpp::Subscription<DiagnosticArray>::SharedPtr sub_diag_;
  // void onDiagnostics(const DiagnosticArray::ConstSharedPtr msg);
  // void addStatusLabel(const std::string & name, int level);
  // void updateStatusLabel(const std::string & name, int level);

autoware_state_panel.hpp

Click to expand
/* void AutowareStatePanel::onDiagnostics(const DiagnosticArray::ConstSharedPtr msg)
{
  for (const auto & status : msg->status) {
    std::string statusName = status.name;  // Assuming name is a std::string
    int level = status.level;              // Assuming level is an int

    // Check if this status name already has an associated QLabel
    auto it = statusLabels.find(statusName);
    if (it != statusLabels.end()) {
      // Status exists, update its display (QLabel) with the new level
      updateStatusLabel(statusName, level);
    } else {
      // New status, add a QLabel for it to the map and the layout
      addStatusLabel(statusName, level);
    }
  }
} */

/* void AutowareStatePanel::addStatusLabel(const std::string & name, int level)
{
  QString baseStyle =
    "QLabel {"
    "  border-radius: 4px;"
    "  padding: 4px;"
    "  margin: 2px;"
    "  font-weight: bold;"
    "  color: #003546;";

  QString okStyle = baseStyle + "background-color: #84c2e6;}";
  QString warnStyle = baseStyle + "background-color: #FFCC00;}";
  QString errorStyle = baseStyle + "background-color: #f08b8b;}";
  QString staleStyle = baseStyle + "background-color: #6c757d;}";

  QString labelText = QString::fromStdString(name);
  // + ": " +
  //                     (level == diagnostic_msgs::msg::DiagnosticStatus::OK      ? "OK"
  //                      : level == diagnostic_msgs::msg::DiagnosticStatus::WARN  ? "WARN"
  //                      : level == diagnostic_msgs::msg::DiagnosticStatus::ERROR ? "ERROR"
  //                                                                               : "STALE");

  auto * label = new QLabel(labelText);
  label->setMinimumHeight(30);  // for example, set a minimum height
  label->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);

  // Adjust style based on level
  QString styleSheet;
  switch (level) {
    case diagnostic_msgs::msg::DiagnosticStatus::OK:
      styleSheet = okStyle;
      break;
    case diagnostic_msgs::msg::DiagnosticStatus::WARN:
      styleSheet = warnStyle;
      break;
    case diagnostic_msgs::msg::DiagnosticStatus::ERROR:
      styleSheet = errorStyle;
      break;
    default:
      styleSheet = staleStyle;
      break;
  }

  label->setStyleSheet(styleSheet);
  diagnostic_layout_->addWidget(label);
  statusLabels[name] = label;
} */

/* void AutowareStatePanel::updateStatusLabel(const std::string & name, int level)
{
  QString baseStyle =
    "QLabel {"
    "  border-radius: 4px;"
    "  padding: 4px;"
    "  margin: 2px;"
    "  font-weight: bold;"
    "  color: #003546;";

  QString okStyle = baseStyle + "background-color: #84c2e6;}";
  QString warnStyle = baseStyle + "background-color: #FFCC00;}";
  QString errorStyle = baseStyle + "background-color: #f08b8b;}";
  QString staleStyle = baseStyle + "background-color: #6c757d;}";

  // Find the QLabel* associated with this status name
  auto it = statusLabels.find(name);
  if (it != statusLabels.end()) {
    QLabel * label = it->second;

    // Update label's text
    QString labelText = QString::fromStdString(name);
    // +": " + (level == diagnostic_msgs::msg::DiagnosticStatus::OK      ? "OK"
    //          : level == diagnostic_msgs::msg::DiagnosticStatus::WARN  ? "WARN"
    //          : level == diagnostic_msgs::msg::DiagnosticStatus::ERROR ? "ERROR"
    //                                                                   : "STALE");
    label->setText(labelText);

    // Update style based on level, similar to addStatusLabel
    QString styleSheet;
    switch (level) {
      case diagnostic_msgs::msg::DiagnosticStatus::OK:
        styleSheet = okStyle;
        break;
      case diagnostic_msgs::msg::DiagnosticStatus::WARN:
        styleSheet = warnStyle;
        break;
      case diagnostic_msgs::msg::DiagnosticStatus::ERROR:
        styleSheet = errorStyle;
        break;
      default:
        styleSheet = staleStyle;
        break;
    }
    label->setStyleSheet(styleSheet);
    label->adjustSize();  // Adjust the size of the label to fit the content if needed
    label->update();      // Ensure the label is updated immediately
  }
} */

Removed commented out future code

M. Fatih Cırıt added 2 commits May 21, 2024 15:52
Signed-off-by: M. Fatih Cırıt <[email protected]>
Signed-off-by: M. Fatih Cırıt <[email protected]>
@xmfcx
Copy link
Contributor

xmfcx commented May 21, 2024

We added scrollbars if it gets forced into a small area.
2024-05-21_16-24

It looks and functions very well now.
2024-05-21_16-23

Copy link
Contributor

@xmfcx xmfcx left a comment

Choose a reason for hiding this comment

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

Looking good, thank you!

@xmfcx xmfcx merged commit 328374e into main May 21, 2024
22 of 23 checks passed
@xmfcx xmfcx deleted the style-dark-mode-state-plugin branch May 21, 2024 14:21
karishma1911 pushed a commit to Interplai/autoware.universe that referenced this pull request Jun 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component:common Common packages from the autoware-common repository. (auto-assigned) run:build-and-test-differential Mark to enable build-and-test-differential workflow. (used-by-ci) type:documentation Creating or refining documentation. (auto-assigned) type:ui-ux User interface, user experience, graphical user interfaces.
Projects
No open projects
Status: Done
Development

Successfully merging this pull request may close these issues.

4 participants