Scaling acceleration? drive motors java

We are using tank drive and its very herky jerky. We have the talons on coast.

We are currently using -1 for left motor(s) and .97 for right motor(s).
-This drives straight at full speed

Questions:

  1. Is there a better way in java to program motors without getting DOUBLES from axis?
  2. Do teams use some type of scaling system where if both thumb stick axis are held up for 2 seconds or more its full speed and if its under 2 seconds its increasing (without using a throttle).
  3. Do you ever need to be driving in full speed or is full tilt herky jerky for even the smooth driving teams? (in high gear)

Open to any ideas just want to get a smoother drive robot.

You could potentially configure a voltage ramp rate on the Talons, which will help limit your max acceleration. Do you have a tall robot?

2 Likes

No its very low. Just doing level 1 stuff this year (our 2nd year).

We will usually square our input controls (to give more fine control but retain high speed) and add a small ramp rate to remove some jerkiness. On top of that we give the drivers a “precision” button that will reduce (scale down) the inputs.
Side note, one of our drivers is a speed demon and always goes full speed, refuses to use the precision button. Others find it useful for lining up.

Yeah the quickest fix would be to set up a ramp rate on the Talon. https://phoenix-documentation.readthedocs.io/en/latest/ch13_MC.html?highlight=ramp

Note that if your right side is driving at 0.97 for full speed, you would want to set up two different ramp rates for the two different sides. For example if you set up your left 0-100% ramp to 2 seconds (might be a bit slow but you can experiment), you would want to configure your right side to ramp from 0-97% in 2 seconds. That way they move roughly in unison.

Can anyone screenshot their ramprates? I understand how its used but want to see what a good value to start working around.

You need to get doubles from the joystick axes. Otherwise you will not be able to drive smoothly.

Yes we are getting doubles. I was wondering if there was a better way than doubles?

Since the Joystick object returns a Double, I can’t think of a better option. What is your concern with using Doubles?

just driving full speed to fast. I didn’t know if teams drove with encoders or something other than getting doubles from axis.

We may need some more information about what precisely you mean by “herky jerky.”

If you mean “when the robot accelerates, my robot does wheelies”, then you may want to limit your maximum acceleration. One simple way is by calling configOpenloopRamp() and configClosedloopRamp() on the TalonSRX, which is what @pkrishna3082 recommended.

If you mean “when the robot accelerates, the robot is browning out and/or the breakers are tripping, causing stutters in acceleration” then you may need to limit current to the motors. You can use enableCurrentLimit() and configContinuousCurrentLimit() to help you there.

If you mean “when I drive the robot forward, it doesn’t drive straight,” then you can either try and guess what the right ratio of left power<->right power is, or you could use a gyro. If the total commanded rotation of the robot is very small, we save the current heading of the robot and use PID to hold that heading until the commanded rotation passes a threshold.

If you mean something else… then please explain. =]

1 Like

Herkey jerky meaning it goes to 0% 100% too fast. I don’t want to be a Ferrari i want to be a mom mobile in a mini van that is safe and smooth.

How would you use closedloopRamp() to say : “dont go 100% unless the axis have been full speed for 2 seconds or more” ??

In theory, it would be something like this:

// create your talon
TalonSRX t = new TalonSRX(1);
// set a 2-second neutral to full ramp
t.configOpenloopRamp(2, 0);

However, that is a pretty long time. Play around with the first parameter of configOpenloopRamp and you’ll see for yourself - the robot will be smooth, but require a lot of prediction to control as a human.

2 Likes

Does that stay at 0 on the motors for 2 seconds? or how does it actually work?

It’s the number of seconds from neutral to full.

Say you set the value to 0.5, and had the robot start with neutral joysticks. at time = 0 (t=0), the output power is 0. Then, you jam the joysticks full forward.

t(sec)|    power
0.1   | 0.2
0.2   | 0.4
0.3   | 0.6
0.4   | 0.8
0.5   | 1.0

You decide this is still too fast, so you go for 2.

t(sec)|    power
0.1   | 0.05
0.2   | 0.10
0.3   | 0.15
0.4   | 0.20
0.5   | 0.25
...
2     | 1.0
3 Likes

this is beautiful thank you for quick and easy explanation !

It’s important to know that open loop ramp rates are both acceleration and deceleration. If you are just looking to smooth out the acceleration curve so it’s not herky-jerky, you can just raise the joystick input value to some exponent. Depending on the gear reductions you have on your robot you can either raise to the 2nd, 3rd, or 4th power. The larger the exponent, the flatter the curve in the lower end.

ok is there a chart to refer to on raising the inputs and how that smooths it out? I’m going to try it but want to understand it so I can teach it to my students

Squaring (or a higher power) the input essentially let’s you get more fine control of low speeds because the first 80% of controller stick movement translate to 0-60% of the bot’s speed, while the last 20% of the stick movement takes you from 60% to 100%. This usually works out because most of the time your driver is either trying to do some precision alignment at low speeds or trying to go as fast as possible.

Squaring the input also helps because our perception of speed is non-linear. If I showed you a video of car driving down a highway and asked you “Is that car going 70mph or 75mph?”, you would likely have a hard time answering. If I showed you a video of a much slower car and said, “Is that car driving at 5mph or 10mph”, it would be much easier to answer even though the difference is only 5mph in both cases.

We found that the voltage ramping results in smoother movements, but also causes the driver to feel a control delay. If you’re at top speed and the ramping is set to 2, then if your driver commands the robot to stop, the robot won’t completely stop until 2 seconds later. Because of this, we tuned our ramping down as low as possible to prevent tipping/jerking/wheels popping up but also to give low latency driver control.

I was just going to mention the ‘floaty’ feeling you start to get when you ramp. You don’t notice it as much under acceleration, but under deceleration you will notice it quite a bit. The robot will continue to power forward even after you release the sticks. This also gets ugly in turning, where the higher power side will take time to ramp down. We use the ramp rate as little as possible, just to help the initial power draw if the drive goes full forward to full back. We’ve moved over to velocity control of the drivetrain this year and found it to be much smoother and more responsive than any type of %output that we’ve used in the past.

1 Like