Skip to content
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

Add wing force sensors to fruitfly_v2 walker #426

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,7 @@
<geom name="wing_left_membrane" material="membrane" mass="0" pos="-0.0968 0.0432 -0.09" quat="-0.915 0 -0.403 0" mesh="wing_left_membrane"/>
<geom name="wing_left_membrane_collision" class="collision-membrane" type="ellipsoid" size="0.00306 0.0551 0.114" pos="0.0263 -0.148 -0.0289" quat="-0.685 -0.634 0.265 -0.243"/>
<geom name="wing_left_fluid" class="wing-fluid" size="0.0005 0.0551 0.114" pos="0.0263 -0.148 -0.0289" quat="-0.685 -0.634 0.265 -0.243"/>
<site name="wing_left"/>
<geom name="wing_left_inertial" class="wing-inertial" size="0.0005 0.0551 0.114" pos="0.0263 -0.148 -0.0289" quat="-0.685 -0.634 0.265 -0.243"/>
</body>
<body name="wing_right" childclass="wing" pos="-0.00694 -0.0432 0.0091" quat="0 0.915 0 -0.403">
Expand All @@ -396,6 +397,7 @@
<geom name="wing_right_membrane" material="membrane" mass="0" pos="0.0968 -0.0432 0.09" quat="-0.403 0 0.915 0" mesh="wing_right_membrane"/>
<geom name="wing_right_membrane_collision" class="collision-membrane" type="ellipsoid" size="0.00306 0.0551 0.114" pos="-0.0263 0.148 0.0289" quat="0.243 0.265 0.634 -0.685"/>
<geom name="wing_right_fluid" class="wing-fluid" size="0.0005 0.0551 0.114" pos="-0.0263 0.148 0.0289" quat="0.243 0.265 0.634 -0.685"/>
<site name="wing_right"/>
<geom name="wing_right_inertial" class="wing-inertial" size="0.0005 0.0551 0.114" pos="-0.0263 0.148 0.0289" quat="0.243 0.265 0.634 -0.685"/>
</body>
<body name="abdomen" childclass="abdomen" pos="-0.0447 -0.000555 0.00428" quat="-0.704 -0.0859 -0.0853 -0.7">
Expand Down Expand Up @@ -907,6 +909,8 @@
<force name="force_tarsus_T2_right" site="tarsus_T2_right"/>
<force name="force_tarsus_T3_left" site="tarsus_T3_left"/>
<force name="force_tarsus_T3_right" site="tarsus_T3_right"/>
<force name="force_wing_left" site="wing_left"/>
<force name="force_wing_right" site="wing_right"/>
<touch name="touch_claw_T1_left" site="claw_T1_left"/>
<touch name="touch_claw_T1_right" site="claw_T1_right"/>
<touch name="touch_claw_T2_left" site="claw_T2_left"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1020,6 +1020,7 @@ def main(argv: Sequence[str]):
model.sensor.add('velocimeter', name='velocimeter', site='thorax')
touch_sites = []
force_sites = []
# Sites for leg sensors.
for leg in legs:
for body in leg.find_all('body'):
if 'claw' in body.name:
Expand All @@ -1033,6 +1034,12 @@ def main(argv: Sequence[str]):
if 'tarsus_' in body.name:
site = body.insert('site', -1, name=body.name)
force_sites.append(site)
# Sites for wing sensors.
for body in thorax.find_all('body'):
if 'wing' in body.name:
site = body.insert('site', -1, name=body.name)
force_sites.append(site)
# Add force and touch sensors.
for site in force_sites:
model.sensor.add('force', name='force_' + site.name, site=site)
for site in touch_sites:
Expand Down
4 changes: 4 additions & 0 deletions dm_control/locomotion/walkers/assets/fruitfly_v2/fruitfly.xml
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,7 @@
<geom name="wing_left_membrane" material="membrane" mass="0" pos="-0.0968 0.0432 -0.09" quat="-0.915 0 -0.403 0" mesh="wing_left_membrane"/>
<geom name="wing_left_membrane_collision" class="collision-membrane" type="ellipsoid" size="0.00306 0.0551 0.114" pos="0.0263 -0.148 -0.0289" quat="-0.685 -0.634 0.265 -0.243"/>
<geom name="wing_left_fluid" class="wing-fluid" size="0.0005 0.0551 0.114" pos="0.0263 -0.148 -0.0289" quat="-0.685 -0.634 0.265 -0.243"/>
<site name="wing_left"/>
<geom name="wing_left_inertial" class="wing-inertial" size="0.0005 0.0551 0.114" pos="0.0263 -0.148 -0.0289" quat="-0.685 -0.634 0.265 -0.243"/>
</body>
<body name="wing_right" childclass="wing" pos="-0.00694 -0.0432 0.0091" quat="0 0.915 0 -0.403">
Expand All @@ -396,6 +397,7 @@
<geom name="wing_right_membrane" material="membrane" mass="0" pos="0.0968 -0.0432 0.09" quat="-0.403 0 0.915 0" mesh="wing_right_membrane"/>
<geom name="wing_right_membrane_collision" class="collision-membrane" type="ellipsoid" size="0.00306 0.0551 0.114" pos="-0.0263 0.148 0.0289" quat="0.243 0.265 0.634 -0.685"/>
<geom name="wing_right_fluid" class="wing-fluid" size="0.0005 0.0551 0.114" pos="-0.0263 0.148 0.0289" quat="0.243 0.265 0.634 -0.685"/>
<site name="wing_right"/>
<geom name="wing_right_inertial" class="wing-inertial" size="0.0005 0.0551 0.114" pos="-0.0263 0.148 0.0289" quat="0.243 0.265 0.634 -0.685"/>
</body>
<body name="abdomen" childclass="abdomen" pos="-0.0447 -0.000555 0.00428" quat="-0.704 -0.0859 -0.0853 -0.7">
Expand Down Expand Up @@ -907,6 +909,8 @@
<force name="force_tarsus_T2_right" site="tarsus_T2_right"/>
<force name="force_tarsus_T3_left" site="tarsus_T3_left"/>
<force name="force_tarsus_T3_right" site="tarsus_T3_right"/>
<force name="force_wing_left" site="wing_left"/>
<force name="force_wing_right" site="wing_right"/>
<touch name="touch_claw_T1_left" site="claw_T1_left"/>
<touch name="touch_claw_T1_right" site="claw_T1_right"/>
<touch name="touch_claw_T2_left" site="claw_T2_left"/>
Expand Down
8 changes: 8 additions & 0 deletions dm_control/locomotion/walkers/fruitfly_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,10 @@ def _build(self,
if ('adhere' in actuator.name and
any_substr_in_str(name_substr['legs'], actuator.name)):
actuator.remove()
# Remove leg sensors.
for sensor in root.find_all('sensor'):
if any_substr_in_str(name_substr['legs'], sensor.name):
sensor.remove()

# Maybe retract and disable wings.
if not use_wings:
Expand All @@ -241,6 +245,10 @@ def _build(self,
for joint in wing_joints:
root.find('actuator', joint.name).remove()
self.observable_joints.remove(joint)
# Remove wing sensors.
for sensor in root.find_all('sensor'):
if any_substr_in_str(name_substr['wings'], sensor.name):
sensor.remove()

# Maybe disable mouth.
if not use_mouth:
Expand Down