-
Notifications
You must be signed in to change notification settings - Fork 29
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
Support for continuous joints and fixed joints in URDF #16
base: main
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 |
---|---|---|
@@ -0,0 +1,45 @@ | ||
function model = remove_fixed_joints(model) | ||
% Update inertias and transforms | ||
for i = 1:model.NB | ||
if ~strcmp(model.jtype{i}, 'fixed') | ||
continue; | ||
end | ||
|
||
parent = model.parent(i); | ||
children = find(model.parent == i); | ||
|
||
% Update the transforms of the children | ||
for j = children | ||
model.parent(j) = parent; | ||
model.Xtree{j} = model.Xtree{j}*model.Xtree{i}; | ||
end | ||
|
||
% Absorb the body into the parent body if it exists | ||
if parent > 0 | ||
% Add inertia to parent | ||
X = model.Xtree{i}; | ||
I = X'*model.I{i}*X; | ||
model.I{parent} = model.I{parent} + I; | ||
end | ||
end | ||
|
||
% Remove the joints | ||
i = 1; | ||
while i <= model.NB | ||
if ~strcmp(model.jtype{i}, 'fixed') | ||
i = i + 1; | ||
else | ||
model.NB = model.NB - 1; | ||
model.parent(i) = []; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Have you tried using the resulting model in any of the conventional algorithms? My suspicion is that leaving an "empty" body in the list will lead to trouble. For example, the empty |
||
model.Xtree(i) = []; | ||
model.I(i) = []; | ||
model.jtype(i) = []; | ||
|
||
for j = i:model.NB | ||
if model.parent(j) >= i | ||
model.parent(j) = model.parent(j) - 1; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This line seems to be assuming that you are removing the body from the list and decrementing the body labels of everyone else in the tree by one? However all the old model data (e.g., for I might be mentally parsing this incorrectly -- if so, I think an example URDF will help a great deal to instill confidence. |
||
end | ||
end | ||
end | ||
end | ||
end |
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.
👍