ev3dev / ev3dev-lang-python

Pure python bindings for ev3dev
MIT License
429 stars 145 forks source link

Continuos rotation servo cannot control its position #752

Open ZakharovAndrey1980 opened 4 years ago

ZakharovAndrey1980 commented 4 years ago

I am trying to control MG995 servo - it is continuous rotation hobby-type servo. All I do is

    self.shoulderMotor = ServoMotor('in4:i2c88:sv7')
    self.shoulderMotor.position_sp = -100
    self.shoulderMotor.run()

I expected the servo rotate counter-clockwise for some degrees and stop, but when executed the servo is starting to rotate and doesn't stop. If I set position_sp=-20 then the servo rotates more slowly but doesn't stop as well.

Please advise, how could I make the servo rotate for say 90 and 180 degrees (approximately)

BTW, when I manually rotate the servo and read position_sp after that It shows -150 value. Could you please explain this.

Thanks!

dlech commented 4 years ago

That is the way continuous rotation servos work. You can only control the speed, not the position. They do not have any mechanism for position feedback.

To know the position, you will need an additional sensor such as limit switches or a rotary encoder.