duty_limit in run_until_stalled() #1293
Replies: 5 comments 3 replies
-
|
It defaults to 100%. "Won't be changed" means that if you have changed the maximum voltage/duty elsewhere in your code, it will return to that value after |
Beta Was this translation helpful? Give feedback.
-
|
Speaking of stalls, is there a reason we can't have a duty_limit with the stalled() method for drivebases? |
Beta Was this translation helpful? Give feedback.
-
|
I came up with this for driving until stalled. Seems to work pretty good. I found that anything less than 3000mV was pretty unreliable, so that is the minimum. 9000mV is the max. def DriveUntilStalled(
self,
speed=STRAIGHT_SPEED,
turn_rate=0,
stall=100,
useGyro=True,
):
if stall > 100:
stall = 100
if stall < 0:
stall = 0
# convert the percentage to a value between 3000 & 9000
stallValue = MIN_LARGE_MOTOR_VOLTAGE + stall / 100 * (
MAX_LARGE_MOTOR_VOLTAGE - MIN_LARGE_MOTOR_VOLTAGE
)
self.robot.use_gyro(useGyro)
self.leftDriveMotor.settings(stallValue)
self.rightDriveMotor.settings(stallValue)
self.robot.drive(speed, turn_rate)
while not self.robot.stalled():
wait(100)
self.robot.drive(0, 0)
wait(100)
self.leftDriveMotor.settings(MAX_LARGE_MOTOR_VOLTAGE)
self.rightDriveMotor.settings(MAX_LARGE_MOTOR_VOLTAGE)
self.robot.use_gyro(True) |
Beta Was this translation helpful? Give feedback.
-
|
Thanks for the tip! I was not aware of those methods. I did some testing, and I am not seeing what I thought I'd be seeing. I set it up so that I can pass in a percentage for the stall speed, and the stallSpeed is calculated based on the command speed. The way I read the documentation, if the stall speed can't be reached/maintained for the given time, the drivebase is determined to be stalled. So, in my case, if I set the stallSpeedPct to 99, and give a command speed of 400, the drivebase should be considered stalled if it can't maintain 396 mm/s. In other words, it should stall pretty easily. Similarly, if I set the stall percent to 1%, the drivebase should not be considered stalled unless it couldn't maintain 4mm/s. But what I am actually seeing is that the drivebase actually stalls at around the same point no matter what percent I set it to. As you can see, I have it printing out the state while it is running, and I can gently put more and more friction on the wheel with my finger, and sure enough, it seems to always stall the same way. Any thoughts on what I might be doing wrong? def DriveUntilStalled2(
self,
targetSpeed=STRAIGHT_SPEED,
turn_rate=0,
stallSpeedPct=99,
useGyro=True,
):
if stallSpeedPct > 99:
stallSpeedPct = 99
if stallSpeedPct < 0:
stallSpeedPct = 0
stallSpeed = int(targetSpeed * stallSpeedPct / 100)
self.robot.distance_control.stall_tolerances(
speed=stallSpeed,
time=100,
)
print(self.robot.distance_control.limits())
print(self.robot.distance_control.stall_tolerances())
self.robot.use_gyro(useGyro)
self.robot.drive(targetSpeed, turn_rate)
while not self.robot.stalled():
print(self.robot.state())
wait(500)
self.robot.drive(0, 0)
wait(100)
self.robot.use_gyro(True)Calling with something like this: br.DriveUntilStalled2(
targetSpeed=460, turn_rate=0, stallSpeedPct=1, useGyro=False
) |
Beta Was this translation helpful? Give feedback.
-
|
Yes, I am attempting to determine when the robot runs into a wall or anything. I thought I was limiting the torque with the stall_tolerances() function??? Doesn't that set the limit for determining when the robot is stalled? Or should I be using control.limits()? Or both?? |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Regarding the duty_limit parameter for run_until_stalled(), the documentation says "If it is None, the duty limit won’t be changed during this command". What does it mean "won't be changed"? Changed from what? I don't see any mention of a default duty_limit parameter.
Beta Was this translation helpful? Give feedback.
All reactions