Skip to content

Commit e67985d

Browse files
committed
Update parameter measurements for modular parts, use V4 Github Actions (#591)
* added an example to analyze part parameters and their effect on the modular robot * updated brick and core v2 parameters * updated active hinge frame mass * fix GitHub Actions: Update artifacts to v4 * artifacts now save with platform dependant names to avoid conflicts * switched runner to latest Mac version hoping to reduce queue time
1 parent 4e58ffa commit e67985d

File tree

11 files changed

+155
-11
lines changed

11 files changed

+155
-11
lines changed

.github/workflows/main.yml

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -144,17 +144,22 @@ jobs:
144144
python-version: 3.11
145145
- name: Build wheels
146146
run: pip wheel --no-deps ./${{ matrix.package }} -w ./dist/${{ matrix.package }}
147-
- uses: actions/upload-artifact@v3
147+
- name: Generate artifact name
148+
shell: bash
149+
run: |
150+
SAFE_PACKAGE=$(echo "${{ matrix.package }}" | sed 's/\//-/g')
151+
echo "ARTIFACT_NAME=dist-${SAFE_PACKAGE}-${{ github.run_id }}" >> $GITHUB_ENV
152+
- uses: actions/upload-artifact@v4
148153
with:
149-
name: dist
154+
name: ${{ env.ARTIFACT_NAME }}
150155
path: ./dist/**/*.whl
151156

152157
build_wheels_platform_dependent:
153158
needs: read-project-info
154159
runs-on: ${{ matrix.os }}
155160
strategy:
156161
matrix:
157-
os: [windows-2022, ubuntu-22.04, macos-12]
162+
os: [windows-2022, ubuntu-22.04, macos-latest]
158163
package: ${{ fromJson(needs.read-project-info.outputs.platform_dependent_packages) }}
159164
steps:
160165
- uses: actions/checkout@v4
@@ -170,9 +175,14 @@ jobs:
170175
CIBW_ARCHS_WINDOWS: AMD64
171176
CIBW_ARCHS_MACOS: universal2
172177
CIBW_ARCHS_LINUX: x86_64
173-
- uses: actions/upload-artifact@v3
178+
- name: Generate artifact name
179+
shell: bash
180+
run: |
181+
SAFE_PACKAGE=$(echo "${{ matrix.package }}" | sed 's/\//-/g')
182+
echo "ARTIFACT_NAME=dist-${SAFE_PACKAGE}-${{ matrix.os }}-${{ github.run_id }}" >> $GITHUB_ENV
183+
- uses: actions/upload-artifact@v4
174184
with:
175-
name: dist
185+
name: ${{ env.ARTIFACT_NAME }}
176186
path: ./dist/**/*.whl
177187

178188
publish:
@@ -188,10 +198,11 @@ jobs:
188198
id-token: write
189199
steps:
190200
- name: Download dist artifact
191-
uses: actions/download-artifact@v3
201+
uses: actions/download-artifact@v4
192202
with:
193-
name: dist
203+
pattern: dist-*
194204
path: dist
205+
merge-multiple: true
195206
- name: Generate name for package
196207
# Prepend 'revolve2-', replace '/' with '-' and remove '/simulators'
197208
run: echo "PACKAGE_URL=https://pypi.org/p/revolve2-$(echo ${{ matrix.package }} | sed 's/_/-/g' | sed 's/simulators\///g')" >> $GITHUB_ENV
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
This example shows you how to create vustom versions of the modular robot elements.
2+
3+
You learn:
4+
- Where are parts defined and what parameters can be changed.
5+
- How to implement custom versions of the parts to analyze the effect of different parameters.
6+
- Using the test_robot function to test robots with manual/dummy brains.
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
"""Main script for the example."""
2+
3+
from pyrr import Vector3
4+
5+
from revolve2.experimentation.logging import setup_logging
6+
from revolve2.modular_robot import ModularRobot
7+
from revolve2.modular_robot.body import RightAngles
8+
from revolve2.modular_robot.body.v2 import ActiveHingeV2, BodyV2, BrickV2, CoreV2
9+
from revolve2.modular_robot.brain.dummy import BrainDummy
10+
from revolve2.modular_robot_simulation import test_robot
11+
from revolve2.simulators.mujoco_simulator import LocalSimulator
12+
from revolve2.standards import terrains
13+
from revolve2.standards.simulation_parameters import make_standard_batch_parameters
14+
15+
""" Below we create a custom version of the ActiveHingeV2.
16+
By pressing shift+right click on the ActiveHingeV2 class in the IDE you can see where it is defined.
17+
Changing the parameters there will change it for all instances of ActiveHingeV2, which is not what we want.
18+
Therefore we create a custom version of the ActiveHingeV2 and change the parameters there."""
19+
20+
21+
class CustomActiveHingeV2(ActiveHingeV2):
22+
"""Custom ActiveHinge for parameter testing."""
23+
24+
def __init__(self, rotation: float | RightAngles):
25+
"""Initialize with custom parameters.
26+
27+
:param rotation: The Modules rotation.
28+
29+
"""
30+
super().__init__(rotation=rotation)
31+
# Modify parameters here to experiment
32+
self._frame_bounding_box = Vector3([0.036, 0.104, 0.033]) # Double size
33+
self._servo1_bounding_box = Vector3([0.1025, 0.1024, 0.040]) # Double size
34+
self._servo2_bounding_box = Vector3([0.004, 0.104, 0.104]) # Double size
35+
36+
37+
class CustomBrickV2(BrickV2):
38+
"""Custom Brick for parameter testing."""
39+
40+
def __init__(self, rotation: float | RightAngles):
41+
"""Initialize with custom parameters.
42+
43+
:param rotation: The Modules rotation.
44+
45+
"""
46+
super().__init__(rotation=rotation)
47+
# Modify parameters here to experiment
48+
self._mass = 0.100 # Double mass
49+
self._bounding_box = Vector3([0.130, 0.130, 0.130]) # Double size
50+
51+
52+
class CustomCoreV2(CoreV2):
53+
"""Custom Core for parameter testing."""
54+
55+
def __init__(self, rotation: float | RightAngles):
56+
"""Initialize with custom parameters.
57+
58+
:param rotation: The Modules rotation.
59+
60+
"""
61+
super().__init__(rotation=rotation)
62+
# Modify parameters here to experiment
63+
self._mass = 0.200 # Double mass
64+
self._bounding_box = Vector3([0.130, 0.130, 0.130]) # Double size
65+
66+
67+
def make_visualization_body() -> BodyV2:
68+
"""
69+
Create a body with all components for visualization.
70+
71+
:returns: The created body.
72+
"""
73+
body = BodyV2()
74+
75+
# Attach components in different configurations to visualize all parts
76+
hinge_left = CustomActiveHingeV2(RightAngles.DEG_0)
77+
body.core_v2.front_face.bottom = hinge_left
78+
hinge_left.attachment = CustomBrickV2(RightAngles.DEG_0)
79+
80+
# Add a chain of components to see how they connect
81+
hinge = CustomActiveHingeV2(RightAngles.DEG_0)
82+
body.core_v2.back_face.bottom = hinge
83+
hinge.attachment = CustomBrickV2(RightAngles.DEG_0)
84+
85+
return body
86+
87+
88+
def main() -> None:
89+
"""Run the visualization."""
90+
setup_logging()
91+
92+
body = make_visualization_body()
93+
94+
# Create dummy brain (no movement) for better visualization
95+
brain = BrainDummy()
96+
robot = ModularRobot(body, brain)
97+
98+
# Set up simulator with custom viewer for better visualization
99+
simulator = LocalSimulator(
100+
viewer_type="custom",
101+
headless=False,
102+
)
103+
104+
# Configure sim params
105+
batch_parameters = make_standard_batch_parameters()
106+
batch_parameters.simulation_time = (
107+
10 # Short sim time since we just want to view it
108+
)
109+
batch_parameters.simulation_timestep = (
110+
0.005 # Smaller timestep for smoother visualization
111+
)
112+
113+
# Test the robot using the test_robot utility
114+
test_robot(
115+
robot=robot,
116+
terrain=terrains.flat(),
117+
simulator=simulator,
118+
batch_parameters=batch_parameters,
119+
)
120+
121+
122+
if __name__ == "__main__":
123+
main()

examples/2_modular_robot_basics/2c_custom_parts/requirements.txt

Whitespace-only changes.

modular_robot/pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ readme = "../README.md"
1010
authors = [
1111
"Aart Stuurman <aartstuurman@hotmail.com>",
1212
"Oliver Weissl <o.weissl@vu.nl>",
13+
"Andres Garcia <a.a.garciarincon@student.vu.nl>"
1314
]
1415
repository = "https://github.com/ci-group/revolve2"
1516
classifiers = [

modular_robot/revolve2/modular_robot/body/v2/_active_hinge_v2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def __init__(self, rotation: float | RightAngles):
2727
frame_offset=0.04495,
2828
servo1_bounding_box=Vector3([0.05125, 0.0512, 0.020]),
2929
servo2_bounding_box=Vector3([0.002, 0.052, 0.052]),
30-
frame_mass=0.01632,
30+
frame_mass=0.01144,
3131
servo1_mass=0.058,
3232
servo2_mass=0.025,
3333
servo_offset=0.0239,

modular_robot/revolve2/modular_robot/body/v2/_brick_v2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def __init__(self, rotation: float | RightAngles):
1717
super().__init__(
1818
rotation=rotation,
1919
bounding_box=Vector3([w, h, d]),
20-
mass=0.06043,
20+
mass=0.05864,
2121
child_offset=d / 2.0,
2222
sensors=[],
2323
)

modular_robot/revolve2/modular_robot/body/v2/_core_v2.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
class CoreV2(Core):
1111
"""The core module of a modular robot."""
1212

13-
_BATTERY_MASS = 0.39712 # in kg
14-
_FRAME_MASS = 1.0644 # in kg
13+
_BATTERY_MASS = 0.39201 # in kg
14+
_FRAME_MASS = 0.9783 # in kg
1515

1616
_horizontal_offset = 0.029 # The horizontal offset for attachment positions (in m).
1717
_vertical_offset = 0.032 # The vertical offset for attachment positions (in m).

project.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ examples:
1414
- 1_simulator_basics/1b_custom_terrain
1515
- 2_modular_robot_basics/2a_custom_brain
1616
- 2_modular_robot_basics/2b_brain_with_feedback
17+
- 2_modular_robot_basics/2c_custom_parts
1718
- 3_experiment_foundations/3a_experiment_setup
1819
- 3_experiment_foundations/3b_evaluate_single_robot
1920
- 3_experiment_foundations/3c_evaluate_multiple_isolated_robots

simulators/mujoco_simulator/pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ authors = [
1111
"Aart Stuurman <aartstuurman@hotmail.com>",
1212
"Oliver Weissl <o.weissl@vu.nl>",
1313
"Kevin Godin-Dubois <k.j.m.godin-dubois@vu.nl>",
14+
"Andres Garcia <a.a.garciarincon@student.vu.nl>"
1415
]
1516
repository = "https://github.com/ci-group/revolve2"
1617
classifiers = [

standards/pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ readme = "../README.md"
1515
authors = [
1616
"Aart Stuurman <aartstuurman@hotmail.com>",
1717
"Oliver Weissl <o.weissl@vu.nl>",
18+
"Andres Garcia <a.a.garciarincon@student.vu.nl>"
1819
]
1920
repository = "https://github.com/ci-group/revolve2"
2021
classifiers = [

0 commit comments

Comments
 (0)