Spinning wheels

I would some need help with how I get some wheels to spin around not just one lap but several laps until I give the signal that they should stand still and it should also be possible to control which direction the wheels should spin so they can easily change direction on rotation.

Does anyone have a good solution?

Hey Linda,

i would put the wheels in a Link with a rotational Joint and write a Python Script to drive the wheels as long as the signal is True.

You then could also connect a second signal on which the Script rotates the Joint in the opposite direction.

Hope that helps!

Thank you!
My experience with Python Script is minimal, do you have any suggestion how the script might look?

x = 1
servo = comp.findBehaviour("ServoController")
spinningSignal = comp.findBehaviour("BooleanSignal#1")
spinningSignal_reverse = comp.findBehaviour("BooleanSignal#2")
while app.Simulation.IsRunning: 
    delay(0.01)
    while spinningSignal.Value == True:
      servo.move(x)
      x = x + 1
    while spinningSignal_reverse.Value == True:
      servo.move(-x)
      x = x - 1

I’m no expert at Python myself, but i would try something like this.

I think easiest way to do it is this one below. Because if you always increase joint value finally you will extend your joint limit.

and if you set your joint accelleration and deccelaration to 50000 this will work easly.

comp = getComponent()
servo = comp.findBehaviour(‘Servo Controller_2’)

def OnRun():
while True:
servo.move(360)
servo.moveImmediate(0)