-
Notifications
You must be signed in to change notification settings - Fork 79
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
Only recreate target object when parameters change #86
base: master
Are you sure you want to change the base?
Conversation
Codecov Report
@@ Coverage Diff @@
## master #86 +/- ##
==========================================
- Coverage 79.16% 78.38% -0.78%
==========================================
Files 9 9
Lines 499 504 +5
==========================================
Hits 395 395
- Misses 104 109 +5
Continue to review full report at Codecov.
|
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.
Are there any other cases you might have missed where you would wan't to clear/recreate the target?
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; |
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.
This case looks the exact same as above. Can you combine?
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.
I went to do this and realized that there's a one character difference, in lines 313 and 321: one uses param.value_.i
and the other param.value_.f
. I'm not thinking of a more elegant way to combine them . . .
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.
You could make it a lambda function that lives inside loadInputWidgetsForTargetType
function and have that one parameter be the input value. And make that parameter const std::string&
to avoid having to template it for different value types.
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.
I don't quite follow your suggestion, @jliukkonen, but I did realize that the parameter could know how to make a string of itself, and so that's what I did and used it here to combine the int and float cases. It also led me to some other situations where things could be simplified related to parameter types.
moveit_calibration_plugins/handeye_calibration_target/src/handeye_target_charuco.cpp
Show resolved
Hide resolved
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.
I would prefer std::atomic<bool>
if possible simply because it can be used the same way as your ordinary bool
, which makes it easier to understand.
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; |
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.
You could make it a lambda function that lives inside loadInputWidgetsForTargetType
function and have that one parameter be the input value. And make that parameter const std::string&
to avoid having to template it for different value types.
Fixes #14: only re-initializes target object when the parameters change.