Skip to content

Upgrade InverseKinematicsTool to new Property system #2685

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

Merged
merged 13 commits into from
Mar 25, 2020

Conversation

aymanhab
Copy link
Member

@aymanhab aymanhab commented Mar 5, 2020

Fixes issue #<issue_number>

Brief summary of changes

Convert inversekinematicstool to use new property system, other cleanup. Kept old API around

Testing I've completed

Ran tests

Looking for feedback on...

CHANGELOG.md (choose one)

  • no need to update because...
  • updated...

The Doxygen for this PR can be viewed at http://myosin.sourceforge.net/?C=N;O=D; click the folder whose name is this PR's number.


This change is Reviewable

@aymanhab aymanhab changed the title [WIP] Unify iktools Upgrade InverseKinematicsTool to new Property system Mar 16, 2020
…f only tracking orientations"

This reverts commit ca8ccdc.
@aymanhab
Copy link
Member Author

Ready for review @carmichaelong when you have a chance

Copy link
Member

@carmichaelong carmichaelong left a comment

Choose a reason for hiding this comment

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

Thanks, @aymanhab! I've left a bunch of minor comments (some just clarifications for my understanding).

@@ -274,7 +274,6 @@ bool InverseDynamicsTool::run()
<< _lowpassCutoffFrequency << "..." << endl << endl;
_coordinateValues->pad(_coordinateValues->getSize()/2);
_coordinateValues->lowpassIIR(_lowpassCutoffFrequency);
if (getVerboseLevel()==Debug) _coordinateValues->print("coordinateDataFiltered.sto");
Copy link
Member

Choose a reason for hiding this comment

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

Is this a loss of functionality for someone trying to debug?

Copy link
Member Author

Choose a reason for hiding this comment

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

True but rarely used AFAIK, we're moving in the direction of having a logger that does logging across all objects/tools so a private verbosity level flag is very ad-hoc and can be removed.

Copy link
Member

Choose a reason for hiding this comment

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

Sounds good. Is there an issue open about what the plans are for the logger? Would be good to make sure these are in there if so.

Copy link
Member Author

Choose a reason for hiding this comment

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

PR #2551 is the new logger PR

@@ -318,10 +163,10 @@ bool InverseKinematicsTool::run()
// Adjust the time range for the tool if the provided range exceeds
// that of the marker data.
SimTK::Vec2 markersValidTimRange = markersReference.getValidTimeRange();
Copy link
Member

Choose a reason for hiding this comment

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

I know that it's not part of the PR, but could be good to make the change of markersValidTimRange ->markersValidTimeRange

void setStartTime(double d) { _timeRange[0] = d; };
double getStartTime() const {return _timeRange[0]; };
void setStartTime(double d) { upd_time_range(0) = d; };
double getStartTime() const {return get_time_range(0); };
Copy link
Member

Choose a reason for hiding this comment

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

I didn't find anything about conventions for one-liners in headers files in our contributing file, but it would be good to at least be consistent with spacing through this section.

Copy link
Member Author

Choose a reason for hiding this comment

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

Does the format file that @chrisdembia included take care of this? If not I will update since I agree with your suggestion

Copy link
Member

Choose a reason for hiding this comment

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

Unsure, do you know where that file is and how it works? If so, I could try to look into it, but in the mean time might just be good to clean up this section?

