Skip to content
Merged
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
25 changes: 18 additions & 7 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -144,17 +144,22 @@ jobs:
python-version: 3.11
- name: Build wheels
run: pip wheel --no-deps ./${{ matrix.package }} -w ./dist/${{ matrix.package }}
- uses: actions/upload-artifact@v3
- name: Generate artifact name
shell: bash
run: |
SAFE_PACKAGE=$(echo "${{ matrix.package }}" | sed 's/\//-/g')
echo "ARTIFACT_NAME=dist-${SAFE_PACKAGE}-${{ github.run_id }}" >> $GITHUB_ENV
- uses: actions/upload-artifact@v4
with:
name: dist
name: ${{ env.ARTIFACT_NAME }}
path: ./dist/**/*.whl

build_wheels_platform_dependent:
needs: read-project-info
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [windows-2022, ubuntu-22.04, macos-12]
os: [windows-2022, ubuntu-22.04, macos-latest]
package: ${{ fromJson(needs.read-project-info.outputs.platform_dependent_packages) }}
steps:
- uses: actions/checkout@v4
Expand All @@ -170,9 +175,14 @@ jobs:
CIBW_ARCHS_WINDOWS: AMD64
CIBW_ARCHS_MACOS: universal2
CIBW_ARCHS_LINUX: x86_64
- uses: actions/upload-artifact@v3
- name: Generate artifact name
shell: bash
run: |
SAFE_PACKAGE=$(echo "${{ matrix.package }}" | sed 's/\//-/g')
echo "ARTIFACT_NAME=dist-${SAFE_PACKAGE}-${{ matrix.os }}-${{ github.run_id }}" >> $GITHUB_ENV
- uses: actions/upload-artifact@v4
with:
name: dist
name: ${{ env.ARTIFACT_NAME }}
path: ./dist/**/*.whl

publish:
Expand All @@ -188,10 +198,11 @@ jobs:
id-token: write
steps:
- name: Download dist artifact
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: dist
pattern: dist-*
path: dist
merge-multiple: true
- name: Generate name for package
# Prepend 'revolve2-', replace '/' with '-' and remove '/simulators'
run: echo "PACKAGE_URL=https://pypi.org/p/revolve2-$(echo ${{ matrix.package }} | sed 's/_/-/g' | sed 's/simulators\///g')" >> $GITHUB_ENV
Expand Down
6 changes: 6 additions & 0 deletions examples/2_modular_robot_basics/2c_custom_parts/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
This example shows you how to create vustom versions of the modular robot elements.

You learn:
- Where are parts defined and what parameters can be changed.
- How to implement custom versions of the parts to analyze the effect of different parameters.
- Using the test_robot function to test robots with manual/dummy brains.
123 changes: 123 additions & 0 deletions examples/2_modular_robot_basics/2c_custom_parts/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
"""Main script for the example."""

from pyrr import Vector3

from revolve2.experimentation.logging import setup_logging
from revolve2.modular_robot import ModularRobot
from revolve2.modular_robot.body import RightAngles
from revolve2.modular_robot.body.v2 import ActiveHingeV2, BodyV2, BrickV2, CoreV2
from revolve2.modular_robot.brain.dummy import BrainDummy
from revolve2.modular_robot_simulation import test_robot
from revolve2.simulators.mujoco_simulator import LocalSimulator
from revolve2.standards import terrains
from revolve2.standards.simulation_parameters import make_standard_batch_parameters

""" Below we create a custom version of the ActiveHingeV2.
By pressing shift+right click on the ActiveHingeV2 class in the IDE you can see where it is defined.
Changing the parameters there will change it for all instances of ActiveHingeV2, which is not what we want.
Therefore we create a custom version of the ActiveHingeV2 and change the parameters there."""


class CustomActiveHingeV2(ActiveHingeV2):
"""Custom ActiveHinge for parameter testing."""

def __init__(self, rotation: float | RightAngles):
"""Initialize with custom parameters.

:param rotation: The Modules rotation.

"""
super().__init__(rotation=rotation)
# Modify parameters here to experiment
self._frame_bounding_box = Vector3([0.036, 0.104, 0.033]) # Double size
self._servo1_bounding_box = Vector3([0.1025, 0.1024, 0.040]) # Double size
self._servo2_bounding_box = Vector3([0.004, 0.104, 0.104]) # Double size


class CustomBrickV2(BrickV2):
"""Custom Brick for parameter testing."""

def __init__(self, rotation: float | RightAngles):
"""Initialize with custom parameters.

:param rotation: The Modules rotation.

"""
super().__init__(rotation=rotation)
# Modify parameters here to experiment
self._mass = 0.100 # Double mass
self._bounding_box = Vector3([0.130, 0.130, 0.130]) # Double size


class CustomCoreV2(CoreV2):
"""Custom Core for parameter testing."""

