[security issue] No encoder -> maximal speed

General discussion of using Roboclaw motor controllers
Post Reply
felix
Posts: 19
Joined: Thu Dec 03, 2020 8:08 am
[security issue] No encoder -> maximal speed

Post by felix »

Hi,
I recently encountered a severe issue with the setVelocity commands : if for whatever reason the encoder is disconnected, then the velocity quickly increases (until 100% PWM I suppose). This behavior is quite dangerous : it means that in case of a failure of the encoder, the robot will go full speed.
Even worse, if I'm not mistaken (this I should double check), even sending a velocity of 0 don't slow down the robot). So even the proximity sensors can't prevent a collision

Is there any mechanism to prevent the robot driving full speed into the wall (or into someone) in case of an encoder failure?
For example a max current above which the robot stops if no movement is sensed? Or a timeout without any move?
Or at least a command to decrease progressively the duty cycle to 0 (nb : simply setting pwm=0 is not a solution, the inertia of our robot is too big and it might fall forwards if stopping so abruptly)

Thanks a lot in advance
Best regards
Felix
User avatar
Basicmicro Support
Posts: 1594
Joined: Thu Feb 26, 2015 9:45 pm
Re: [security issue] No encoder -> maximal speed

Post by Basicmicro Support »

This is not a security issue. This is a PID controller. It can not tell if there is an encoder connected or not. It assumes no pulses means the motor needs more power.

However you can use the speed or position error limits to prevent runaway. You need to set them appropriately and if you use them you absolutely MUST set a proper acceleration rate(one the motor can perform). An acceleration rate too high means the error will accumulate during acceleration and may false trigger your error limits.
felix
Posts: 19
Joined: Thu Dec 03, 2020 8:08 am
Re: [security issue] No encoder -> maximal speed

Post by felix »

Hi,
I agree that it is a "normal" behaviour on a PID controler. Still if no other precautions are taken, a disconnecting the encoders means the robot will drive full speed without taking without slowing down even if we start sending low velocities to slow down.

The speed error limit seems a good way to handle this issue. Do you have any documentation on how to use it (I didn't found it in the python Library)?
User avatar
Basicmicro Support
Posts: 1594
Joined: Thu Feb 26, 2015 9:45 pm
Re: [security issue] No encoder -> maximal speed

Post by Basicmicro Support »

Yes it will. That is the nature of the beast.

There is no example in the python code. We highly recommend setting up PIDs in Motion Studio only.

1. You absolutely must use an acceleration value with any speed command if you enable speed error limits. Other wise you will have an instantaneous error equal to the requested motor speed as soon as you start the motor(eg motor is at speed 0, requested speed is 100000, your error is 100000). You need to set an accel rate the motor can achieve so the speed error is small.

2. Then you set a speed error above that small amount of error. If the motor gets stuck or the encoder fails(for any reason) the motor will be stopped when the error goes over the error limit set.

Post Reply