-
Notifications
You must be signed in to change notification settings - Fork 103
Only recreate target object when parameters change #86
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
base: master
Are you sure you want to change the base?
Changes from 2 commits
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 |
|---|---|---|
|
|
@@ -90,6 +90,7 @@ TargetTabWidget::TargetTabWidget(QWidget* parent) | |
| , it_(nh_) | ||
| , target_plugins_loader_(nullptr) | ||
| , target_(nullptr) | ||
| , target_is_ready_(ATOMIC_FLAG_INIT) | ||
JStech marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| , target_param_layout_(new QFormLayout()) | ||
| { | ||
| // Target setting tab area ----------------------------------------------- | ||
|
|
@@ -304,18 +305,25 @@ bool TargetTabWidget::loadInputWidgetsForTargetType(const std::string& plugin_na | |
| { | ||
| switch (param.parameter_type_) | ||
| { | ||
| case moveit_handeye_calibration::HandEyeTargetBase::Parameter::ParameterType::Int: | ||
| target_param_inputs_.insert(std::make_pair(param.name_, new QLineEdit())); | ||
| case moveit_handeye_calibration::HandEyeTargetBase::Parameter::ParameterType::Int: { | ||
| QLineEdit* line_edit = new QLineEdit(); | ||
| connect(line_edit, SIGNAL(textChanged(QString)), this, SLOT(targetParameterChanged(QString))); | ||
| target_param_inputs_.insert(std::make_pair(param.name_, line_edit)); | ||
| target_param_layout_->addRow(param.name_.c_str(), target_param_inputs_[param.name_]); | ||
| static_cast<QLineEdit*>(target_param_inputs_[param.name_])->setText(std::to_string(param.value_.i).c_str()); | ||
| break; | ||
| case moveit_handeye_calibration::HandEyeTargetBase::Parameter::ParameterType::Float: | ||
| target_param_inputs_.insert(std::make_pair(param.name_, new QLineEdit())); | ||
| } | ||
| case moveit_handeye_calibration::HandEyeTargetBase::Parameter::ParameterType::Float: { | ||
| QLineEdit* line_edit = new QLineEdit(); | ||
| connect(line_edit, SIGNAL(textChanged(QString)), this, SLOT(targetParameterChanged(QString))); | ||
| target_param_inputs_.insert(std::make_pair(param.name_, line_edit)); | ||
| target_param_layout_->addRow(param.name_.c_str(), target_param_inputs_[param.name_]); | ||
| static_cast<QLineEdit*>(target_param_inputs_[param.name_])->setText(std::to_string(param.value_.f).c_str()); | ||
| break; | ||
|
||
| case moveit_handeye_calibration::HandEyeTargetBase::Parameter::ParameterType::Enum: | ||
| } | ||
| case moveit_handeye_calibration::HandEyeTargetBase::Parameter::ParameterType::Enum: { | ||
| QComboBox* combo_box = new QComboBox(); | ||
| connect(combo_box, SIGNAL(currentTextChanged(QString)), this, SLOT(targetParameterChanged(QString))); | ||
| for (const std::string& value : param.enum_values_) | ||
| { | ||
| combo_box->addItem(tr(value.c_str())); | ||
|
|
@@ -324,6 +332,7 @@ bool TargetTabWidget::loadInputWidgetsForTargetType(const std::string& plugin_na | |
| target_param_layout_->addRow(param.name_.c_str(), target_param_inputs_[param.name_]); | ||
| static_cast<QComboBox*>(target_param_inputs_[param.name_])->setCurrentIndex(param.value_.e); | ||
| break; | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
@@ -341,6 +350,9 @@ bool TargetTabWidget::createTargetInstance() | |
| if (!target_) | ||
| return false; | ||
|
|
||
| if (target_is_ready_.test_and_set()) | ||
JStech marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| return true; | ||
|
|
||
| try | ||
| { | ||
| // TODO: load parameters from GUI | ||
|
|
@@ -368,6 +380,7 @@ bool TargetTabWidget::createTargetInstance() | |
| { | ||
| QMessageBox::warning(this, tr("Exception while loading a handeye target plugin"), tr(ex.what())); | ||
| target_ = nullptr; | ||
| target_is_ready_.clear(); | ||
JStech marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| return false; | ||
| } | ||
|
|
||
|
|
@@ -462,6 +475,7 @@ void TargetTabWidget::targetTypeComboboxChanged(const QString& text) | |
| { | ||
| loadInputWidgetsForTargetType(text.toStdString()); | ||
| } | ||
| target_is_ready_.clear(); | ||
JStech marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| void TargetTabWidget::createTargetImageBtnClicked(bool clicked) | ||
|
|
@@ -549,4 +563,9 @@ void TargetTabWidget::cameraInfoComboBoxChanged(const QString& topic) | |
| } | ||
| } | ||
|
|
||
| void TargetTabWidget::targetParameterChanged(const QString&) | ||
| { | ||
| target_is_ready_.clear(); | ||
JStech marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| } // namespace moveit_rviz_plugin | ||
Uh oh!
There was an error while loading. Please reload this page.