Special Commands - QuirkyCort/gears GitHub Wiki
Sometimes, it may be desirable to reset the simulator from the Python code. To do that, see the following example (...try it out with the paintball robot and the "High and Low" paintball world.
from simPython import System
sys = System()
while True:
motorD = LargeMotor(OUTPUT_D) # Arm
motorE = LargeMotor(OUTPUT_E) # Paintball Launcher
motorD.on_for_degrees(5, 43)
motorE.on_for_degrees(100, (-1000))
motorE.on_for_degrees(100, 1)
time.sleep(3)
sys.reset_simulator()
time.sleep(1)
Few things to note...
- You need to create a new instance of every sensor / actuator after reset. This is because the reset destroys the original motors and sensors, making the original instances invalid.
- There's a short sleep after the reset. This is because sys.reset_simulator() may return before the reset is complete.