Tool() : _inputsDir(_inputsDirProp.getValueStr()),
_resultsDir(_resultsDirProp.getValueStr())
{ setNull(); };
Tool() { constructProperties();
Copy link
Member

Choose a reason for hiding this comment

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

Put constructProperties() on own line?

@@ -511,9 +359,7 @@ void InverseKinematicsTool::updateFromXMLNode(SimTK::Xml::Element& aNode, int ve
for (; p!= trialIter->node_end(); ++p) {
iter->insertNodeAfter( iter->node_end(), p->clone());
}
iter->insertNodeAfter( iter->node_end(), Xml::Comment(_constraintWeightProp.getComment()));
Copy link
Member

Choose a reason for hiding this comment

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

Just to double check, the comments will still be in the files due to the way the new property system works, correct?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, the goal is to construct an object with the correct property values, comments on the other hand are never read so setting them here is unnecessary

@@ -22,10 +22,10 @@
* See the License for the specific language governing permissions and *
* limitations under the License. *
* -------------------------------------------------------------------------- */

#include "Simbody.h"
Copy link
Member

Choose a reason for hiding this comment

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

I think this is only needed for SimTK::ReferencePtr? Can the include be of smaller scope?

Copy link
Member Author

Choose a reason for hiding this comment

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

That is true, I followed suit with similar usage because headers that defines templates are tricky to surgically include but I can look into it further if you think it's worth it.

Copy link
Member

Choose a reason for hiding this comment

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

Will #include <SimTKcommon/internal/ReferencePtr.h> work?

double &_accuracy;
OpenSim_DECLARE_PROPERTY(accuracy, double,
"The accuracy of the solution in absolute terms, i.e. the number of "
"significant digits to which the solution can be trusted. Default 1e-6.");
Copy link
Member

Choose a reason for hiding this comment

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

I think the default is 1e-5?

PropertyDblArray _timeRangeProp;
Array<double> &_timeRange;
OpenSim_DECLARE_PROPERTY(coordinate_file, std::string,
"The name of the storage (.sto or .mot) file containing the time "
Copy link
Member

Choose a reason for hiding this comment

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

Can this be a path too?

Copy link
Member Author

Choose a reason for hiding this comment

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

We don't have a path property, feel free to propose one 😉 All file names in xml are string properties AFAIK

PropertyStr _markerFileNameProp;
std::string &_markerFileName;
OpenSim_DECLARE_PROPERTY(marker_file, std::string,
"Name/path to a .trc or .sto file of type Vec3 of marker data.");
Copy link
Member

Choose a reason for hiding this comment

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

Many users using the GUI or files won't know what "type Vec3" will mean. How can we convey the necessary info to that type of user?

Copy link
Member

Choose a reason for hiding this comment

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

May also be useful to keep some of the original comment, but reword, so that users have context for this. For instance: Markers in this " "file that have a corresponding task and model marker are included." This comment isn't perfect, but it's getting at something useful about having a corresponding IK task a model marker aligned with each of the experimental markers.

Copy link
Member Author

Choose a reason for hiding this comment

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

Good point regarding comments. I basically had to consolidate comments from old InverseKinematicsTool and IMUInverseKinematicsTool which have same properties with different comments. In this case I used the one from the more recent IMUInverseKinematicsTool but I agree the old InverseKinematicsTool comments were better,were the remaining properties clear or should I revert all comments?

Copy link
Member

Choose a reason for hiding this comment

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

I think the others were alright, this one definitely stuck out the most. Probably shouldn't revert all comments.


return(*this);
constructProperty_model_file("");
constructProperty_constraint_weight(Infinity);
Copy link
Member

Choose a reason for hiding this comment

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

Is Infinity defined from Simbody? What's the rationale on switching this from std::numeric_limits<SimTK::Real>::infinity()?

Copy link
Member Author

Choose a reason for hiding this comment

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

Infinity is SimTK::Infinity and as such is much cleaner than the more complicated syntax that returns same value (unless you're aware of other potential side-effects) it was used in other code already.

@aymanhab
Copy link
Member Author

@carmichaelong Thanks for the thorough review, I believe I addressed your feedback, let me know what you think when you have a chance. Thank you

@aymanhab
Copy link
Member Author

Ready for another pass @carmichaelong Thank you

@carmichaelong
Copy link
Member

I left a few comments on the open threads. Overall it's just a few very minor things:

  1. Make sure it's documented that the future logger should replace the capability removed here.
  2. Check if the more specific #include works
  3. Clean up white space on some of the one liners.

Merging should be easy after these are addressed since they're pretty minor.

@aymanhab
Copy link
Member Author

ok, changes/updates made per your request @carmichaelong Thank you

@carmichaelong
Copy link
Member

Thanks @aymanhab, I'll keep an eye out for the tests completing

@aymanhab
Copy link
Member Author

Testing finished 😃

@carmichaelong carmichaelong merged commit 60dd70d into master Mar 25, 2020
@carmichaelong
Copy link
Member

Thanks, and sorry, wanted to make sure to at least put a note about the logging somewhere (I put it in the other PR for now).

Separately, I know you've already continued work from this branch, so I didn't want to delete the unify_iktools branch from opensim-core yet. Feel free to delete the branch if you're all good to go.

@aymanhab
Copy link
Member Author

Thanks @carmichaelong I'll rebase my branch on master and then delete this branch. Thank you

@aymanhab aymanhab deleted the unify_iktools branch April 16, 2020 22:55
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.

2 participants