Skip to content

Conversation

@JStech
Copy link
Contributor

@JStech JStech commented May 8, 2021

Fixes #14: only re-initializes target object when the parameters change.

@codecov
Copy link

codecov bot commented May 8, 2021

Codecov Report

Merging #86 (a6cbf5a) into master (f1e99ab) will decrease coverage by 0.79%.
The diff coverage is 22.23%.

Impacted file tree graph

@@            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     
Impacted Files Coverage Δ
...t/handeye_calibration_target/handeye_target_base.h 84.22% <0.00%> (-3.86%) ⬇️
..._calibration_target/src/handeye_target_charuco.cpp 88.78% <33.34%> (ø)
...ye_calibration_target/src/handeye_target_aruco.cpp 87.78% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f1e99ab...a6cbf5a. Read the comment docs.

Copy link

@auman66 auman66 left a 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?

Comment on lines 316 to 322
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;
Copy link

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?

Copy link
Contributor Author

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 . . .

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.

Copy link
Contributor Author

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.

Copy link

@jliukkonen jliukkonen left a 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.

Comment on lines 316 to 322
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;

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.

@JStech JStech closed this Jun 4, 2021
@JStech JStech deleted the pr-fix-repeated-target-init branch June 4, 2021 03:09
@JStech JStech restored the pr-fix-repeated-target-init branch June 4, 2021 03:10
@JStech JStech reopened this Jun 4, 2021
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.

Repeated target initialization

3 participants