Motion Profile Generator to Turn in Place

Is there a motion profile generator with a GUI that will allow you to create “turn in place” profiles while generating headings at each time step?

Barring that, I suppose I’m left to generating the distances to make the robot turn an angle, flipping the signs on one side, and then using a spreadsheet to generate the angles at each time step mathematically based on the expected wheel positions. Or we could just zero out the gyro term while turning in place. But that seems really counterproductive to turn without a gyro.

Ideally you build a robot that doesn’t need to turn in place in auto, but we didn’t, so that’s that :smiley:

Just use a raw gyro loop (possibly cascaded to velocity loops if you want to avoid some of the tricks needed to get it to work well).

A method I’ve found to work is:

  1. Use the gyro to periodically get a new angle setpoint
  2. Convert the angle to displacements for the left and right side of the drivetrain
  3. Pass the wheel displacements as position setpoints into motion magic on the Talon SRX

Essentially this “motion profiles” the turn, but it adjusts using the gyro throughout the movement.

In theory the conversion between angle and wheel displacement is as simple as displacement = angle * trackwidth/2. However, because of wheel scrub, you’ll likely need an additional multiplier, changing the equation to displacement = angle * trackwidth/2 * scrubfactor. The best way to tune this scrub factor is probably just to turn in place ~5-10 times and measure actual wheel displacement.

This is essentially what we do (on the fly instead of in a spreadsheet, but same idea).

If wheel slip isn’t very consistent for your bot (a very common issue), it may be desirable to re-generate the final setpoint/motion profile on the fly by iteratively looking at actual gyro angle vs. target and recomputing the estimated wheel displacement left to go. In 2017 we did the latter on the RoboRIO, and kept feeding new setpoints to Talon SRXs in motion magic mode. Worked great.

And we got the idea from you all :smiley:

Yeah, you guys are light years ahead of us. Right now, just creating an accurate following system is the goal utilizing the roborio. The generation can be as clunky as it wants for now. We’ll get to the point where we worry about generation later. /jealous

I understand the other suggestions - using the gyro in closed loop, or using the gyro to create expected lengths and then using the motion magic on the talon to get there. But now we’re talking about more constants to tune, and swapping in and out of closed loop control on the talon.

In the ideal world, I’d like our following code to handle turning in place just like it does following a trajectory. Now, that may end up being impossible because the scrub may be significantly different between trajectories and turning in place (omnis at the ends and traction in the middle to minimize scrub). But it’s the more elegant solution if we can make it work.

You can try to characterize the scrub for turning in place and just do the same thing you do for following translating trajectories. It’s another parameter, but it’s actually one of the easiest to tune. Turn the robot in place ex. 10 times, measure encoder displacement (average between left and right sides), divide by 10*pi, and now you have an “effective wheel base diameter” parameter you can use to generate displacements.

Do you use that characterization to calculate your wheel base for all your trajectories, or just for the ones that turn in place?

Our testing indicates that the “effective trackwidth” parameter doesn’t change much/at all with forward velocity or angular velocity, so you can use it for all your trajectories.