{"action":"created","issue":{"url":"https://api.github.com/repos/opensim-org/opensim-core/issues/1443","repository_url":"https://api.github.com/repos/opensim-org/opensim-core","labels_url":"https://api.github.com/repos/opensim-org/opensim-core/issues/1443/labels{/name}","comments_url":"https://api.github.com/repos/opensim-org/opensim-core/issues/1443/comments","events_url":"https://api.github.com/repos/opensim-org/opensim-core/issues/1443/events","html_url":"https://github.com/opensim-org/opensim-core/issues/1443","id":194879457,"number":1443,"title":"Wrong marker weights value in MarkersReference","user":{"login":"cpizzolato","id":7061843,"avatar_url":"https://avatars.githubusercontent.com/u/7061843?v=3","gravatar_id":"","url":"https://api.github.com/users/cpizzolato","html_url":"https://github.com/cpizzolato","followers_url":"https://api.github.com/users/cpizzolato/followers","following_url":"https://api.github.com/users/cpizzolato/following{/other_user}","gists_url":"https://api.github.com/users/cpizzolato/gists{/gist_id}","starred_url":"https://api.github.com/users/cpizzolato/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cpizzolato/subscriptions","organizations_url":"https://api.github.com/users/cpizzolato/orgs","repos_url":"https://api.github.com/users/cpizzolato/repos","events_url":"https://api.github.com/users/cpizzolato/events{/privacy}","received_events_url":"https://api.github.com/users/cpizzolato/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-12-12T02:44:52Z","updated_at":"2017-01-05T19:25:48Z","closed_at":null,"body":"When using the `InverseKinematicsTool` the marker weights are read from the inverse kinematics setup file. However, the values of the marker weights in the xml and in the `MarkersReference` are different.\r\n\r\nMy understanding is that `MarkersReference::_markerNames` and `MarkersReference::_weights` should be in the same order, with the marker name matching in position with the respective weight, however this seems not to happen all the time. I have a [simple test case](/cpizzolato/opensim-core/tree/example-markerweightserror) if you want to take a look. Check for testInverseKinematicsTool among the other tests.\r\n\r\nI think the problem is in `void MarkersReference::updateInternalWeights() const`, specifically, where names and weight are associated \r\n```\r\n   // Begin by assigning default weight to each. Markers that do not have a\r\n    // weight specified in the marker_weights property use the default weight.\r\n    _weights.assign(getNumRefs(), get_default_weight());\r\n    // Next fill in the marker weights that were specified in the\r\n    // marker_weights property\r\n    int wix = -1;\r\n    int ix = 0;\r\n    // Build flat lists of marker weights in the same order as the marker names\r\n    for (const std::string &name : _markerNames) {\r\n        wix = get_marker_weights().getIndex(name, wix);\r\n        // Associate user weights (as specified in the marker_weights property)\r\n        // with the corresponding marker by order of marker names\r\n        if (wix >= 0)\r\n            _weights[ix++] = get_marker_weights()[wix].getWeight();\r\n    }\r\n```\r\n\r\nthe index `ix` is incremented only when a weight in the xml is found, which makes it go out of sync when a name is not found. So, `ix` should be incremented at every iteration of the for loop.\r\n\r\nPlease, let me know it this makes sense :)\r\n"},"comment":{"url":"https://api.github.com/repos/opensim-org/opensim-core/issues/comments/270733761","html_url":"https://github.com/opensim-org/opensim-core/issues/1443#issuecomment-270733761","issue_url":"https://api.github.com/repos/opensim-org/opensim-core/issues/1443","id":270733761,"user":{"login":"jenhicks","id":4510959,"avatar_url":"https://avatars.githubusercontent.com/u/4510959?v=3","gravatar_id":"","url":"https://api.github.com/users/jenhicks","html_url":"https://github.com/jenhicks","followers_url":"https://api.github.com/users/jenhicks/followers","following_url":"https://api.github.com/users/jenhicks/following{/other_user}","gists_url":"https://api.github.com/users/jenhicks/gists{/gist_id}","starred_url":"https://api.github.com/users/jenhicks/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jenhicks/subscriptions","organizations_url":"https://api.github.com/users/jenhicks/orgs","repos_url":"https://api.github.com/users/jenhicks/repos","events_url":"https://api.github.com/users/jenhicks/events{/privacy}","received_events_url":"https://api.github.com/users/jenhicks/received_events","type":"User","site_admin":false},"created_at":"2017-01-05T19:25:48Z","updated_at":"2017-01-05T19:25:48Z","body":"@aseth1 will look into this. Thank you for reporting Claudio!"}}
{"actor":{"display_login":"jenhicks"}}