def __init__(self, rotation: float | RightAngles):
"""Initialize with custom parameters.

:param rotation: The Modules rotation.

"""
super().__init__(rotation=rotation)
# Modify parameters here to experiment
self._mass = 0.200 # Double mass
self._bounding_box = Vector3([0.130, 0.130, 0.130]) # Double size


def make_visualization_body() -> BodyV2:
"""
Create a body with all components for visualization.

:returns: The created body.
"""
body = BodyV2()

# Attach components in different configurations to visualize all parts
hinge_left = CustomActiveHingeV2(RightAngles.DEG_0)
body.core_v2.front_face.bottom = hinge_left
hinge_left.attachment = CustomBrickV2(RightAngles.DEG_0)

# Add a chain of components to see how they connect
hinge = CustomActiveHingeV2(RightAngles.DEG_0)
body.core_v2.back_face.bottom = hinge
hinge.attachment = CustomBrickV2(RightAngles.DEG_0)

return body


def main() -> None:
"""Run the visualization."""
setup_logging()

body = make_visualization_body()

# Create dummy brain (no movement) for better visualization
brain = BrainDummy()
robot = ModularRobot(body, brain)

# Set up simulator with custom viewer for better visualization
simulator = LocalSimulator(
viewer_type="custom",
headless=False,
)

# Configure sim params
batch_parameters = make_standard_batch_parameters()
batch_parameters.simulation_time = (
10 # Short sim time since we just want to view it
)
batch_parameters.simulation_timestep = (
0.005 # Smaller timestep for smoother visualization
)

# Test the robot using the test_robot utility
test_robot(
robot=robot,
terrain=terrains.flat(),
simulator=simulator,
batch_parameters=batch_parameters,
)


if __name__ == "__main__":
main()
Empty file.
1 change: 1 addition & 0 deletions modular_robot/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ readme = "../README.md"
authors = [
"Aart Stuurman <aartstuurman@hotmail.com>",
"Oliver Weissl <o.weissl@vu.nl>",
"Andres Garcia <a.a.garciarincon@student.vu.nl>"
]
repository = "https://github.com/ci-group/revolve2"
classifiers = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def __init__(self, rotation: float | RightAngles):
frame_offset=0.04495,
servo1_bounding_box=Vector3([0.05125, 0.0512, 0.020]),
servo2_bounding_box=Vector3([0.002, 0.052, 0.052]),
frame_mass=0.01632,
frame_mass=0.01144,
servo1_mass=0.058,
servo2_mass=0.025,
servo_offset=0.0239,
Expand Down
2 changes: 1 addition & 1 deletion modular_robot/revolve2/modular_robot/body/v2/_brick_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def __init__(self, rotation: float | RightAngles):
super().__init__(
rotation=rotation,
bounding_box=Vector3([w, h, d]),
mass=0.06043,
mass=0.05864,
child_offset=d / 2.0,
sensors=[],
)
4 changes: 2 additions & 2 deletions modular_robot/revolve2/modular_robot/body/v2/_core_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
class CoreV2(Core):
"""The core module of a modular robot."""

_BATTERY_MASS = 0.39712 # in kg
_FRAME_MASS = 1.0644 # in kg
_BATTERY_MASS = 0.39201 # in kg
_FRAME_MASS = 0.9783 # in kg

_horizontal_offset = 0.029 # The horizontal offset for attachment positions (in m).
_vertical_offset = 0.032 # The vertical offset for attachment positions (in m).
Expand Down
1 change: 1 addition & 0 deletions project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ examples:
- 1_simulator_basics/1b_custom_terrain
- 2_modular_robot_basics/2a_custom_brain
- 2_modular_robot_basics/2b_brain_with_feedback
- 2_modular_robot_basics/2c_custom_parts
- 3_experiment_foundations/3a_experiment_setup
- 3_experiment_foundations/3b_evaluate_single_robot
- 3_experiment_foundations/3c_evaluate_multiple_isolated_robots
Expand Down
1 change: 1 addition & 0 deletions simulators/mujoco_simulator/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ authors = [
"Aart Stuurman <aartstuurman@hotmail.com>",
"Oliver Weissl <o.weissl@vu.nl>",
"Kevin Godin-Dubois <k.j.m.godin-dubois@vu.nl>",
"Andres Garcia <a.a.garciarincon@student.vu.nl>"
]
repository = "https://github.com/ci-group/revolve2"
classifiers = [
Expand Down
1 change: 1 addition & 0 deletions standards/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ readme = "../README.md"
authors = [
"Aart Stuurman <aartstuurman@hotmail.com>",
"Oliver Weissl <o.weissl@vu.nl>",
"Andres Garcia <a.a.garciarincon@student.vu.nl>"
]
repository = "https://github.com/ci-group/revolve2"
classifiers = [
Expand Down
Loading