Skip to content

Update tutorial action switch frequency#345

Merged
yuecideng merged 1 commit into
mainfrom
fix/tutorial-action-switch-frequency
Jul 1, 2026
Merged

Update tutorial action switch frequency#345
yuecideng merged 1 commit into
mainfrom
fix/tutorial-action-switch-frequency

Conversation

@yuecideng

Copy link
Copy Markdown
Contributor

Description

This PR updates the scripts/tutorials/sim/create_robot.py and scripts/tutorials/sim/create_sensor.py tutorials to use an explicit shared action-switch interval, instead of hard-coded modulo values in the simulation loop.

It also adds a regression test to verify that both tutorial scripts keep the expected switch interval constant.

Dependencies: None.

Issue reference: None.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • Enhancement (non-breaking change which improves an existing functionality)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (existing functionality will not work without user modification)
  • Documentation update

Screenshots

Not applicable.

Checklist

  • I have run the black . command to format the code base.
  • I have made corresponding changes to the documentation.
  • I have added tests that prove my fix is effective or that my feature works.
  • Dependencies have been updated, if applicable.

Verification

  • pytest tests/sim/test_tutorial_action_switch_frequency.py -v
    • 2 passed in 1.38s

Update the create_robot and create_sensor tutorial scripts to use an explicit action switch interval and add a regression test for the shared cadence.
Copilot AI review requested due to automatic review settings July 1, 2026 11:11
@yuecideng yuecideng added bug Something isn't working robot Module related to robot sensor Virtual sensor for computing observation from simulation labels Jul 1, 2026
@yuecideng yuecideng merged commit 690e130 into main Jul 1, 2026
2 checks passed
@yuecideng yuecideng deleted the fix/tutorial-action-switch-frequency branch July 1, 2026 11:12

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the simulation tutorial loops in create_robot.py and create_sensor.py to use an explicit shared ACTION_SWITCH_INTERVAL (and a derived cycle length) instead of hard-coded modulo conditions, and adds a regression test intended to keep that interval consistent.

Changes:

  • Introduces ACTION_SWITCH_INTERVAL and ACTION_CYCLE_STEPS, and refactors loop conditionals to use cycle_step.
  • Adjusts the tutorials’ action switch cadence to a consistent interval-based schedule.
  • Adds a test that parses the tutorial scripts to validate the expected interval constant.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
scripts/tutorials/sim/create_robot.py Refactors action switching logic to use shared interval/cycle constants.
scripts/tutorials/sim/create_sensor.py Refactors action switching logic to use shared interval/cycle constants (and triggers sensor capture on switches).
tests/sim/test_tutorial_action_switch_frequency.py Adds a regression test for the tutorial action switch interval constant.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

CONTROL_PARTS = {
"arm": [
"JOINT[1-6]", # Matches JOINT1, JOINT2, ..., JOINT6
"joint[1-6]", # Matches JOINT1, JOINT2, ..., JOINT6
CONTROL_PARTS = {
"arm": [
"JOINT[1-6]", # Matches JOINT1, JOINT2, ..., JOINT6
"joint[1-6]", # Matches JOINT1, JOINT2, ..., JOINT6
Comment on lines +39 to +56


def test_create_robot_tutorial_uses_shared_action_switch_interval() -> None:
module = _parse_module("create_robot.py")

assert (
_find_constant_value(module, "ACTION_SWITCH_INTERVAL")
== EXPECTED_ACTION_SWITCH_INTERVAL
)


def test_create_sensor_tutorial_uses_shared_action_switch_interval() -> None:
module = _parse_module("create_sensor.py")

assert (
_find_constant_value(module, "ACTION_SWITCH_INTERVAL")
== EXPECTED_ACTION_SWITCH_INTERVAL
)
@yuecideng yuecideng mentioned this pull request Jul 1, 2026
9 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working robot Module related to robot sensor Virtual sensor for computing observation from simulation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants