Open ajoardar007 opened 5 months ago
In the last two-lines of the Attachment-frame topic, it is mentioned that joint
is a valid child of attachment-frames
.
Apparently, "The easiest way to do this is to hold a reference to the object returned by a call to attach":
frame_1 = self.shoulder_pitch_link_site.attach(self.shoulder_pitch_link.mjcf_model)
However, I am unable to attach a joint at the attachment-frame:
# Add joint to the attachment frame
frame_1.add('joint',
name = self._joint_name[1],
range = self._joint_range[1],
damping = self._joint_damping[1],
axis = self._joint_axis,
type = self._joint_type,
frictionloss = self._joint_frictionloss,
dclass = 'rand')
while I get the following error:
Traceback (most recent call last):
File "/home/arnab/.local/lib/python3.8/site-packages/dm_control/mjcf/element.py", line 593, in _check_valid_child
return self._spec.children[element_name]
KeyError: 'joint'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/arnab/UWARL_catkin_ws/src/uwarl-mujoco-summit-wam-sim/src/main_rob_dup_1.py", line 965, in <module>
summit_body = Summit(prefix = prefix)
File "/home/arnab/UWARL_catkin_ws/src/uwarl-mujoco-summit-wam-sim/src/main_rob_dup_1.py", line 916, in __init__
wam = WAM(name = self._wam_name+'_'+prefix)
File "/home/arnab/UWARL_catkin_ws/src/uwarl-mujoco-summit-wam-sim/src/main_rob_dup_1.py", line 471, in __init__
self.shoulder_yaw_link_site.add('joint',
File "/home/arnab/.local/lib/python3.8/site-packages/dm_control/mjcf/element.py", line 630, in add
return self.insert(element_name, position=None, **kwargs)
File "/home/arnab/.local/lib/python3.8/site-packages/dm_control/mjcf/element.py", line 647, in insert
child_spec = self._check_valid_child(element_name)
File "/home/arnab/.local/lib/python3.8/site-packages/dm_control/mjcf/element.py", line 595, in _check_valid_child
raise AttributeError( # pylint: disable=raise-missing-from
AttributeError: <joint> is not a valid child of <site>
Could you please advise as to how I may add a joint
-element at the attachment-frame between a parent and a child?
Hello, In order attach multiple links together, each having its own collision/visual mesh, inertia, joint, etc. I decided to construct a class that defines such a link, and it is then called multiple times, where each of its objects are initialized accordingly.
The issue that i am facing is that, when attaching such a child-body (
Child
) to the parent body, where the parent-body (Parent-2
) has a joint w.r.t. its parent (Parent-1
), I am unable to place theChild
inside theXML
definition ofParent-2
where the joint is defined, preventing the effects of the joint (Joint 1-to-2
) betweenParent-1
andParent-2
to effect theChild
body.Below, I define a class for constructing bodies with joints:
and below, I call the class
Link_w_Joints
multiple-times and attach successive-links (from ground to tool) to the preceding-ones:I have already identified the cause of said problem:
worldbody
-element of theChild
is converted into abody
-element and inserted intoParent-2
link,Parent-2
toParent-1
, theChild
does not end up inside thebody-element
that holds thejoint
-definition, but in the outer-one that was defined when theworldbody
-element of the child-body is converted into abody
-element.Below, you will find the output of the above script which shows the above-described behavior:
What is desired is the following output (the problematic-lines have been commented
<-- -->
):Can we make changes that does not create a new
body
-element, and, instead, appends the thesite
'spos
andquat
information to the child'sbody
-element, which is defined inside the child'sworldbody
element? This will also address the issue here as well