How do negative values for velocity affect motors?

A lot of sources are saying that, when set to a negative velocity, motors will drive in the opposite direction. However, there are an equal amount of sources that say they don’t.
Python

# Not using a drivetrain
motor1.set_velocity(-50, PERCENT)
motor1.spin(FORWARD)

Will this code snippet cause the motor to spin forward or backward at fifty percent? What happens if you call motor1.spin() without any parameters? Normally, I’d test this myself, but I have to wait a long time until I get access to any motors in person.

The motor will spin backwards because it sends negative voltage to the motor making it spin reverse of what you specifiy in the spin parameter :
Ex:
forward sign 1 * -1 = backward sign -1
Consider the following C++ code :

motorPower = kP * error + kD* d // Error desired-actual  D : err-prevErr
SpinAllMotors(motorPower) // Default direction (forward)

This is a snippet of my pid and when it over shoots it has a negative error value so if I were to plug that in the power would be negative and the drivetrain moves backwards.

4 Likes

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.