Constant motor speed at different battery level

Ok I see there has already been a bit of discussion on motor speeds but I am still a little lost on a good solution.

The bot will have lots of general use purposes but atm I want to use it for my openCV line follower see

I did notice another thread of line follower using openCV somewhere but can’t find it now, if any others are working on this let me know as I have the computer vision working very well.

I want to be able to control and steer accurately a bot with 2 drive wheels at front and a caster following wheel at the back. The bot needs to be able to drive at constant speed even as battery charge changes and also it would be much better if I could sink both motors for accurate steering.

Atm I just use BrickPi.MotorSpeed[port2] = speed to set motor speed but the actual speed that the motor turns will depend upon the battery level. It seems it more like sets the power level rather than the rotation degrees per time.

Also for steering I just set “BrickPi.MotorSpeed[port2] = speed” on one motor and “BrickPi.MotorSpeed[port2] = speed*percentsteer” on the other motor

If I am correct you now have the BrickPi3? Correct? You can then just use BP.set_motor_dps(port,DPS)
DPS stands for degrees per second. Normally when you just run the motor with a certain speed (With the new update its now called power) the power of the motor is controlled in PWM. So as the battery drains the motor power drains. However, that is not so much as an issue when using DPS.

Wonder why some threads no one replied to. :frowning:

It only now just let me know that this tread was replied too.

And yes I think BP.set_motor_dps(port,DPS) is the function that I need to use. I had an older version of the examples that I was looking at to learn how to use BrickPi3 and it used set_motor_speed which I now know is really set_motor_power and for constant speed I need to use set_motor_dps

set_motor_dps is indeed the method you would want to use to run at a consistent speed. As the batteries drain or the load increases, the PWM power is automatically adjusted (increased) to maintain the target speed. If it’s not capable of reaching the target speed (battery voltage too low or load to heavy for the target speed), the OVERLOADED bit returned by get_motor_status will be set.

set_motor_power sets the raw/unregulated PWM power level.