So I wanted to incorporate slew rate in my program this year and have done so successfully now using the Smart Motor Library. My question is, is there a way to only have slew rate applied to specific motors (ie, drivetrain motors) and not others?
I have tried adding a false at the end of my SetMotor command like this:
SetMotor(MogoLift, 127, false);
But this has not seemed to work and it seems slew rate is still applied to all my motors.
So, how do I “turn off” the effects of slew rate for some of my motors but not the others?
How can you tell that slew rate is still being applied when you are operating the robot? I imagine that it is a subtle difference between on & off.
It’s been a while since I looked at the library, but I’d be surprised if slew rate was causing you any issues. I’m sure the esteemed Mr. Pearman, who was summoned above, will step in when he’s able.
In the meantime, until he gives you the exact details, I know one thing offhand that would work. Since the max change per iteration is adjustable, you could just set a very large “max” number on any port you didn’t want to take long to change. Do that with:
SmartMotorSetSlewRate( portOfInterest, maxChangePerIteration );
So, setting the max to something like 100 means it would take only two passes to go from zero to 127, for instance. You could even set it to 500 to make the slew have essentially no effect for that port.
There’s probably some more official way to accomplish what you want, but this works.
Turns out there is not a more official way to turn off slew control for a motor. Here’s a screen shot from the documentation PDF:
There is also an undocumented but somehow implemented “off” value of zero, but from the cursory look at the code, I am not sure it works as intended. At least not w/o also calling SetMotor() with immediate=true
/* Copyright (c) James Pearman */ ...] SmartMotorSetSlewRate( tMotor index, int slew_rate = 10 ) ...] // negative is invalid // 0 is used to disable SM control of this motor if( slew_rate < 0 ) return; ...] // if 0 then we skip, motor is disabled from control if( m->motor_slew == 0 ) continue; ...]